diff --git a/addons/ofxPoco/src/ofxXmlPoco.cpp b/addons/ofxPoco/src/ofxXmlPoco.cpp index 5b9901b8e97..7851ebb549f 100644 --- a/addons/ofxPoco/src/ofxXmlPoco.cpp +++ b/addons/ofxPoco/src/ofxXmlPoco.cpp @@ -42,7 +42,7 @@ ofxXmlPoco::ofxXmlPoco(){ } -bool ofxXmlPoco::load(const std::filesystem::path & path){ +bool ofxXmlPoco::load(const fs::path & path){ ofFile file(path, ofFile::ReadOnly); if(!file.exists()){ ofLogError("ofxXmlPoco") << "couldn't load, \"" << file.getFileName() << "\" not found"; @@ -53,7 +53,7 @@ bool ofxXmlPoco::load(const std::filesystem::path & path){ } -bool ofxXmlPoco::save(const std::filesystem::path & path){ +bool ofxXmlPoco::save(const fs::path & path){ ofBuffer buffer; buffer.set(toString()); ofFile file(path, ofFile::WriteOnly); diff --git a/addons/ofxPoco/src/ofxXmlPoco.h b/addons/ofxPoco/src/ofxXmlPoco.h index a71fa53827a..a582288f133 100644 --- a/addons/ofxPoco/src/ofxXmlPoco.h +++ b/addons/ofxPoco/src/ofxXmlPoco.h @@ -41,8 +41,8 @@ class ofxXmlPoco{ ofxXmlPoco( const ofxXmlPoco& rhs ); const ofxXmlPoco& operator =( const ofxXmlPoco& rhs ); - bool load(const std::filesystem::path & path); - bool save(const std::filesystem::path & path); + bool load(const fs::path & path); + bool save(const fs::path & path); bool addChild( const std::string& path ); void addXml( ofxXmlPoco& xml, bool copyAll = false); diff --git a/libs/openFrameworks/3d/ofMesh.h b/libs/openFrameworks/3d/ofMesh.h index a2c67829aa3..c5303682385 100644 --- a/libs/openFrameworks/3d/ofMesh.h +++ b/libs/openFrameworks/3d/ofMesh.h @@ -591,7 +591,7 @@ class ofMesh_{ /// /// It expects that the file will be in the [PLY Format](http://en.wikipedia.org/wiki/PLY_(file_format)). /// It will only load meshes saved in the PLY ASCII format; the binary format is not supported. - void load(const std::filesystem::path& path); + void load(const fs::path& path); /// \brief Saves the mesh at the passed path in the [PLY Format](http://en.wikipedia.org/wiki/PLY_(file_format)). /// @@ -602,7 +602,7 @@ class ofMesh_{ /// If you're planning on reloading the mesh into ofMesh, ofMesh currently only supports loading the ASCII format. /// /// For more information, see the [PLY format specification](http://paulbourke.net/dataformats/ply/). - void save(const std::filesystem::path& path, bool useBinary = false) const; + void save(const fs::path& path, bool useBinary = false) const; /// \} diff --git a/libs/openFrameworks/3d/ofMesh.inl b/libs/openFrameworks/3d/ofMesh.inl index a68ab1cadec..70ba1f63b5a 100644 --- a/libs/openFrameworks/3d/ofMesh.inl +++ b/libs/openFrameworks/3d/ofMesh.inl @@ -1030,7 +1030,7 @@ void ofMesh_::append(const ofMesh_ & mesh){ //-------------------------------------------------------------- template -void ofMesh_::load(const std::filesystem::path& path){ +void ofMesh_::load(const fs::path& path){ ofFile is(path, ofFile::ReadOnly); auto & data = *this; @@ -1271,7 +1271,7 @@ void ofMesh_::load(const std::filesystem::path& path){ //-------------------------------------------------------------- template -void ofMesh_::save(const std::filesystem::path& path, bool useBinary) const{ +void ofMesh_::save(const fs::path& path, bool useBinary) const{ ofFile os(path, ofFile::WriteOnly); const auto & data = *this; diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index bb253612282..bf61346e80b 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -1375,7 +1375,7 @@ void ofAppGLFWWindow::drop_cb(GLFWwindow* windowP_, int numFiles, const char** d drag.position = {instance->events().getMouseX(), instance->events().getMouseY()}; drag.files.resize(numFiles); for(int i=0; i<(int)drag.files.size(); i++){ - drag.files[i] = std::filesystem::path(dropString[i]).string(); + drag.files[i] = fs::path(dropString[i]).string(); } instance->events().notifyDragEvent(drag); } diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index 223b08c99d3..b97012b9454 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -196,12 +196,12 @@ ofShader & ofShader::operator=(ofShader && mom){ } //-------------------------------------------------------------- -bool ofShader::load(const std::filesystem::path& shaderName) { +bool ofShader::load(const fs::path& shaderName) { return load(shaderName.string() + ".vert", shaderName.string() + ".frag"); } //-------------------------------------------------------------- -bool ofShader::load(const std::filesystem::path& vertName, const std::filesystem::path& fragName, const std::filesystem::path& geomName) { +bool ofShader::load(const fs::path& vertName, const fs::path& fragName, const fs::path& geomName) { if(vertName.empty() == false) setupShaderFromFile(GL_VERTEX_SHADER, vertName); if(fragName.empty() == false) setupShaderFromFile(GL_FRAGMENT_SHADER, fragName); #ifndef TARGET_OPENGLES @@ -215,7 +215,7 @@ bool ofShader::load(const std::filesystem::path& vertName, const std::filesystem #if !defined(TARGET_OPENGLES) && defined(glDispatchCompute) //-------------------------------------------------------------- -bool ofShader::loadCompute(const std::filesystem::path& shaderName) { +bool ofShader::loadCompute(const fs::path& shaderName) { return setupShaderFromFile(GL_COMPUTE_SHADER, shaderName) && linkProgram(); } #endif @@ -292,7 +292,7 @@ bool ofShader::setup(const TransformFeedbackSettings & settings) { #endif //-------------------------------------------------------------- -bool ofShader::setupShaderFromFile(GLenum type, const std::filesystem::path& filename) { +bool ofShader::setupShaderFromFile(GLenum type, const fs::path& filename) { ofBuffer buffer = ofBufferFromFile(filename); // we need to make absolutely sure to have an absolute path here, so that any #includes // within the shader files have a root directory to traverse from. @@ -307,7 +307,7 @@ bool ofShader::setupShaderFromFile(GLenum type, const std::filesystem::path& fil } //-------------------------------------------------------------- -ofShader::Source ofShader::sourceFromFile(GLenum type, const std::filesystem::path& filename) { +ofShader::Source ofShader::sourceFromFile(GLenum type, const fs::path& filename) { ofBuffer buffer = ofBufferFromFile(filename); // we need to make absolutely sure to have an absolute path here, so that any #includes // within the shader files have a root directory to traverse from. @@ -413,13 +413,13 @@ bool ofShader::setupShaderFromSource(ofShader::Source && source){ */ //-------------------------------------------------------------- -string ofShader::parseForIncludes( const string& source, const std::filesystem::path& sourceDirectoryPath) { +string ofShader::parseForIncludes( const string& source, const fs::path& sourceDirectoryPath) { vector included; return parseForIncludes( source, included, 0, sourceDirectoryPath); } //-------------------------------------------------------------- -string ofShader::parseForIncludes( const string& source, vector& included, int level, const std::filesystem::path& sourceDirectoryPath) { +string ofShader::parseForIncludes( const string& source, vector& included, int level, const fs::path& sourceDirectoryPath) { if ( level > 32 ) { ofLogError( "ofShader", "glsl header inclusion depth limit reached, might be caused by cyclic header inclusion" ); diff --git a/libs/openFrameworks/gl/ofShader.h b/libs/openFrameworks/gl/ofShader.h index 7bb7c5cd587..d924197b7a1 100644 --- a/libs/openFrameworks/gl/ofShader.h +++ b/libs/openFrameworks/gl/ofShader.h @@ -26,18 +26,18 @@ typedef ofColor_ ofFloatColor; enum ofLogLevel: short; struct ofShaderSettings { - std::map shaderFiles; + std::map shaderFiles; std::map shaderSources; std::map intDefines; std::map floatDefines; - std::filesystem::path sourceDirectoryPath; + fs::path sourceDirectoryPath; bool bindDefaults = true; }; class ofShader { struct Source{ - Source(GLuint type, const std::string & source, const std::filesystem::path & directoryPath) + Source(GLuint type, const std::string & source, const fs::path & directoryPath) :type(type) ,source(source) ,directoryPath(directoryPath){} @@ -47,7 +47,7 @@ class ofShader { GLuint type; std::string source; std::string expandedSource; - std::filesystem::path directoryPath; + fs::path directoryPath; std::map intDefines; std::map floatDefines; }; @@ -60,20 +60,20 @@ class ofShader { ofShader(ofShader && shader); ofShader & operator=(ofShader && shader); - bool load(const std::filesystem::path& shaderName); - bool load(const std::filesystem::path& vertName, const std::filesystem::path& fragName, const std::filesystem::path& geomName=""); + bool load(const fs::path& shaderName); + bool load(const fs::path& vertName, const fs::path& fragName, const fs::path& geomName=""); #if !defined(TARGET_OPENGLES) && defined(glDispatchCompute) - bool loadCompute(const std::filesystem::path& shaderName); + bool loadCompute(const fs::path& shaderName); #endif #if !defined(TARGET_OPENGLES) struct TransformFeedbackSettings { - std::map shaderFiles; + std::map shaderFiles; std::map shaderSources; std::vector varyingsToCapture; std::map intDefines; std::map floatDefines; - std::filesystem::path sourceDirectoryPath; + fs::path sourceDirectoryPath; bool bindDefaults = true; GLuint bufferMode = GL_INTERLEAVED_ATTRIBS; // GL_INTERLEAVED_ATTRIBS or GL_SEPARATE_ATTRIBS }; @@ -229,7 +229,7 @@ class ofShader { // these methods create and compile a shader from source or file // type: GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, GL_GEOMETRY_SHADER_EXT etc. bool setupShaderFromSource(GLenum type, std::string source, std::string sourceDirectoryPath = ""); - bool setupShaderFromFile(GLenum type, const std::filesystem::path& filename); + bool setupShaderFromFile(GLenum type, const fs::path& filename); // links program with all compiled shaders bool linkProgram(); @@ -278,7 +278,7 @@ class ofShader { #endif bool setupShaderFromSource(Source && source); - ofShader::Source sourceFromFile(GLenum type, const std::filesystem::path& filename); + ofShader::Source sourceFromFile(GLenum type, const fs::path& filename); void checkProgramInfoLog(); bool checkProgramLinkStatus(); void checkShaderInfoLog(GLuint shader, GLenum type, ofLogLevel logLevel); @@ -295,8 +295,8 @@ class ofShader { /// @note Include paths are always specified _relative to the including file's current path_ /// @note Recursive #pragma include statements are possible /// @note Includes will be processed up to 32 levels deep - static std::string parseForIncludes( const std::string& source, const std::filesystem::path& sourceDirectoryPath = ""); - static std::string parseForIncludes( const std::string& source, std::vector& included, int level = 0, const std::filesystem::path& sourceDirectoryPath = ""); + static std::string parseForIncludes( const std::string& source, const fs::path& sourceDirectoryPath = ""); + static std::string parseForIncludes( const std::string& source, std::vector& included, int level = 0, const fs::path& sourceDirectoryPath = ""); void checkAndCreateProgram(); #ifdef TARGET_ANDROID diff --git a/libs/openFrameworks/graphics/ofImage.cpp b/libs/openFrameworks/graphics/ofImage.cpp index 3515b3e2224..fcf54709d08 100644 --- a/libs/openFrameworks/graphics/ofImage.cpp +++ b/libs/openFrameworks/graphics/ofImage.cpp @@ -180,7 +180,7 @@ static int getJpegOptionFromImageLoadSetting(const ofImageLoadSettings &settings } template -static bool loadImage(ofPixels_ & pix, const std::filesystem::path& _fileName, const ofImageLoadSettings& settings){ +static bool loadImage(ofPixels_ & pix, const fs::path& _fileName, const ofImageLoadSettings& settings){ ofInitFreeImage(); auto uriStr = _fileName.string(); @@ -297,7 +297,7 @@ static bool loadImage(ofPixels_ & pix, const ofBuffer & buffer, const } //---------------------------------------------------------------- -bool ofLoadImage(ofPixels & pix, const std::filesystem::path& path, const ofImageLoadSettings &settings) { +bool ofLoadImage(ofPixels & pix, const fs::path& path, const ofImageLoadSettings &settings) { return loadImage(pix, path, settings); } @@ -307,7 +307,7 @@ bool ofLoadImage(ofPixels & pix, const ofBuffer & buffer, const ofImageLoadSetti } //---------------------------------------------------------------- -bool ofLoadImage(ofShortPixels & pix, const std::filesystem::path& path, const ofImageLoadSettings &settings) { +bool ofLoadImage(ofShortPixels & pix, const fs::path& path, const ofImageLoadSettings &settings) { return loadImage(pix, path, settings); } @@ -317,7 +317,7 @@ bool ofLoadImage(ofShortPixels & pix, const ofBuffer & buffer, const ofImageLoad } //---------------------------------------------------------------- -bool ofLoadImage(ofFloatPixels & pix, const std::filesystem::path& path, const ofImageLoadSettings &settings) { +bool ofLoadImage(ofFloatPixels & pix, const fs::path& path, const ofImageLoadSettings &settings) { return loadImage(pix, path, settings); } @@ -327,7 +327,7 @@ bool ofLoadImage(ofFloatPixels & pix, const ofBuffer & buffer, const ofImageLoad } //---------------------------------------------------------------- -bool ofLoadImage(ofTexture & tex, const std::filesystem::path& path, const ofImageLoadSettings &settings){ +bool ofLoadImage(ofTexture & tex, const fs::path& path, const ofImageLoadSettings &settings){ ofPixels pixels; bool loaded = ofLoadImage(pixels, path, settings); if(loaded){ @@ -350,7 +350,7 @@ bool ofLoadImage(ofTexture & tex, const ofBuffer & buffer, const ofImageLoadSett //---------------------------------------------------------------- template -static bool saveImage(const ofPixels_ & _pix, const std::filesystem::path& _fileName, ofImageQualityType qualityLevel) { +static bool saveImage(const ofPixels_ & _pix, const fs::path& _fileName, ofImageQualityType qualityLevel) { ofInitFreeImage(); if (_pix.isAllocated() == false){ ofLogError("ofImage") << "saveImage(): couldn't save \"" << _fileName << "\", pixels are not allocated"; @@ -435,17 +435,17 @@ static bool saveImage(const ofPixels_ & _pix, const std::filesystem:: } //---------------------------------------------------------------- -bool ofSaveImage(const ofPixels & pix, const std::filesystem::path& fileName, ofImageQualityType qualityLevel){ +bool ofSaveImage(const ofPixels & pix, const fs::path& fileName, ofImageQualityType qualityLevel){ return saveImage(pix,fileName,qualityLevel); } //---------------------------------------------------------------- -bool ofSaveImage(const ofFloatPixels & pix, const std::filesystem::path& fileName, ofImageQualityType qualityLevel) { +bool ofSaveImage(const ofFloatPixels & pix, const fs::path& fileName, ofImageQualityType qualityLevel) { return saveImage(pix,fileName,qualityLevel); } //---------------------------------------------------------------- -bool ofSaveImage(const ofShortPixels & pix, const std::filesystem::path& fileName, ofImageQualityType qualityLevel) { +bool ofSaveImage(const ofShortPixels & pix, const fs::path& fileName, ofImageQualityType qualityLevel) { return saveImage(pix,fileName,qualityLevel); } @@ -603,7 +603,7 @@ ofImage_::ofImage_(const ofPixels_ & pix){ } template -ofImage_::ofImage_(const std::filesystem::path & fileName, const ofImageLoadSettings &settings){ +ofImage_::ofImage_(const fs::path & fileName, const ofImageLoadSettings &settings){ width = 0; height = 0; bpp = 0; @@ -700,7 +700,7 @@ bool ofImage_::loadImage(const ofFile & file){ //---------------------------------------------------------- template -bool ofImage_::load(const std::filesystem::path& fileName, const ofImageLoadSettings &settings){ +bool ofImage_::load(const fs::path& fileName, const ofImageLoadSettings &settings){ #if defined(TARGET_ANDROID) ofAddListener(ofxAndroidEvents().unloadGL,this,&ofImage_::unloadTexture); ofAddListener(ofxAndroidEvents().reloadGL,this,&ofImage_::update); @@ -746,7 +746,7 @@ bool ofImage_::loadImage(const ofBuffer & buffer){ //---------------------------------------------------------- template -bool ofImage_::save(const std::filesystem::path& fileName, ofImageQualityType qualityLevel) const { +bool ofImage_::save(const fs::path& fileName, ofImageQualityType qualityLevel) const { return ofSaveImage(pixels, fileName, qualityLevel); } diff --git a/libs/openFrameworks/graphics/ofImage.h b/libs/openFrameworks/graphics/ofImage.h index 42a2c616b22..1f3030d423d 100644 --- a/libs/openFrameworks/graphics/ofImage.h +++ b/libs/openFrameworks/graphics/ofImage.h @@ -134,27 +134,27 @@ struct ofImageLoadSettings { /// \todo Needs documentation. -bool ofLoadImage(ofPixels & pix, const std::filesystem::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); +bool ofLoadImage(ofPixels & pix, const fs::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); bool ofLoadImage(ofPixels & pix, const ofBuffer & buffer, const ofImageLoadSettings &settings = ofImageLoadSettings()); -bool ofLoadImage(ofFloatPixels & pix, const std::filesystem::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); +bool ofLoadImage(ofFloatPixels & pix, const fs::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); bool ofLoadImage(ofFloatPixels & pix, const ofBuffer & buffer, const ofImageLoadSettings &settings = ofImageLoadSettings()); -bool ofLoadImage(ofShortPixels & pix, const std::filesystem::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); +bool ofLoadImage(ofShortPixels & pix, const fs::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); bool ofLoadImage(ofShortPixels & pix, const ofBuffer & buffer, const ofImageLoadSettings &settings = ofImageLoadSettings()); /// \todo Needs documentation. -bool ofLoadImage(ofTexture & tex, const std::filesystem::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); +bool ofLoadImage(ofTexture & tex, const fs::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); bool ofLoadImage(ofTexture & tex, const ofBuffer & buffer, const ofImageLoadSettings &settings = ofImageLoadSettings()); /// \todo Needs documentation. -bool ofSaveImage(const ofPixels & pix, const std::filesystem::path& path, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST); +bool ofSaveImage(const ofPixels & pix, const fs::path& path, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST); bool ofSaveImage(const ofPixels & pix, ofBuffer & buffer, ofImageFormat format = OF_IMAGE_FORMAT_PNG, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST); /// \todo Needs documentation. -bool ofSaveImage(const ofFloatPixels & pix, const std::filesystem::path& path, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST); +bool ofSaveImage(const ofFloatPixels & pix, const fs::path& path, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST); bool ofSaveImage(const ofFloatPixels & pix, ofBuffer & buffer, ofImageFormat format = OF_IMAGE_FORMAT_PNG, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST); /// \todo Needs documentation. -bool ofSaveImage(const ofShortPixels & pix, const std::filesystem::path& path, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST); +bool ofSaveImage(const ofShortPixels & pix, const fs::path& path, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST); bool ofSaveImage(const ofShortPixels & pix, ofBuffer & buffer, ofImageFormat format = OF_IMAGE_FORMAT_PNG, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST); /// \brief Deallocates FreeImage resources. @@ -173,7 +173,7 @@ class ofImage_ : public ofBaseImage_{ ofImage_(); ofImage_(const ofPixels_ & pix); - ofImage_(const std::filesystem::path & fileName, const ofImageLoadSettings &settings = ofImageLoadSettings()); + ofImage_(const fs::path & fileName, const ofImageLoadSettings &settings = ofImageLoadSettings()); ofImage_(const ofImage_& mom); ofImage_(ofImage_&& mom); @@ -217,7 +217,7 @@ class ofImage_ : public ofBaseImage_{ /// the data folder. /// \param settings Load options /// \returns true if image loaded correctly. - bool load(const std::filesystem::path& fileName, const ofImageLoadSettings &settings = ofImageLoadSettings()); + bool load(const fs::path& fileName, const ofImageLoadSettings &settings = ofImageLoadSettings()); /// \brief Loads an image from an ofBuffer instance created by, for /// instance, ofFile::readToBuffer(). @@ -599,7 +599,7 @@ class ofImage_ : public ofBaseImage_{ /// /// \param fileName Saves image to this path, relative to the data folder. /// \param compressionLevel The ofImageQualityType. - bool save(const std::filesystem::path & fileName, ofImageQualityType compressionLevel = OF_IMAGE_QUALITY_BEST) const; + bool save(const fs::path & fileName, ofImageQualityType compressionLevel = OF_IMAGE_QUALITY_BEST) const; /// \brief This saves the image to the ofBuffer passed with the image /// quality specified by compressionLevel. diff --git a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp index 077047179ee..6da745bfd17 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp @@ -372,8 +372,8 @@ static std::string linuxFontPathByName(const std::string& fontname){ #endif //----------------------------------------------------------- -static bool loadFontFace(const std::filesystem::path& _fontname, FT_Face & face, std::filesystem::path & filename, int index){ - std::filesystem::path fontname = _fontname; +static bool loadFontFace(const fs::path& _fontname, FT_Face & face, fs::path & filename, int index){ + fs::path fontname = _fontname; filename = ofToDataPath(_fontname,true); ofFile fontFile(filename,ofFile::Reference); int fontID = index; @@ -695,7 +695,7 @@ ofTrueTypeFont::glyph ofTrueTypeFont::loadGlyph(uint32_t utf8) const{ } //----------------------------------------------------------- -bool ofTrueTypeFont::load(const std::filesystem::path& filename, int fontSize, bool antialiased, bool fullCharacterSet, bool makeContours, float simplifyAmt, int dpi) { +bool ofTrueTypeFont::load(const fs::path& filename, int fontSize, bool antialiased, bool fullCharacterSet, bool makeContours, float simplifyAmt, int dpi) { ofTrueTypeFontSettings settings(filename,fontSize); settings.antialiased = antialiased; settings.contours = makeContours; diff --git a/libs/openFrameworks/graphics/ofTrueTypeFont.h b/libs/openFrameworks/graphics/ofTrueTypeFont.h index c9c3840887f..e3fdfb018b6 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.h +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.h @@ -138,7 +138,7 @@ enum ofTrueTypeFontDirection : uint32_t { struct ofTrueTypeFontSettings{ - std::filesystem::path fontName; + fs::path fontName; int fontSize = 0; bool antialiased = true; bool contours = false; @@ -148,7 +148,7 @@ struct ofTrueTypeFontSettings{ ofTrueTypeFontDirection direction = OF_TTF_LEFT_TO_RIGHT; std::vector ranges; - ofTrueTypeFontSettings(const std::filesystem::path & name, int size) + ofTrueTypeFontSettings(const fs::path & name, int size) :fontName(name) ,fontSize(size){} @@ -196,7 +196,7 @@ class ofTrueTypeFont{ /// \param simplifyAmt the amount to simplify the vector contours. Larger number means more simplified. /// \param dpi the dots per inch used to specify rendering size. /// \returns true if the font was loaded correctly. - bool load(const std::filesystem::path& filename, + bool load(const fs::path& filename, int fontsize, bool _bAntiAliased=true, bool _bFullCharacterSet=true, diff --git a/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp b/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp index 51cc5f05ac3..bff1013be40 100644 --- a/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp @@ -177,7 +177,7 @@ void ofFmodSoundPlayer::closeFmod(){ } //------------------------------------------------------------ -bool ofFmodSoundPlayer::load(const std::filesystem::path& _fileName, bool stream){ +bool ofFmodSoundPlayer::load(const fs::path& _fileName, bool stream){ auto fileName = ofToDataPath(_fileName); diff --git a/libs/openFrameworks/sound/ofFmodSoundPlayer.h b/libs/openFrameworks/sound/ofFmodSoundPlayer.h index b54f1b2e62d..e787f6bed04 100644 --- a/libs/openFrameworks/sound/ofFmodSoundPlayer.h +++ b/libs/openFrameworks/sound/ofFmodSoundPlayer.h @@ -41,7 +41,7 @@ class ofFmodSoundPlayer : public ofBaseSoundPlayer { ofFmodSoundPlayer(); virtual ~ofFmodSoundPlayer(); - bool load(const std::filesystem::path& fileName, bool stream = false); + bool load(const fs::path& fileName, bool stream = false); void unload(); void play(); void stop(); diff --git a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp index 7e7eb0ebcc6..caa12563c3c 100644 --- a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp @@ -229,7 +229,7 @@ void ofOpenALSoundPlayer::close(){ } // ---------------------------------------------------------------------------- -bool ofOpenALSoundPlayer::sfReadFile(const std::filesystem::path& path, std::vector & buffer, std::vector & fftAuxBuffer){ +bool ofOpenALSoundPlayer::sfReadFile(const fs::path& path, std::vector & buffer, std::vector & fftAuxBuffer){ SF_INFO sfInfo; SNDFILE* f = sf_open(path.string().c_str(),SFM_READ,&sfInfo); if(!f){ @@ -283,7 +283,7 @@ bool ofOpenALSoundPlayer::sfReadFile(const std::filesystem::path& path, std::vec #ifdef OF_USING_MPG123 //------------------------------------------------------------ -bool ofOpenALSoundPlayer::mpg123ReadFile(const std::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer){ +bool ofOpenALSoundPlayer::mpg123ReadFile(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer){ int err = MPG123_OK; mpg123_handle * f = mpg123_new(nullptr,&err); if(mpg123_open(f,path.string().c_str())!=MPG123_OK){ @@ -321,7 +321,7 @@ bool ofOpenALSoundPlayer::mpg123ReadFile(const std::filesystem::path& path,std:: #endif //------------------------------------------------------------ -bool ofOpenALSoundPlayer::sfStream(const std::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer){ +bool ofOpenALSoundPlayer::sfStream(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer){ if(!streamf){ SF_INFO sfInfo; streamf = sf_open(path.string().c_str(),SFM_READ,&sfInfo); @@ -384,7 +384,7 @@ bool ofOpenALSoundPlayer::sfStream(const std::filesystem::path& path,std::vector #ifdef OF_USING_MPG123 //------------------------------------------------------------ -bool ofOpenALSoundPlayer::mpg123Stream(const std::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer){ +bool ofOpenALSoundPlayer::mpg123Stream(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer){ if(!mp3streamf){ int err = MPG123_OK; mp3streamf = mpg123_new(nullptr,&err); @@ -435,7 +435,7 @@ bool ofOpenALSoundPlayer::mpg123Stream(const std::filesystem::path& path,std::ve #endif //------------------------------------------------------------ -bool ofOpenALSoundPlayer::stream(const std::filesystem::path& fileName, std::vector & buffer){ +bool ofOpenALSoundPlayer::stream(const fs::path& fileName, std::vector & buffer){ #ifdef OF_USING_MPG123 if(ofFilePath::getFileExt(fileName)=="mp3" || ofFilePath::getFileExt(fileName)=="MP3" || mp3streamf){ if(!mpg123Stream(fileName,buffer,fftAuxBuffer)) return false; @@ -455,7 +455,7 @@ bool ofOpenALSoundPlayer::stream(const std::filesystem::path& fileName, std::vec return true; } -bool ofOpenALSoundPlayer::readFile(const std::filesystem::path& fileName, std::vector & buffer){ +bool ofOpenALSoundPlayer::readFile(const fs::path& fileName, std::vector & buffer){ #ifdef OF_USING_MPG123 if(ofFilePath::getFileExt(fileName)!="mp3" && ofFilePath::getFileExt(fileName)!="MP3"){ if(!sfReadFile(fileName,buffer,fftAuxBuffer)) return false; @@ -478,9 +478,9 @@ bool ofOpenALSoundPlayer::readFile(const std::filesystem::path& fileName, std::v } //------------------------------------------------------------ -bool ofOpenALSoundPlayer::load(const std::filesystem::path& _fileName, bool is_stream){ +bool ofOpenALSoundPlayer::load(const fs::path& _fileName, bool is_stream){ - std::filesystem::path fileName = ofToDataPath(_fileName); + fs::path fileName = ofToDataPath(_fileName); bMultiPlay = false; isStreaming = is_stream; diff --git a/libs/openFrameworks/sound/ofOpenALSoundPlayer.h b/libs/openFrameworks/sound/ofOpenALSoundPlayer.h index 80df4f90cb6..b10af783425 100644 --- a/libs/openFrameworks/sound/ofOpenALSoundPlayer.h +++ b/libs/openFrameworks/sound/ofOpenALSoundPlayer.h @@ -49,7 +49,7 @@ class ofOpenALSoundPlayer : public ofBaseSoundPlayer, public ofThread { ofOpenALSoundPlayer(); virtual ~ofOpenALSoundPlayer(); - bool load(const std::filesystem::path& fileName, bool stream = false); + bool load(const fs::path& fileName, bool stream = false); void unload(); void play(); void stop(); @@ -93,15 +93,15 @@ class ofOpenALSoundPlayer : public ofBaseSoundPlayer, public ofThread { static void runWindow(std::vector & signal); static void initSystemFFT(int bands); - bool sfReadFile(const std::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer); - bool sfStream(const std::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer); + bool sfReadFile(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer); + bool sfStream(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer); #ifdef OF_USING_MPG123 - bool mpg123ReadFile(const std::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer); - bool mpg123Stream(const std::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer); + bool mpg123ReadFile(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer); + bool mpg123Stream(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer); #endif - bool readFile(const std::filesystem::path& fileName,std::vector & buffer); - bool stream(const std::filesystem::path& fileName, std::vector & buffer); + bool readFile(const fs::path& fileName,std::vector & buffer); + bool stream(const fs::path& fileName, std::vector & buffer); bool isStreaming; bool bMultiPlay; diff --git a/libs/openFrameworks/sound/ofSoundBaseTypes.h b/libs/openFrameworks/sound/ofSoundBaseTypes.h index 39b08a66a46..405cf280fed 100644 --- a/libs/openFrameworks/sound/ofSoundBaseTypes.h +++ b/libs/openFrameworks/sound/ofSoundBaseTypes.h @@ -168,7 +168,7 @@ class ofBaseSoundPlayer { ofBaseSoundPlayer(){}; virtual ~ofBaseSoundPlayer(){}; - virtual bool load(const std::filesystem::path& fileName, bool stream = false)=0; + virtual bool load(const fs::path& fileName, bool stream = false)=0; virtual void unload()=0; virtual void play() = 0; virtual void stop() = 0; diff --git a/libs/openFrameworks/sound/ofSoundPlayer.cpp b/libs/openFrameworks/sound/ofSoundPlayer.cpp index 543a0579428..4bbe7ba4a3c 100644 --- a/libs/openFrameworks/sound/ofSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofSoundPlayer.cpp @@ -73,7 +73,7 @@ std::shared_ptr ofSoundPlayer::getPlayer(){ } //-------------------------------------------------------------------- -bool ofSoundPlayer::load(const std::filesystem::path& fileName, bool stream){ +bool ofSoundPlayer::load(const fs::path& fileName, bool stream){ if( player ){ return player->load(fileName, stream); } diff --git a/libs/openFrameworks/sound/ofSoundPlayer.h b/libs/openFrameworks/sound/ofSoundPlayer.h index a24bfdcc50e..168d3e9b1fb 100644 --- a/libs/openFrameworks/sound/ofSoundPlayer.h +++ b/libs/openFrameworks/sound/ofSoundPlayer.h @@ -82,7 +82,7 @@ class ofSoundPlayer : public ofBaseSoundPlayer { /// /// \param fileName Path to the sound file, relative to your app's data folder. /// \param stream set "true" to enable streaming from disk (for large files). - bool load(const std::filesystem::path& fileName, bool stream = false); + bool load(const fs::path& fileName, bool stream = false); OF_DEPRECATED_MSG("Use load",bool loadSound(std::string fileName, bool stream = false)); /// \brief Stops and unloads the current sound. diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index 6d3a5e840ab..15cffc8ec33 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -453,7 +453,12 @@ std::unique_ptr make_unique(Args&&... args) { #ifndef OF_USING_STD_FS #if OF_HAS_CPP17 - #define OF_USING_STD_FS 1 + // if target includes version 10.14 or below + #if(MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_14) + #define OF_USING_STD_FS 0 + #else + #define OF_USING_STD_FS 1 + #endif #else // Set to 1 to force std filesystem instead of boost's #define OF_USING_STD_FS 0 @@ -514,7 +519,7 @@ std::unique_ptr make_unique(Args&&... args) { using v1::path; } } - namespace filesystem = experimental::filesystem; + namespace fs = experimental::filesystem; } #else namespace std { @@ -528,13 +533,14 @@ std::unique_ptr make_unique(Args&&... args) { using v1::__cxx11::path; } } - namespace filesystem = experimental::filesystem; + namespace fs = experimental::filesystem; } #endif #else // Regular C++17 fs support #include + namespace fs = std::filesystem; #endif #else // No experimental or c++17 filesytem support use boost @@ -548,7 +554,5 @@ std::unique_ptr make_unique(Args&&... args) { class path; } } - namespace std { - namespace filesystem = boost::filesystem; - } + namespace fs = boost::filesystem; #endif diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 897d408a308..232bb99a231 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -29,7 +29,7 @@ namespace{ string defaultDataPath(){ #if defined TARGET_OSX try{ - return std::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../data/")).string(); + return fs::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../data/")).string(); }catch(...){ return ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../data/"); } @@ -37,7 +37,7 @@ namespace{ return string("sdcard/"); #else try{ - return std::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); + return fs::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); }catch(...){ return ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/"); } @@ -45,14 +45,14 @@ namespace{ } //-------------------------------------------------- - std::filesystem::path & defaultWorkingDirectory(){ - static auto * defaultWorkingDirectory = new std::filesystem::path(ofFilePath::getCurrentExeDir()); + fs::path & defaultWorkingDirectory(){ + static auto * defaultWorkingDirectory = new fs::path(ofFilePath::getCurrentExeDir()); return * defaultWorkingDirectory; } //-------------------------------------------------- - std::filesystem::path & dataPathRoot(){ - static auto * dataPathRoot = new std::filesystem::path(defaultDataPath()); + fs::path & dataPathRoot(){ + static auto * dataPathRoot = new fs::path(defaultDataPath()); return *dataPathRoot; } } @@ -60,7 +60,7 @@ namespace{ namespace of{ namespace priv{ void initfileutils(){ - defaultWorkingDirectory() = std::filesystem::absolute(std::filesystem::current_path()); + defaultWorkingDirectory() = fs::absolute(fs::current_path()); } } } @@ -450,13 +450,13 @@ istream & operator>>(istream & istr, ofBuffer & buf){ } //-------------------------------------------------- -ofBuffer ofBufferFromFile(const std::filesystem::path & path, bool binary){ +ofBuffer ofBufferFromFile(const fs::path & path, bool binary){ ofFile f(path,ofFile::ReadOnly, binary); return ofBuffer(f); } //-------------------------------------------------- -bool ofBufferToFile(const std::filesystem::path & path, const ofBuffer& buffer, bool binary){ +bool ofBufferToFile(const fs::path & path, const ofBuffer& buffer, bool binary){ ofFile f(path, ofFile::WriteOnly, binary); return buffer.writeTo(f); } @@ -473,7 +473,7 @@ ofFile::ofFile() ,binary(true){ } -ofFile::ofFile(const std::filesystem::path & path, Mode mode, bool binary) +ofFile::ofFile(const fs::path & path, Mode mode, bool binary) :mode(mode) ,binary(true){ open(path, mode, binary); @@ -555,16 +555,16 @@ bool ofFile::openStream(Mode _mode, bool _binary){ } //------------------------------------------------------------------------------------------------------------ -bool ofFile::open(const std::filesystem::path & _path, Mode _mode, bool binary){ +bool ofFile::open(const fs::path & _path, Mode _mode, bool binary){ close(); - myFile = std::filesystem::path(ofToDataPath(_path.string())); + myFile = fs::path(ofToDataPath(_path.string())); return openStream(_mode, binary); } //------------------------------------------------------------------------------------------------------------ -bool ofFile::openFromCWD(const std::filesystem::path & _path, Mode _mode, bool binary){ +bool ofFile::openFromCWD(const fs::path & _path, Mode _mode, bool binary){ close(); - myFile = std::filesystem::path(_path.string()); + myFile = fs::path(_path.string()); return openStream(_mode, binary); } @@ -573,7 +573,7 @@ bool ofFile::changeMode(Mode _mode, bool binary){ if(_mode != mode){ string _path = path(); close(); - myFile = std::filesystem::path(_path); + myFile = fs::path(_path); return openStream(_mode, binary); } else{ @@ -588,7 +588,7 @@ bool ofFile::isWriteMode(){ //------------------------------------------------------------------------------------------------------------- void ofFile::close(){ - myFile = std::filesystem::path(); + myFile = fs::path(); if(mode!=Reference) fstream::close(); } @@ -598,7 +598,7 @@ bool ofFile::create(){ } //------------------------------------------------------------------------------------------------------------ -bool ofFile::create(const std::filesystem::path & path){ +bool ofFile::create(const fs::path & path){ bool success = false; auto oldmode = this->mode; @@ -614,7 +614,7 @@ bool ofFile::create(const std::filesystem::path & path){ //------------------------------------------------------------------------------------------------------------ ofBuffer ofFile::readToBuffer(){ - if(myFile.string().empty() || !std::filesystem::exists(myFile)){ + if(myFile.string().empty() || !fs::exists(myFile)){ return ofBuffer(); } @@ -643,7 +643,7 @@ bool ofFile::exists() const { return false; } - return std::filesystem::exists(myFile); + return fs::exists(myFile); } //------------------------------------------------------------------------------------------------------------ @@ -683,7 +683,7 @@ string ofFile::getAbsolutePath() const { //------------------------------------------------------------------------------------------------------------ bool ofFile::canRead() const { - auto perm = std::filesystem::status(myFile).permissions(); + auto perm = fs::status(myFile).permissions(); #ifdef TARGET_WIN32 DWORD attr = GetFileAttributes(myFile.native().c_str()); if (attr == INVALID_FILE_ATTRIBUTES) @@ -696,19 +696,19 @@ bool ofFile::canRead() const { stat(path().c_str(), &info); // Error check omitted #if OF_USING_STD_FS if(geteuid() == info.st_uid){ - return (perm & std::filesystem::perms::owner_read) != std::filesystem::perms::none; + return (perm & fs::perms::owner_read) != fs::perms::none; }else if (getegid() == info.st_gid){ - return (perm & std::filesystem::perms::group_read) != std::filesystem::perms::none; + return (perm & fs::perms::group_read) != fs::perms::none; }else{ - return (perm & std::filesystem::perms::others_read) != std::filesystem::perms::none; + return (perm & fs::perms::others_read) != fs::perms::none; } #else if(geteuid() == info.st_uid){ - return perm & std::filesystem::owner_read; + return perm & fs::owner_read; }else if (getegid() == info.st_gid){ - return perm & std::filesystem::group_read; + return perm & fs::group_read; }else{ - return perm & std::filesystem::others_read; + return perm & fs::others_read; } #endif #endif @@ -716,7 +716,7 @@ bool ofFile::canRead() const { //------------------------------------------------------------------------------------------------------------ bool ofFile::canWrite() const { - auto perm = std::filesystem::status(myFile).permissions(); + auto perm = fs::status(myFile).permissions(); #ifdef TARGET_WIN32 DWORD attr = GetFileAttributes(myFile.native().c_str()); if (attr == INVALID_FILE_ATTRIBUTES){ @@ -729,19 +729,19 @@ bool ofFile::canWrite() const { stat(path().c_str(), &info); // Error check omitted #if OF_USING_STD_FS if(geteuid() == info.st_uid){ - return (perm & std::filesystem::perms::owner_write) != std::filesystem::perms::none; + return (perm & fs::perms::owner_write) != fs::perms::none; }else if (getegid() == info.st_gid){ - return (perm & std::filesystem::perms::group_write) != std::filesystem::perms::none; + return (perm & fs::perms::group_write) != fs::perms::none; }else{ - return (perm & std::filesystem::perms::others_write) != std::filesystem::perms::none; + return (perm & fs::perms::others_write) != fs::perms::none; } #else if(geteuid() == info.st_uid){ - return perm & std::filesystem::owner_write; + return perm & fs::owner_write; }else if (getegid() == info.st_gid){ - return perm & std::filesystem::group_write; + return perm & fs::group_write; }else{ - return perm & std::filesystem::others_write; + return perm & fs::others_write; } #endif #endif @@ -749,7 +749,7 @@ bool ofFile::canWrite() const { //------------------------------------------------------------------------------------------------------------ bool ofFile::canExecute() const { - auto perm = std::filesystem::status(myFile).permissions(); + auto perm = fs::status(myFile).permissions(); #ifdef TARGET_WIN32 return getExtension() == "exe"; #else @@ -757,19 +757,19 @@ bool ofFile::canExecute() const { stat(path().c_str(), &info); // Error check omitted #if OF_USING_STD_FS if(geteuid() == info.st_uid){ - return (perm & std::filesystem::perms::owner_exec) != std::filesystem::perms::none; + return (perm & fs::perms::owner_exec) != fs::perms::none; }else if (getegid() == info.st_gid){ - return (perm & std::filesystem::perms::group_exec) != std::filesystem::perms::none; + return (perm & fs::perms::group_exec) != fs::perms::none; }else{ - return (perm & std::filesystem::perms::others_exec) != std::filesystem::perms::none; + return (perm & fs::perms::others_exec) != fs::perms::none; } #else if(geteuid() == info.st_uid){ - return perm & std::filesystem::owner_exe; + return perm & fs::owner_exe; }else if (getegid() == info.st_gid){ - return perm & std::filesystem::group_exe; + return perm & fs::group_exe; }else{ - return perm & std::filesystem::others_exe; + return perm & fs::others_exe; } #endif #endif @@ -777,17 +777,17 @@ bool ofFile::canExecute() const { //------------------------------------------------------------------------------------------------------------ bool ofFile::isFile() const { - return std::filesystem::is_regular_file(myFile); + return fs::is_regular_file(myFile); } //------------------------------------------------------------------------------------------------------------ bool ofFile::isLink() const { - return std::filesystem::is_symlink(myFile); + return fs::is_symlink(myFile); } //------------------------------------------------------------------------------------------------------------ bool ofFile::isDirectory() const { - return std::filesystem::is_directory(myFile); + return fs::is_directory(myFile); } //------------------------------------------------------------------------------------------------------------ @@ -796,9 +796,9 @@ bool ofFile::isDevice() const { return false; #else #if OF_USING_STD_FS - return std::filesystem::is_block_file(std::filesystem::status(myFile)); + return fs::is_block_file(fs::status(myFile)); #else - return std::filesystem::status(myFile).type() == std::filesystem::block_file; + return fs::status(myFile).type() == fs::block_file; #endif #endif } @@ -817,19 +817,19 @@ void ofFile::setWriteable(bool flag){ try{ #if !OF_USING_STD_FS || (OF_USING_STD_FS && OF_USE_EXPERIMENTAL_FS) if(flag){ - std::filesystem::permissions(myFile,std::filesystem::perms::owner_write | std::filesystem::perms::add_perms); + fs::permissions(myFile,fs::perms::owner_write | fs::perms::add_perms); }else{ - std::filesystem::permissions(myFile,std::filesystem::perms::owner_write | std::filesystem::perms::remove_perms); + fs::permissions(myFile,fs::perms::owner_write | fs::perms::remove_perms); } #else if(flag){ - std::filesystem::permissions(myFile, - std::filesystem::perms::owner_write, - std::filesystem::perm_options::add); + fs::permissions(myFile, + fs::perms::owner_write, + fs::perm_options::add); }else{ - std::filesystem::permissions(myFile, - std::filesystem::perms::owner_write, - std::filesystem::perm_options::remove); + fs::permissions(myFile, + fs::perms::owner_write, + fs::perm_options::remove); } #endif }catch(std::exception & e){ @@ -848,19 +848,19 @@ void ofFile::setReadable(bool flag){ try{ #if !OF_USING_STD_FS || (OF_USING_STD_FS && OF_USE_EXPERIMENTAL_FS) if(flag){ - std::filesystem::permissions(myFile,std::filesystem::perms::owner_read | std::filesystem::perms::add_perms); + fs::permissions(myFile,fs::perms::owner_read | fs::perms::add_perms); }else{ - std::filesystem::permissions(myFile,std::filesystem::perms::owner_read | std::filesystem::perms::remove_perms); + fs::permissions(myFile,fs::perms::owner_read | fs::perms::remove_perms); } #else if(flag){ - std::filesystem::permissions(myFile, - std::filesystem::perms::owner_read, - std::filesystem::perm_options::add); + fs::permissions(myFile, + fs::perms::owner_read, + fs::perm_options::add); }else{ - std::filesystem::permissions(myFile, - std::filesystem::perms::owner_read, - std::filesystem::perm_options::remove); + fs::permissions(myFile, + fs::perms::owner_read, + fs::perm_options::remove); } #endif }catch(std::exception & e){ @@ -874,26 +874,26 @@ void ofFile::setExecutable(bool flag){ #if OF_USING_STD_FS # if OF_USE_EXPERIMENTAL_FS if(flag){ - std::filesystem::permissions(myFile, std::filesystem::perms::owner_exec | std::filesystem::perms::add_perms); + fs::permissions(myFile, fs::perms::owner_exec | fs::perms::add_perms); } else{ - std::filesystem::permissions(myFile, std::filesystem::perms::owner_exec | std::filesystem::perms::remove_perms); + fs::permissions(myFile, fs::perms::owner_exec | fs::perms::remove_perms); } # else if(flag){ - std::filesystem::permissions(myFile, - std::filesystem::perms::owner_exec, - std::filesystem::perm_options::add); + fs::permissions(myFile, + fs::perms::owner_exec, + fs::perm_options::add); } else{ - std::filesystem::permissions(myFile, - std::filesystem::perms::owner_exec, - std::filesystem::perm_options::remove); + fs::permissions(myFile, + fs::perms::owner_exec, + fs::perm_options::remove); } # endif #else if(flag){ - std::filesystem::permissions(myFile, std::filesystem::perms::owner_exe | std::filesystem::perms::add_perms); + fs::permissions(myFile, fs::perms::owner_exe | fs::perms::add_perms); } else{ - std::filesystem::permissions(myFile, std::filesystem::perms::owner_exe | std::filesystem::perms::remove_perms); + fs::permissions(myFile, fs::perms::owner_exe | fs::perms::remove_perms); } #endif }catch(std::exception & e){ @@ -902,7 +902,7 @@ void ofFile::setExecutable(bool flag){ } //------------------------------------------------------------------------------------------------------------ -bool ofFile::copyTo(const std::filesystem::path& _path, bool bRelativeToData, bool overwrite) const{ +bool ofFile::copyTo(const fs::path& _path, bool bRelativeToData, bool overwrite) const{ auto path = _path; if(path.empty()){ @@ -948,7 +948,7 @@ bool ofFile::copyTo(const std::filesystem::path& _path, bool bRelativeToData, bo if(!destDir.exists()){ ofFilePath::createEnclosingDirectory(path, false); } - std::filesystem::copy_file(myFile,path); + fs::copy_file(myFile,path); }catch(std::exception & except){ ofLogError("ofFile") << "copyTo(): unable to copy \"" << path << "\":" << except.what(); return false; @@ -958,7 +958,7 @@ bool ofFile::copyTo(const std::filesystem::path& _path, bool bRelativeToData, bo } //------------------------------------------------------------------------------------------------------------ -bool ofFile::moveTo(const std::filesystem::path& _path, bool bRelativeToData, bool overwrite){ +bool ofFile::moveTo(const fs::path& _path, bool bRelativeToData, bool overwrite){ auto path = _path; if(path.empty()){ @@ -1001,7 +1001,7 @@ bool ofFile::moveTo(const std::filesystem::path& _path, bool bRelativeToData, bo if(!destDir.exists()){ ofFilePath::createEnclosingDirectory(path,false); } - std::filesystem::rename(myFile,path); + fs::rename(myFile,path); myFile = path; if(mode != ofFile::Reference){ changeMode(mode, binary); @@ -1016,7 +1016,7 @@ bool ofFile::moveTo(const std::filesystem::path& _path, bool bRelativeToData, bo } //------------------------------------------------------------------------------------------------------------ -bool ofFile::renameTo(const std::filesystem::path& path, bool bRelativeToData, bool overwrite){ +bool ofFile::renameTo(const fs::path& path, bool bRelativeToData, bool overwrite){ return moveTo(path,bRelativeToData,overwrite); } @@ -1036,9 +1036,9 @@ bool ofFile::remove(bool recursive){ open(path(),Reference,binary); } if(recursive){ - std::filesystem::remove_all(myFile); + fs::remove_all(myFile); }else{ - std::filesystem::remove(myFile); + fs::remove(myFile); } }catch(std::exception & except){ ofLogError("ofFile") << "remove(): unable to remove \"" << myFile << "\": " << except.what(); @@ -1051,7 +1051,7 @@ bool ofFile::remove(bool recursive){ //------------------------------------------------------------------------------------------------------------ uint64_t ofFile::getSize() const { try{ - return std::filesystem::file_size(myFile); + return fs::file_size(myFile); }catch(std::exception & except){ ofLogError("ofFile") << "getSize(): unable to get size of \"" << myFile << "\": " << except.what(); return 0; @@ -1092,7 +1092,7 @@ bool ofFile::operator>=(const ofFile & file) const { // ofFile Static Methods //------------------------------------------------------------------------------------------------------------ -bool ofFile::copyFromTo(const std::filesystem::path& pathSrc, const std::filesystem::path& pathDst, bool bRelativeToData, bool overwrite){ +bool ofFile::copyFromTo(const fs::path& pathSrc, const fs::path& pathDst, bool bRelativeToData, bool overwrite){ ofFile tmp; if( bRelativeToData ){ tmp.open(pathSrc,ofFile::Reference); @@ -1104,7 +1104,7 @@ bool ofFile::copyFromTo(const std::filesystem::path& pathSrc, const std::filesys //be careful with slashes here - appending a slash when moving a folder will causes mad headaches //------------------------------------------------------------------------------------------------------------ -bool ofFile::moveFromTo(const std::filesystem::path& pathSrc, const std::filesystem::path& pathDst, bool bRelativeToData, bool overwrite){ +bool ofFile::moveFromTo(const fs::path& pathSrc, const fs::path& pathDst, bool bRelativeToData, bool overwrite){ ofFile tmp; if( bRelativeToData ){ tmp.open(pathSrc,ofFile::Reference); @@ -1115,7 +1115,7 @@ bool ofFile::moveFromTo(const std::filesystem::path& pathSrc, const std::filesys } //------------------------------------------------------------------------------------------------------------ -bool ofFile::doesFileExist(const std::filesystem::path& _fPath, bool bRelativeToData){ +bool ofFile::doesFileExist(const fs::path& _fPath, bool bRelativeToData){ ofFile tmp; if(bRelativeToData){ tmp.open(_fPath,ofFile::Reference); @@ -1126,7 +1126,7 @@ bool ofFile::doesFileExist(const std::filesystem::path& _fPath, bool bRelativeTo } //------------------------------------------------------------------------------------------------------------ -bool ofFile::removeFile(const std::filesystem::path& _path, bool bRelativeToData){ +bool ofFile::removeFile(const fs::path& _path, bool bRelativeToData){ ofFile tmp; if(bRelativeToData){ tmp.open(_path,ofFile::Reference); @@ -1149,28 +1149,28 @@ ofDirectory::ofDirectory(){ } //------------------------------------------------------------------------------------------------------------ -ofDirectory::ofDirectory(const std::filesystem::path & path){ +ofDirectory::ofDirectory(const fs::path & path){ showHidden = false; open(path); } //------------------------------------------------------------------------------------------------------------ -void ofDirectory::open(const std::filesystem::path & path){ +void ofDirectory::open(const fs::path & path){ originalDirectory = ofFilePath::getPathForDirectory(path.string()); files.clear(); - myDir = std::filesystem::path(ofToDataPath(originalDirectory)); + myDir = fs::path(ofToDataPath(originalDirectory)); } //------------------------------------------------------------------------------------------------------------ -void ofDirectory::openFromCWD(const std::filesystem::path & path){ +void ofDirectory::openFromCWD(const fs::path & path){ originalDirectory = ofFilePath::getPathForDirectory(path.string()); files.clear(); - myDir = std::filesystem::path(originalDirectory); + myDir = fs::path(originalDirectory); } //------------------------------------------------------------------------------------------------------------ void ofDirectory::close(){ - myDir = std::filesystem::path(); + myDir = fs::path(); } //------------------------------------------------------------------------------------------------------------ @@ -1179,9 +1179,9 @@ bool ofDirectory::create(bool recursive){ if(!myDir.string().empty()){ try{ if(recursive){ - std::filesystem::create_directories(myDir); + fs::create_directories(myDir); }else{ - std::filesystem::create_directory(myDir); + fs::create_directory(myDir); } } catch(std::exception & except){ @@ -1195,7 +1195,7 @@ bool ofDirectory::create(bool recursive){ //------------------------------------------------------------------------------------------------------------ bool ofDirectory::exists() const { - return (myDir == "" || std::filesystem::exists(myDir)); + return (myDir == "" || fs::exists(myDir)); } //------------------------------------------------------------------------------------------------------------ @@ -1206,9 +1206,9 @@ string ofDirectory::path() const { //------------------------------------------------------------------------------------------------------------ string ofDirectory::getAbsolutePath() const { try{ - return std::filesystem::canonical(std::filesystem::absolute(myDir)).string(); + return fs::canonical(fs::absolute(myDir)).string(); }catch(...){ - return std::filesystem::absolute(myDir).string(); + return fs::absolute(myDir).string(); } } @@ -1260,22 +1260,22 @@ void ofDirectory::setShowHidden(bool showHidden){ //------------------------------------------------------------------------------------------------------------ bool ofDirectory::isDirectory() const { - return std::filesystem::is_directory(myDir); + return fs::is_directory(myDir); } //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::copyTo(const std::filesystem::path& _path, bool bRelativeToData, bool overwrite){ +bool ofDirectory::copyTo(const fs::path& _path, bool bRelativeToData, bool overwrite){ auto path = _path; if(myDir.string().empty()){ ofLogError("ofDirectory") << "copyTo(): source path is empty"; return false; } - if(!std::filesystem::exists(myDir)){ + if(!fs::exists(myDir)){ ofLogError("ofDirectory") << "copyTo(): source directory does not exist"; return false; } - if(!std::filesystem::is_directory(myDir)){ + if(!fs::is_directory(myDir)){ ofLogError("ofDirectory") << "copyTo(): source path is not a directory"; return false; } @@ -1299,10 +1299,10 @@ bool ofDirectory::copyTo(const std::filesystem::path& _path, bool bRelativeToDat dir.create(true); // Iterate through the source directory - for(std::filesystem::directory_iterator file(myDir); file != std::filesystem::directory_iterator(); ++file){ - auto currentPath = std::filesystem::absolute(file->path()); - auto dst = std::filesystem::path(path) / currentPath.filename(); - if(std::filesystem::is_directory(currentPath)){ + for(fs::directory_iterator file(myDir); file != fs::directory_iterator(); ++file){ + auto currentPath = fs::absolute(file->path()); + auto dst = fs::path(path) / currentPath.filename(); + if(fs::is_directory(currentPath)){ ofDirectory current(currentPath); // Found directory: Recursion if(!current.copyTo(dst.string(),false,overwrite)){ @@ -1319,7 +1319,7 @@ bool ofDirectory::copyTo(const std::filesystem::path& _path, bool bRelativeToDat } //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::moveTo(const std::filesystem::path& path, bool bRelativeToData, bool overwrite){ +bool ofDirectory::moveTo(const fs::path& path, bool bRelativeToData, bool overwrite){ if(copyTo(path,bRelativeToData,overwrite)){ return remove(true); } @@ -1328,21 +1328,21 @@ bool ofDirectory::moveTo(const std::filesystem::path& path, bool bRelativeToData } //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::renameTo(const std::filesystem::path& path, bool bRelativeToData, bool overwrite){ +bool ofDirectory::renameTo(const fs::path& path, bool bRelativeToData, bool overwrite){ return moveTo(path, bRelativeToData, overwrite); } //------------------------------------------------------------------------------------------------------------ bool ofDirectory::remove(bool recursive){ - if(path().empty() || !std::filesystem::exists(myDir)){ + if(path().empty() || !fs::exists(myDir)){ return false; } try{ if(recursive){ - std::filesystem::remove_all(std::filesystem::canonical(myDir)); + fs::remove_all(fs::canonical(myDir)); }else{ - std::filesystem::remove(std::filesystem::canonical(myDir)); + fs::remove(fs::canonical(myDir)); } }catch(std::exception & except){ ofLogError("ofDirectory") << "remove(): unable to remove file/directory: " << except.what(); @@ -1373,14 +1373,14 @@ std::size_t ofDirectory::listDir(){ ofLogError("ofDirectory") << "listDir(): directory path is empty"; return 0; } - if(!std::filesystem::exists(myDir)){ + if(!fs::exists(myDir)){ ofLogError("ofDirectory") << "listDir:() source directory does not exist: \"" << myDir << "\""; return 0; } - std::filesystem::directory_iterator end_iter; - if ( std::filesystem::exists(myDir) && std::filesystem::is_directory(myDir)){ - for( std::filesystem::directory_iterator dir_iter(myDir) ; dir_iter != end_iter ; ++dir_iter){ + fs::directory_iterator end_iter; + if ( fs::exists(myDir) && fs::is_directory(myDir)){ + for( fs::directory_iterator dir_iter(myDir) ; dir_iter != end_iter ; ++dir_iter){ files.emplace_back(dir_iter->path().string(), ofFile::Reference); } }else{ @@ -1468,8 +1468,8 @@ static bool natural(const ofFile& a, const ofFile& b) { //------------------------------------------------------------------------------------------------------------ static bool byDate(const ofFile& a, const ofFile& b) { - auto ta = std::filesystem::last_write_time(a); - auto tb = std::filesystem::last_write_time(b); + auto ta = fs::last_write_time(a); + auto tb = fs::last_write_time(b); return ta < tb; } @@ -1512,7 +1512,7 @@ int ofDirectory::numFiles(){ //------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::removeDirectory(const std::filesystem::path& _path, bool deleteIfNotEmpty, bool bRelativeToData){ +bool ofDirectory::removeDirectory(const fs::path& _path, bool deleteIfNotEmpty, bool bRelativeToData){ auto path = _path; ofFile dirToRemove; @@ -1526,14 +1526,14 @@ bool ofDirectory::removeDirectory(const std::filesystem::path& _path, bool delet } //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::createDirectory(const std::filesystem::path& _dirPath, bool bRelativeToData, bool recursive){ +bool ofDirectory::createDirectory(const fs::path& _dirPath, bool bRelativeToData, bool recursive){ auto dirPath = _dirPath; if(bRelativeToData){ dirPath = ofToDataPath(dirPath); } - // on OSX,std::filesystem::create_directories seems to return false *if* the path has folders that already exist + // on OSX,fs::create_directories seems to return false *if* the path has folders that already exist // and true if it doesn't // so to avoid unnecessary warnings on OSX, we check if it exists here: @@ -1544,9 +1544,9 @@ bool ofDirectory::createDirectory(const std::filesystem::path& _dirPath, bool bR bool success = false; try{ if(!recursive){ - success = std::filesystem::create_directory(dirPath); + success = fs::create_directory(dirPath); }else{ - success = std::filesystem::create_directories(dirPath); + success = fs::create_directories(dirPath); } } catch(std::exception & except){ ofLogError("ofDirectory") << "createDirectory(): couldn't create directory \"" << dirPath << "\": " << except.what(); @@ -1560,13 +1560,13 @@ bool ofDirectory::createDirectory(const std::filesystem::path& _dirPath, bool bR } //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::doesDirectoryExist(const std::filesystem::path& _dirPath, bool bRelativeToData){ +bool ofDirectory::doesDirectoryExist(const fs::path& _dirPath, bool bRelativeToData){ auto dirPath = _dirPath; try { if (bRelativeToData) { dirPath = ofToDataPath(dirPath); } - return std::filesystem::exists(dirPath) && std::filesystem::is_directory(dirPath); + return fs::exists(dirPath) && fs::is_directory(dirPath); } catch (std::exception & except) { ofLogError("ofDirectory") << "doesDirectoryExist(): couldn't find directory \"" << dirPath << "\": " << except.what() << std::endl; @@ -1575,14 +1575,14 @@ bool ofDirectory::doesDirectoryExist(const std::filesystem::path& _dirPath, bool } //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::isDirectoryEmpty(const std::filesystem::path& _dirPath, bool bRelativeToData){ +bool ofDirectory::isDirectoryEmpty(const fs::path& _dirPath, bool bRelativeToData){ auto dirPath = _dirPath; if(bRelativeToData){ dirPath = ofToDataPath(dirPath); } - if(!dirPath.empty() && std::filesystem::exists(dirPath) && std::filesystem::is_directory(dirPath)){ - return std::filesystem::directory_iterator(dirPath) == std::filesystem::directory_iterator(); + if(!dirPath.empty() && fs::exists(dirPath) && fs::is_directory(dirPath)){ + return fs::directory_iterator(dirPath) == fs::directory_iterator(); } return false; } @@ -1646,9 +1646,9 @@ vector::const_reverse_iterator ofDirectory::rend() const{ //------------------------------------------------------------------------------------------------------------ -string ofFilePath::addLeadingSlash(const std::filesystem::path& _path){ +string ofFilePath::addLeadingSlash(const fs::path& _path){ auto path = _path.string(); - auto sep = std::filesystem::path("/").make_preferred(); + auto sep = fs::path("/").make_preferred(); if(!path.empty()){ if(ofToString(path[0]) != sep.string()){ path = (sep / path).string(); @@ -1658,13 +1658,13 @@ string ofFilePath::addLeadingSlash(const std::filesystem::path& _path){ } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::addTrailingSlash(const std::filesystem::path& _path){ +string ofFilePath::addTrailingSlash(const fs::path& _path){ #if OF_USING_STD_FS && !OF_USE_EXPERIMENTAL_FS if(_path.string().empty()) return ""; - return (std::filesystem::path(_path).make_preferred() / "").string(); + return (fs::path(_path).make_preferred() / "").string(); #else - auto path = std::filesystem::path(_path).make_preferred().string(); - auto sep = std::filesystem::path("/").make_preferred(); + auto path = fs::path(_path).make_preferred().string(); + auto sep = fs::path("/").make_preferred(); if(!path.empty()){ if(ofToString(path.back()) != sep.string()){ path = (path / sep).string(); @@ -1676,18 +1676,18 @@ string ofFilePath::addTrailingSlash(const std::filesystem::path& _path){ //------------------------------------------------------------------------------------------------------------ -string ofFilePath::getFileExt(const std::filesystem::path& filename){ +string ofFilePath::getFileExt(const fs::path& filename){ return ofFile(filename,ofFile::Reference).getExtension(); } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::removeExt(const std::filesystem::path& filename){ +string ofFilePath::removeExt(const fs::path& filename){ return ofFilePath::join(getEnclosingDirectory(filename,false), ofFile(filename,ofFile::Reference).getBaseName()); } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::getPathForDirectory(const std::filesystem::path& path){ +string ofFilePath::getPathForDirectory(const fs::path& path){ // if a trailing slash is missing from a path, this will clean it up // if it's a windows-style "\" path it will add a "\" // if it's a unix-style "/" path it will add a "/" @@ -1695,7 +1695,7 @@ string ofFilePath::getPathForDirectory(const std::filesystem::path& path){ if(path.string().empty()) return ""; return (path / "").string(); #else - auto sep = std::filesystem::path("/").make_preferred(); + auto sep = fs::path("/").make_preferred(); if(!path.empty() && ofToString(path.string().back())!=sep.string()){ return (path / sep).string(); }else{ @@ -1705,7 +1705,7 @@ string ofFilePath::getPathForDirectory(const std::filesystem::path& path){ } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::removeTrailingSlash(const std::filesystem::path& _path){ +string ofFilePath::removeTrailingSlash(const fs::path& _path){ auto path = _path.string(); if(path.length() > 0 && (path[path.length() - 1] == '/' || path[path.length() - 1] == '\\')){ path = path.substr(0, path.length() - 1); @@ -1715,62 +1715,62 @@ string ofFilePath::removeTrailingSlash(const std::filesystem::path& _path){ //------------------------------------------------------------------------------------------------------------ -string ofFilePath::getFileName(const std::filesystem::path& _filePath, bool bRelativeToData){ +string ofFilePath::getFileName(const fs::path& _filePath, bool bRelativeToData){ std::string filePath = _filePath.string(); if(bRelativeToData){ filePath = ofToDataPath(_filePath); } - return std::filesystem::path(filePath).filename().string(); + return fs::path(filePath).filename().string(); } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::getBaseName(const std::filesystem::path& filePath){ +string ofFilePath::getBaseName(const fs::path& filePath){ return ofFile(filePath,ofFile::Reference).getBaseName(); } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::getEnclosingDirectory(const std::filesystem::path& _filePath, bool bRelativeToData){ +string ofFilePath::getEnclosingDirectory(const fs::path& _filePath, bool bRelativeToData){ std::string filePath = _filePath.string(); if(bRelativeToData){ filePath = ofToDataPath(filePath); } - return addTrailingSlash(std::filesystem::path(filePath).parent_path().string()); + return addTrailingSlash(fs::path(filePath).parent_path().string()); } //------------------------------------------------------------------------------------------------------------ -bool ofFilePath::createEnclosingDirectory(const std::filesystem::path& filePath, bool bRelativeToData, bool bRecursive) { +bool ofFilePath::createEnclosingDirectory(const fs::path& filePath, bool bRelativeToData, bool bRecursive) { return ofDirectory::createDirectory(ofFilePath::getEnclosingDirectory(filePath,bRelativeToData), bRelativeToData, bRecursive); } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::getAbsolutePath(const std::filesystem::path& path, bool bRelativeToData){ +string ofFilePath::getAbsolutePath(const fs::path& path, bool bRelativeToData){ if(bRelativeToData){ return ofToDataPath(path, true); }else{ try{ - return std::filesystem::canonical(std::filesystem::absolute(path)).string(); + return fs::canonical(fs::absolute(path)).string(); }catch(...){ - return std::filesystem::absolute(path).string(); + return fs::absolute(path).string(); } } } //------------------------------------------------------------------------------------------------------------ -bool ofFilePath::isAbsolute(const std::filesystem::path& path){ - return std::filesystem::path(path).is_absolute(); +bool ofFilePath::isAbsolute(const fs::path& path){ + return fs::path(path).is_absolute(); } //------------------------------------------------------------------------------------------------------------ string ofFilePath::getCurrentWorkingDirectory(){ - return std::filesystem::current_path().string(); + return fs::current_path().string(); } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::join(const std::filesystem::path& path1, const std::filesystem::path& path2){ - return (std::filesystem::path(path1) / std::filesystem::path(path2)).string(); +string ofFilePath::join(const fs::path& path1, const fs::path& path2){ + return (fs::path(path1) / fs::path(path2)).string(); } //------------------------------------------------------------------------------------------------------------ @@ -1824,15 +1824,15 @@ string ofFilePath::getUserHomeDir(){ #endif } -string ofFilePath::makeRelative(const std::filesystem::path & from, const std::filesystem::path & to){ - auto pathFrom = std::filesystem::absolute( from ); - auto pathTo = std::filesystem::absolute( to ); - std::filesystem::path ret; - std::filesystem::path::const_iterator itrFrom( pathFrom.begin() ), itrTo( pathTo.begin() ); +string ofFilePath::makeRelative(const fs::path & from, const fs::path & to){ + auto pathFrom = fs::absolute( from ); + auto pathTo = fs::absolute( to ); + fs::path ret; + fs::path::const_iterator itrFrom( pathFrom.begin() ), itrTo( pathTo.begin() ); // Find common base - for( std::filesystem::path::const_iterator toEnd( pathTo.end() ), fromEnd( pathFrom.end() ) ; itrFrom != fromEnd && itrTo != toEnd && *itrFrom == *itrTo; ++itrFrom, ++itrTo ); + for( fs::path::const_iterator toEnd( pathTo.end() ), fromEnd( pathFrom.end() ) ; itrFrom != fromEnd && itrTo != toEnd && *itrFrom == *itrTo; ++itrFrom, ++itrTo ); // Navigate backwards in directory to reach previously found base - for( std::filesystem::path::const_iterator fromEnd( pathFrom.end() ); itrFrom != fromEnd; ++itrFrom ){ + for( fs::path::const_iterator fromEnd( pathFrom.end() ); itrFrom != fromEnd; ++itrFrom ){ if( (*itrFrom) != "." ){ ret /= ".."; } @@ -1860,7 +1860,7 @@ void ofDisableDataPath(){ //-------------------------------------------------- bool ofRestoreWorkingDirectoryToDefault(){ try{ - std::filesystem::current_path(defaultWorkingDirectory()); + fs::current_path(defaultWorkingDirectory()); return true; }catch(...){ return false; @@ -1868,12 +1868,12 @@ bool ofRestoreWorkingDirectoryToDefault(){ } //-------------------------------------------------- -void ofSetDataPathRoot(const std::filesystem::path& newRoot){ +void ofSetDataPathRoot(const fs::path& newRoot){ dataPathRoot() = newRoot; } //-------------------------------------------------- -string ofToDataPath(const std::filesystem::path & path, bool makeAbsolute){ +string ofToDataPath(const fs::path & path, bool makeAbsolute){ if (makeAbsolute && path.is_absolute()) { return path.string(); } @@ -1886,7 +1886,7 @@ string ofToDataPath(const std::filesystem::path & path, bool makeAbsolute){ // if our Current Working Directory has changed (e.g. file open dialog) #ifdef TARGET_WIN32 - if (defaultWorkingDirectory() != std::filesystem::current_path()) { + if (defaultWorkingDirectory() != fs::current_path()) { // change our cwd back to where it was on app load bool ret = ofRestoreWorkingDirectoryToDefault(); if(!ret){ @@ -1897,14 +1897,14 @@ string ofToDataPath(const std::filesystem::path & path, bool makeAbsolute){ // this could be performed here, or wherever we might think we accidentally change the cwd, e.g. after file dialogs on windows const auto & dataPath = dataPathRoot(); - std::filesystem::path inputPath(path); - std::filesystem::path outputPath; + fs::path inputPath(path); + fs::path outputPath; // if path is already absolute, just return it if (inputPath.is_absolute()) { try { - auto outpath = std::filesystem::canonical(inputPath).make_preferred(); - if(std::filesystem::is_directory(outpath) && hasTrailingSlash){ + auto outpath = fs::canonical(inputPath).make_preferred(); + if(fs::is_directory(outpath) && hasTrailingSlash){ return ofFilePath::addTrailingSlash(outpath.string()); }else{ return outpath.string(); @@ -1922,7 +1922,7 @@ string ofToDataPath(const std::filesystem::path & path, bool makeAbsolute){ // also, we strip the trailing slash from dataPath since `path` may be input as a file formatted path even if it is a folder (i.e. missing trailing slash) dirDataPath = ofFilePath::addTrailingSlash(dirDataPath); - auto relativeDirDataPath = ofFilePath::makeRelative(std::filesystem::current_path().string(),dataPath.string()); + auto relativeDirDataPath = ofFilePath::makeRelative(fs::current_path().string(),dataPath.string()); relativeDirDataPath = ofFilePath::addTrailingSlash(relativeDirDataPath); if (inputPath.string().find(dirDataPath) != 0 && inputPath.string().find(relativeDirDataPath)!=0) { @@ -1941,15 +1941,15 @@ string ofToDataPath(const std::filesystem::path & path, bool makeAbsolute){ if(makeAbsolute){ // then we return the absolute form of the path try { - auto outpath = std::filesystem::canonical(std::filesystem::absolute(outputPath)).make_preferred(); - if(std::filesystem::is_directory(outpath) && hasTrailingSlash){ + auto outpath = fs::canonical(fs::absolute(outputPath)).make_preferred(); + if(fs::is_directory(outpath) && hasTrailingSlash){ return ofFilePath::addTrailingSlash(outpath.string()); }else{ return outpath.string(); } } catch (std::exception &) { - return std::filesystem::absolute(outputPath).string(); + return fs::absolute(outputPath).string(); } }else{ // or output the relative path diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index 027f79fe7dc..e61208946e8 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -256,7 +256,7 @@ class ofBuffer{ /// \param path file to open /// \param binary set to false if you are reading a text file & want lines /// split at endline characters automatically -ofBuffer ofBufferFromFile(const std::filesystem::path & path, bool binary=true); +ofBuffer ofBufferFromFile(const fs::path & path, bool binary=true); //-------------------------------------------------- /// Write the contents of a buffer to a file at path. @@ -267,7 +267,7 @@ ofBuffer ofBufferFromFile(const std::filesystem::path & path, bool binary=true); /// \param buffer data source to write from /// \param binary set to false if you are writing a text file & want lines /// split at endline characters automatically -bool ofBufferToFile(const std::filesystem::path & path, const ofBuffer& buffer, bool binary=true); +bool ofBufferToFile(const fs::path & path, const ofBuffer& buffer, bool binary=true); //-------------------------------------------------- /// \class ofFilePath @@ -281,32 +281,32 @@ class ofFilePath{ /// /// \param filename file path /// \returns filename extension only - static std::string getFileExt(const std::filesystem::path& filename); + static std::string getFileExt(const fs::path& filename); /// Remove extension from a filename, ie. "duck.jpg" ->"duck". /// /// \param filename file path /// \returns filename without extension - static std::string removeExt(const std::filesystem::path& filename); + static std::string removeExt(const fs::path& filename); /// Prepend path with a slash, ie. "images" -> "/images". /// /// \param path file or directory path /// \returns slah + path - static std::string addLeadingSlash(const std::filesystem::path& path); + static std::string addLeadingSlash(const fs::path& path); /// Append path with a slash, ie. "images" -> "images/". /// /// \param path directory path /// \returns path + slash - static std::string addTrailingSlash(const std::filesystem::path& path); + static std::string addTrailingSlash(const fs::path& path); /// Remove a path's trailing slash (if found), /// ie. "images/" -> "images". /// /// \param path directory path /// \returns path minus trailing slash - static std::string removeTrailingSlash(const std::filesystem::path& path); + static std::string removeTrailingSlash(const fs::path& path); /// Cleaned up a directory path by adding a trailing slash if needed. /// @@ -315,7 +315,7 @@ class ofFilePath{ /// /// \param path directory path /// \returns cleaned path + trailing slash (if needed) - static std::string getPathForDirectory(const std::filesystem::path& path); + static std::string getPathForDirectory(const fs::path& path); /// Get the absolute, full path for a given path, /// ie. "images" -> "/Users/mickey/of/apps/myApps/Donald/bin/data/images". @@ -325,7 +325,7 @@ class ofFilePath{ /// are *not* in the data folder and want the direct path without relative /// "../../" /// \returns absolute path - static std::string getAbsolutePath(const std::filesystem::path& path, bool bRelativeToData = true); + static std::string getAbsolutePath(const fs::path& path, bool bRelativeToData = true); /// Check if a path is an absolute (aka a full path), /// ie. "images" -> false, @@ -333,7 +333,7 @@ class ofFilePath{ /// /// \param path file or directory path /// \returns true if the path is an absolute path - static bool isAbsolute(const std::filesystem::path& path); + static bool isAbsolute(const fs::path& path); /// Get the filename of a given path by stripping the parent /// directories ie. "images/duck.jpg" -> "duck.jpg", assumes the path is in @@ -344,7 +344,7 @@ class ofFilePath{ /// are *not* in the data folder and want the direct path without relative /// "../../" /// \returns filename - static std::string getFileName(const std::filesystem::path& filePath, bool bRelativeToData = true); + static std::string getFileName(const fs::path& filePath, bool bRelativeToData = true); /// Get a file name without its extension, /// ie. "images/duck.jpg" -> "duck" and @@ -352,7 +352,7 @@ class ofFilePath{ /// /// \param filePath file path /// \returns basename - static std::string getBaseName(const std::filesystem::path& filePath); + static std::string getBaseName(const fs::path& filePath); /// Get the enclosing parent directory of a path, /// ie. "images/duck.jpg" -> "images", assumes the path is in the data @@ -363,7 +363,7 @@ class ofFilePath{ /// are *not* in the data folder and want the direct path without relative /// "../../" ///\returns enclosing directory - static std::string getEnclosingDirectory(const std::filesystem::path& filePath, bool bRelativeToData = true); + static std::string getEnclosingDirectory(const fs::path& filePath, bool bRelativeToData = true); /// Create the enclosing parent directory of a path, ie. /// "images" is the enclosing directory of "duck.jpg" = "images/duck.jpg". @@ -377,7 +377,7 @@ class ofFilePath{ /// are *not* in the data folder and want the direct path without relative /// "../../" /// \returns true if the enclosing directory was created - static bool createEnclosingDirectory(const std::filesystem::path& filePath, bool bRelativeToData = true, bool bRecursive = true); + static bool createEnclosingDirectory(const fs::path& filePath, bool bRelativeToData = true, bool bRecursive = true); /// Get the full path to the app's current working directory. /// @@ -395,7 +395,7 @@ class ofFilePath{ /// \param path1 left half of the path to join /// \param path2 right half of the path to join /// \returns joined path - static std::string join(const std::filesystem::path& path1, const std::filesystem::path& path2); + static std::string join(const fs::path& path1, const fs::path& path2); /// Get the full path to the application's executable file. /// @@ -430,7 +430,7 @@ class ofFilePath{ /// \param from starting path /// \param to destination path /// \returns relative path - static std::string makeRelative(const std::filesystem::path & from, const std::filesystem::path & to); + static std::string makeRelative(const fs::path & from, const fs::path & to); }; /// \class ofFile @@ -468,7 +468,7 @@ class ofFile: public std::fstream{ /// (read only, read write, etc) /// \param binary set to false if you are working with a text file & want /// lines split at endline characters automatically - ofFile(const std::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); + ofFile(const fs::path & path, Mode mode=ReadOnly, bool binary=true); /// Create a new file path using the same path & settings of another /// file. @@ -493,7 +493,7 @@ class ofFile: public std::fstream{ /// \param binary set to false if you are reading a text file & want lines /// split at endline characters automatically /// \returns true if the path was opened - bool open(const std::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); + bool open(const fs::path & path, Mode mode=ReadOnly, bool binary=true); /// Open the path as a file. /// @@ -505,7 +505,7 @@ class ofFile: public std::fstream{ /// \param binary set to false if you are reading a text file & want lines /// split at endline characters automatically /// \returns true if the path was opened - bool openFromCWD(const std::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); + bool openFromCWD(const fs::path & path, Mode mode=ReadOnly, bool binary=true); /// Reopen the current file path with a different access mode. /// @@ -532,7 +532,7 @@ class ofFile: public std::fstream{ /// /// \param path file path /// \returns true if the file was created - bool create(const std::filesystem::path & path); + bool create(const fs::path & path); /// Check if a file exists at the current path. /// @@ -646,7 +646,7 @@ class ofFile: public std::fstream{ /// \param overwrite set to true if you want to overwrite the file or /// directory at the new path /// \returns true if the copy was successful - bool copyTo(const std::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false) const; + bool copyTo(const fs::path& path, bool bRelativeToData = true, bool overwrite = false) const; /// Move the current file or directory path to a new path. /// @@ -660,7 +660,7 @@ class ofFile: public std::fstream{ /// \param overwrite set to true if you want to overwrite the file or /// directory at the new path /// \returns true if the copy was successful - bool moveTo(const std::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false); + bool moveTo(const fs::path& path, bool bRelativeToData = true, bool overwrite = false); /// Rename the current file or directory path to a new path. /// @@ -674,7 +674,7 @@ class ofFile: public std::fstream{ /// \param overwrite set to true if you want to overwrite the file or /// directory at the new path /// \returns true if the copy was successful - bool renameTo(const std::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false); + bool renameTo(const fs::path& path, bool bRelativeToData = true, bool overwrite = false); /// Removes the file or directory at the current path. /// @@ -728,11 +728,11 @@ class ofFile: public std::fstream{ /// \return output stream std::filebuf * getFileBuffer() const; - operator std::filesystem::path(){ + operator fs::path(){ return myFile; } - operator const std::filesystem::path() const{ + operator const fs::path() const{ return myFile; } @@ -752,7 +752,7 @@ class ofFile: public std::fstream{ /// \param overwrite set to true if you want to overwrite the file or /// directory at the new path /// \returns true if the copy was successful - static bool copyFromTo(const std::filesystem::path& pathSrc, const std::filesystem::path& pathDst, bool bRelativeToData = true, bool overwrite = false); + static bool copyFromTo(const fs::path& pathSrc, const fs::path& pathDst, bool bRelativeToData = true, bool overwrite = false); /// Move source path to destination path. /// @@ -768,7 +768,7 @@ class ofFile: public std::fstream{ /// \warning be careful with slashes here, appending a slash when moving a /// folder may cause mad headaches in OSX /// \returns true if the move was successful - static bool moveFromTo(const std::filesystem::path& pathSrc, const std::filesystem::path& pathDst, bool bRelativeToData = true, bool overwrite = false); + static bool moveFromTo(const fs::path& pathSrc, const fs::path& pathDst, bool bRelativeToData = true, bool overwrite = false); /// Check if a file or directory exists at a given path. /// @@ -777,7 +777,7 @@ class ofFile: public std::fstream{ /// are *not* in the data folder and want the direct path without relative /// "../../" /// \returns true if a file or directory exists - static bool doesFileExist(const std::filesystem::path& fPath, bool bRelativeToData = true); + static bool doesFileExist(const fs::path& fPath, bool bRelativeToData = true); /// Remove a file or directory at a given path. /// @@ -785,13 +785,13 @@ class ofFile: public std::fstream{ /// are *not* in the data folder and want the direct path without relative /// "../../" /// \returns true if the path was removed successfully - static bool removeFile(const std::filesystem::path& path, bool bRelativeToData = true); + static bool removeFile(const fs::path& path, bool bRelativeToData = true); private: bool isWriteMode(); bool openStream(Mode _mode, bool binary); void copyFrom(const ofFile & mom); - std::filesystem::path myFile; + fs::path myFile; Mode mode; bool binary; }; @@ -814,17 +814,17 @@ class ofDirectory{ /// Create an ofDirectory instance and attempt to open the path. /// /// \param path directory path - ofDirectory(const std::filesystem::path & path); + ofDirectory(const fs::path & path); /// Open a directory path, clears the current file list. /// /// \param path directory path - void open(const std::filesystem::path & path); + void open(const fs::path & path); /// Open a directory path relative to the current working directory without calling ofToDataPath internally, clears the current file list. /// /// \param path directory path - void openFromCWD(const std::filesystem::path & path); + void openFromCWD(const fs::path & path); /// Close the currently open path. void close(); @@ -916,7 +916,7 @@ class ofDirectory{ /// \param overwrite set to true if you want to overwrite the file or /// directory at the new path /// \returns true if the copy was successful - bool copyTo(const std::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false); + bool copyTo(const fs::path& path, bool bRelativeToData = true, bool overwrite = false); /// Move the current file or directory path to a new path. /// @@ -930,7 +930,7 @@ class ofDirectory{ /// \param overwrite set to true if you want to overwrite the file or /// directory at the new path /// \returns true if the copy was successful - bool moveTo(const std::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false); + bool moveTo(const fs::path& path, bool bRelativeToData = true, bool overwrite = false); /// Rename the current file or directory path to a new path. /// @@ -944,7 +944,7 @@ class ofDirectory{ /// \param overwrite set to true if you want to overwrite the file or /// directory at the new path /// \returns true if the copy was successful - bool renameTo(const std::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false); + bool renameTo(const fs::path& path, bool bRelativeToData = true, bool overwrite = false); /// Removes the file or directory at the current path. /// @@ -1094,11 +1094,11 @@ class ofDirectory{ bool operator>(const ofDirectory & dir) const; bool operator>=(const ofDirectory & dir) const; - operator std::filesystem::path(){ + operator fs::path(){ return myDir; } - operator const std::filesystem::path() const{ + operator const fs::path() const{ return myDir; } @@ -1116,7 +1116,7 @@ class ofDirectory{ /// \param bRecursive set to true to automatically create nested directories /// as required /// \returns true if directory was created successfully - static bool createDirectory(const std::filesystem::path& dirPath, bool bRelativeToData = true, bool recursive = false); + static bool createDirectory(const fs::path& dirPath, bool bRelativeToData = true, bool recursive = false); /// Check if a directory at a given path is empty. /// @@ -1127,7 +1127,7 @@ class ofDirectory{ /// are *not* in the data directory /// \returns true if the directory is empty aka contains no files or /// directories - static bool isDirectoryEmpty(const std::filesystem::path& dirPath, bool bRelativeToData = true ); + static bool isDirectoryEmpty(const fs::path& dirPath, bool bRelativeToData = true ); /// Check if a directory exists at a given path. /// @@ -1137,7 +1137,7 @@ class ofDirectory{ /// \param bRelativeToData set to false if you are working with paths that /// are *not* in the data directory /// \returns true if the directory exists - static bool doesDirectoryExist(const std::filesystem::path& dirPath, bool bRelativeToData = true); + static bool doesDirectoryExist(const fs::path& dirPath, bool bRelativeToData = true); /// remove a directory at a given path @@ -1147,7 +1147,7 @@ class ofDirectory{ /// \param bRelativeToData set to false if you are working with paths that /// are *not* in the data directory /// \returns true if the path was removed successfully - static bool removeDirectory(const std::filesystem::path& path, bool deleteIfNotEmpty, bool bRelativeToData = true); + static bool removeDirectory(const fs::path& path, bool deleteIfNotEmpty, bool bRelativeToData = true); std::vector::const_iterator begin() const; std::vector::const_iterator end() const; @@ -1155,7 +1155,7 @@ class ofDirectory{ std::vector::const_reverse_iterator rend() const; private: - std::filesystem::path myDir; + fs::path myDir; std::string originalDirectory; std::vector extensions; std::vector files; @@ -1187,7 +1187,7 @@ void ofDisableDataPath(); /// \param path The path to make relative to the data/ folder. /// \param absolute Set to true to return an absolute path. /// \returns the new path, unless paths were disabled with ofDisableDataPath(). -std::string ofToDataPath(const std::filesystem::path & path, bool absolute=false); +std::string ofToDataPath(const fs::path & path, bool absolute=false); /// \brief Reset the working directory to the platform default. /// @@ -1206,7 +1206,7 @@ bool ofRestoreWorkingDirectoryToDefault(); /// /// \warning The provided path must have a trailing slash (/). /// \param root The path to the data/ folder relative to the app executable. -void ofSetDataPathRoot(const std::filesystem::path& root); +void ofSetDataPathRoot(const fs::path& root); /*! \cond PRIVATE */ namespace of{ diff --git a/libs/openFrameworks/utils/ofJson.h b/libs/openFrameworks/utils/ofJson.h index b0edf2099ac..0c974909068 100644 --- a/libs/openFrameworks/utils/ofJson.h +++ b/libs/openFrameworks/utils/ofJson.h @@ -14,7 +14,7 @@ using ofJson = nlohmann::json; /// \brief Load Json from the given path. /// \param filename The file to load from. /// \returns loaded json, or an empty json object on failure. -inline ofJson ofLoadJson(const std::filesystem::path& filename){ +inline ofJson ofLoadJson(const fs::path& filename){ ofJson json; ofFile jsonFile(filename); if(jsonFile.exists()){ @@ -35,7 +35,7 @@ inline ofJson ofLoadJson(const std::filesystem::path& filename){ /// \param filename The destination path. /// \param json The Json to save. /// \returns true if the json was saved successfully. -inline bool ofSaveJson(const std::filesystem::path& filename, const ofJson & json){ +inline bool ofSaveJson(const fs::path& filename, const ofJson & json){ ofFile jsonFile(filename, ofFile::WriteOnly); try{ jsonFile << json; @@ -53,7 +53,7 @@ inline bool ofSaveJson(const std::filesystem::path& filename, const ofJson & jso /// \param filename The destination path. /// \param json The Json to save. /// \returns true if the json was saved successfully. -inline bool ofSavePrettyJson(const std::filesystem::path& filename, const ofJson & json){ +inline bool ofSavePrettyJson(const fs::path& filename, const ofJson & json){ ofFile jsonFile(filename, ofFile::WriteOnly); try{ jsonFile << json.dump(4); diff --git a/libs/openFrameworks/utils/ofLog.cpp b/libs/openFrameworks/utils/ofLog.cpp index 843b85edbb8..76ad506b472 100644 --- a/libs/openFrameworks/utils/ofLog.cpp +++ b/libs/openFrameworks/utils/ofLog.cpp @@ -62,7 +62,7 @@ ofLogLevel ofGetLogLevel(string module){ } //-------------------------------------------------- -void ofLogToFile(const std::filesystem::path & path, bool append){ +void ofLogToFile(const fs::path & path, bool append){ ofLog::setChannel(std::make_shared(path,append)); } @@ -359,7 +359,7 @@ void ofDebugViewLoggerChannel::log(ofLogLevel level, const string & module, cons ofFileLoggerChannel::ofFileLoggerChannel(){ } -ofFileLoggerChannel::ofFileLoggerChannel(const std::filesystem::path & path, bool append){ +ofFileLoggerChannel::ofFileLoggerChannel(const fs::path & path, bool append){ setFile(path,append); } @@ -371,7 +371,7 @@ void ofFileLoggerChannel::close(){ file.close(); } -void ofFileLoggerChannel::setFile(const std::filesystem::path & path,bool append){ +void ofFileLoggerChannel::setFile(const fs::path & path,bool append){ file.open(path,append?ofFile::Append:ofFile::WriteOnly); file << std::endl; file << std::endl; diff --git a/libs/openFrameworks/utils/ofLog.h b/libs/openFrameworks/utils/ofLog.h index 1ad4973203c..c7b100aec23 100644 --- a/libs/openFrameworks/utils/ofLog.h +++ b/libs/openFrameworks/utils/ofLog.h @@ -235,7 +235,7 @@ class ofBaseLoggerChannel; /// \brief Set the logging to output to a file instead of the console. /// \param path The path to the log file to use. /// \param append True if you want to append to the existing file. -void ofLogToFile(const std::filesystem::path & path, bool append=false); +void ofLogToFile(const fs::path & path, bool append=false); /// \brief Set the logging to ouptut to the console. /// @@ -698,7 +698,7 @@ class ofFileLoggerChannel: public ofBaseLoggerChannel{ /// \brief Create an ofFileLoggerChannel with parameters. /// \param path The file path for the log file. /// \param append True if the log data should be added to an existing file. - ofFileLoggerChannel(const std::filesystem::path & path, bool append); + ofFileLoggerChannel(const fs::path & path, bool append); /// \brief Destroy the file logger channel. virtual ~ofFileLoggerChannel(); @@ -706,7 +706,7 @@ class ofFileLoggerChannel: public ofBaseLoggerChannel{ /// \brief Set the log file. /// \param path The file path for the log file. /// \param append True if the log data should be added to an existing file. - void setFile(const std::filesystem::path & path,bool append=false); + void setFile(const fs::path & path,bool append=false); void log(ofLogLevel level, const std::string & module, const std::string & message); void log(ofLogLevel level, const std::string & module, const char* format, ...) OF_PRINTF_ATTR(4, 5); diff --git a/libs/openFrameworks/utils/ofURLFileLoader.cpp b/libs/openFrameworks/utils/ofURLFileLoader.cpp index f79c315518a..a05c5eb8f9c 100644 --- a/libs/openFrameworks/utils/ofURLFileLoader.cpp +++ b/libs/openFrameworks/utils/ofURLFileLoader.cpp @@ -31,8 +31,8 @@ class ofURLFileLoaderImpl: public ofThread, public ofBaseURLFileLoader{ ~ofURLFileLoaderImpl(); ofHttpResponse get(const string& url); int getAsync(const string& url, const string& name=""); // returns id - ofHttpResponse saveTo(const string& url, const std::filesystem::path& path); - int saveAsync(const string& url, const std::filesystem::path& path); + ofHttpResponse saveTo(const string& url, const fs::path& path); + int saveAsync(const string& url, const fs::path& path); void remove(int id); void clear(); void stop(); @@ -79,12 +79,12 @@ int ofURLFileLoaderImpl::getAsync(const string& url, const string& name){ } -ofHttpResponse ofURLFileLoaderImpl::saveTo(const string& url, const std::filesystem::path& path){ +ofHttpResponse ofURLFileLoaderImpl::saveTo(const string& url, const fs::path& path){ ofHttpRequest request(url,path.string(),true); return handleRequest(request); } -int ofURLFileLoaderImpl::saveAsync(const string& url, const std::filesystem::path& path){ +int ofURLFileLoaderImpl::saveAsync(const string& url, const fs::path& path){ ofHttpRequest request(url,path.string(),true); requests.send(request); start(); @@ -293,11 +293,11 @@ int ofURLFileLoader::getAsync(const string& url, const string& name){ return impl->getAsync(url,name); } -ofHttpResponse ofURLFileLoader::saveTo(const string& url, const std::filesystem::path & path){ +ofHttpResponse ofURLFileLoader::saveTo(const string& url, const fs::path & path){ return impl->saveTo(url,path); } -int ofURLFileLoader::saveAsync(const string& url, const std::filesystem::path & path){ +int ofURLFileLoader::saveAsync(const string& url, const fs::path & path){ return impl->saveAsync(url,path); } @@ -388,11 +388,11 @@ int ofLoadURLAsync(const string& url, const string& name){ return getFileLoader().getAsync(url,name); } -ofHttpResponse ofSaveURLTo(const string& url, const std::filesystem::path& path){ +ofHttpResponse ofSaveURLTo(const string& url, const fs::path& path){ return getFileLoader().saveTo(url,path); } -int ofSaveURLAsync(const string& url, const std::filesystem::path& path){ +int ofSaveURLAsync(const string& url, const fs::path& path){ return getFileLoader().saveAsync(url,path); } diff --git a/libs/openFrameworks/utils/ofURLFileLoader.h b/libs/openFrameworks/utils/ofURLFileLoader.h index 10ee0af25d9..6d58167a3f7 100644 --- a/libs/openFrameworks/utils/ofURLFileLoader.h +++ b/libs/openFrameworks/utils/ofURLFileLoader.h @@ -71,7 +71,7 @@ int ofLoadURLAsync(const std::string& url, const std::string& name=""); // retur /// \param url HTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg" /// \param path file path to save to /// \return HTTP response on success or failure -ofHttpResponse ofSaveURLTo(const std::string& url, const std::filesystem::path& path); +ofHttpResponse ofSaveURLTo(const std::string& url, const fs::path& path); /// make an asynchronous HTTP request for a url and save the response to a file at path /// \returns unique request id for the active HTTP request @@ -81,7 +81,7 @@ ofHttpResponse ofSaveURLTo(const std::string& url, const std::filesystem::path& /// \param url HTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg" /// \param path file path to save to /// \returns unique id for the active HTTP request -int ofSaveURLAsync(const std::string& url, const std::filesystem::path& path); +int ofSaveURLAsync(const std::string& url, const fs::path& path); /// \brief remove an active HTTP request from the queue /// \param id HTTP request id @@ -132,14 +132,14 @@ class ofURLFileLoader { /// \param url HTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg" /// \param path file path to save to /// \return HTTP response on success or failure - ofHttpResponse saveTo(const std::string& url, const std::filesystem::path& path); + ofHttpResponse saveTo(const std::string& url, const fs::path& path); /// \brief make an asynchronous HTTP request and save the response data to a file /// will not block, placed in a queue and run using a background thread /// \param url HTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg" /// \param path file path to save to /// \returns unique id for the active HTTP request - int saveAsync(const std::string& url, const std::filesystem::path& path); + int saveAsync(const std::string& url, const fs::path& path); /// \brief remove an active HTTP request from the queue /// \param id HTTP request id @@ -191,14 +191,14 @@ class ofBaseURLFileLoader{ /// \param url HTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg" /// \param path file path to save to /// \return HTTP response on success or failure - virtual ofHttpResponse saveTo(const std::string& url, const std::filesystem::path& path)=0; + virtual ofHttpResponse saveTo(const std::string& url, const fs::path& path)=0; /// \brief make an asynchronous HTTP request and save the response data to a file /// will not block, placed in a queue and run using a background thread /// \param url HTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg" /// \param path file path to save to /// \returns unique id for the active HTTP request - virtual int saveAsync(const std::string& url, const std::filesystem::path& path)=0; + virtual int saveAsync(const std::string& url, const fs::path& path)=0; /// \brief remove an active HTTP request from the queue /// \param unique HTTP request id diff --git a/libs/openFrameworks/utils/ofXml.cpp b/libs/openFrameworks/utils/ofXml.cpp index 223f9dadab8..b48a009b487 100644 --- a/libs/openFrameworks/utils/ofXml.cpp +++ b/libs/openFrameworks/utils/ofXml.cpp @@ -15,7 +15,7 @@ ofXml::ofXml(std::shared_ptr doc, const pugi::xml_node & xml } -bool ofXml::load(const std::filesystem::path & file){ +bool ofXml::load(const fs::path & file){ auto auxDoc = std::make_shared(); auto res = auxDoc->load_file(ofToDataPath(file).c_str()); if( res ){ @@ -47,7 +47,7 @@ bool ofXml::parse(const std::string & xmlStr){ } } -bool ofXml::save(const std::filesystem::path & file) const{ +bool ofXml::save(const fs::path & file) const{ if(xml == doc->root()){ auto res = doc->save_file(ofToDataPath(file).c_str()); ofLogVerbose("ofXml")<<"ofXML Save : "<< res; diff --git a/libs/openFrameworks/utils/ofXml.h b/libs/openFrameworks/utils/ofXml.h index c4006615ff2..9f69110f7ad 100644 --- a/libs/openFrameworks/utils/ofXml.h +++ b/libs/openFrameworks/utils/ofXml.h @@ -100,10 +100,10 @@ class ofXml{ ofXml(); - bool load(const std::filesystem::path & file); + bool load(const fs::path & file); bool load(const ofBuffer & buffer); bool parse(const std::string & xmlStr); - bool save(const std::filesystem::path & file) const; + bool save(const fs::path & file) const; void clear(); std::string toString(const std::string & indent = "\t") const;