From 2e03222896e1da48cfd51b52848003aeed708720 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 3 Aug 2022 09:45:53 -0300 Subject: [PATCH 01/91] not working yet --- .../ofxAndroid/src/ofxAndroidSoundPlayer.cpp | 2 +- addons/ofxAndroid/src/ofxAndroidSoundPlayer.h | 2 +- .../src/ofxEmscriptenSoundPlayer.cpp | 2 +- .../src/ofxEmscriptenSoundPlayer.h | 2 +- .../src/ofxEmscriptenURLFileLoader.cpp | 4 +- .../src/ofxEmscriptenURLFileLoader.h | 4 +- addons/ofxPoco/src/ofxXmlPoco.cpp | 4 +- addons/ofxPoco/src/ofxXmlPoco.h | 4 +- addons/ofxUnitTests/src/ofxUnitTests.h | 4 +- .../ofxiOS/src/sound/ofxOpenALSoundPlayer.cpp | 2 +- .../ofxiOS/src/sound/ofxOpenALSoundPlayer.h | 2 +- addons/ofxiOS/src/sound/ofxiOSSoundPlayer.h | 2 +- addons/ofxiOS/src/sound/ofxiOSSoundPlayer.mm | 2 +- examples/3d/ofNodeExample/addons.make | 0 .../androidAccelerometerExample/addons.make | 0 .../androidAdvanced3DExample/addons.make | 0 .../android/androidAudioExample/addons.make | 0 .../android/androidCameraExample/addons.make | 0 .../android/androidEmptyExample/addons.make | 0 .../android/androidFontExample/addons.make | 0 .../android/androidImageExample/addons.make | 0 .../addons.make | 0 .../addons.make | 0 .../android/androidPolygonExample/addons.make | 0 .../android/androidShaderExample/addons.make | 0 .../androidSoundPlayerExample/addons.make | 0 .../android/androidSwipeExample/addons.make | 0 .../android/androidTouchExample/addons.make | 0 .../android/androidVBOExample/addons.make | 0 .../androidVibratorExample/addons.make | 0 .../android/androidVideoExample/addons.make | 0 examples/events/rpiTouchExample/addons.make | 0 .../gl/transformFeedbackExample/addons.make | 0 .../vboMeshDrawInstancedExample/addons.make | 0 .../colorsExtendedExample/addons.make | 0 .../ios/GLKitNativeARCExample/addons.make | 0 examples/ios/iosNativeARCExample/addons.make | 0 .../shader/01_simpleColorQuad/addons.make | 0 .../02_simpleVertexDisplacement/addons.make | 0 .../03_simpleShaderInteraction/addons.make | 0 .../shader/04_simpleTexturing/addons.make | 0 examples/shader/05_alphaMasking/addons.make | 0 examples/shader/06_multiTexture/addons.make | 0 examples/shader/07_fboAlphaMask/addons.make | 0 .../shader/08_displacementMap/addons.make | 0 .../shader/09_gaussianBlurFilter/addons.make | 0 .../windowing/noWindowExample/addons.make | 0 libs/openFrameworks/3d/ofMesh.h | 4 +- libs/openFrameworks/3d/ofMesh.inl | 8 +- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 2 +- libs/openFrameworks/gl/ofShader.cpp | 27 +- libs/openFrameworks/gl/ofShader.h | 26 +- .../graphics/ofCairoRenderer.cpp | 2 +- libs/openFrameworks/graphics/ofImage.cpp | 24 +- libs/openFrameworks/graphics/ofImage.h | 20 +- .../graphics/ofTrueTypeFont.cpp | 12 +- libs/openFrameworks/graphics/ofTrueTypeFont.h | 6 +- .../sound/ofFmodSoundPlayer.cpp | 2 +- libs/openFrameworks/sound/ofFmodSoundPlayer.h | 2 +- .../sound/ofOpenALSoundPlayer.cpp | 16 +- .../sound/ofOpenALSoundPlayer.h | 14 +- libs/openFrameworks/sound/ofSoundBaseTypes.h | 2 +- libs/openFrameworks/sound/ofSoundPlayer.cpp | 2 +- libs/openFrameworks/sound/ofSoundPlayer.h | 2 +- libs/openFrameworks/utils/ofConstants.h | 16 + libs/openFrameworks/utils/ofFileUtils.cpp | 382 +++++++++--------- libs/openFrameworks/utils/ofFileUtils.h | 113 +++--- libs/openFrameworks/utils/ofJson.h | 6 +- libs/openFrameworks/utils/ofLog.cpp | 6 +- libs/openFrameworks/utils/ofLog.h | 6 +- libs/openFrameworks/utils/ofURLFileLoader.cpp | 16 +- libs/openFrameworks/utils/ofURLFileLoader.h | 12 +- libs/openFrameworks/utils/ofXml.cpp | 8 +- libs/openFrameworks/utils/ofXml.h | 4 +- .../project/osx/config.osx.default.mk | 56 ++- 75 files changed, 456 insertions(+), 376 deletions(-) delete mode 100644 examples/3d/ofNodeExample/addons.make delete mode 100644 examples/android/androidAccelerometerExample/addons.make delete mode 100644 examples/android/androidAdvanced3DExample/addons.make delete mode 100644 examples/android/androidAudioExample/addons.make delete mode 100644 examples/android/androidCameraExample/addons.make delete mode 100644 examples/android/androidEmptyExample/addons.make delete mode 100644 examples/android/androidFontExample/addons.make delete mode 100644 examples/android/androidImageExample/addons.make delete mode 100644 examples/android/androidJavaOnlyActivityExample/addons.make delete mode 100644 examples/android/androidMultiOFActivitiesExample/addons.make delete mode 100644 examples/android/androidPolygonExample/addons.make delete mode 100644 examples/android/androidShaderExample/addons.make delete mode 100644 examples/android/androidSoundPlayerExample/addons.make delete mode 100644 examples/android/androidSwipeExample/addons.make delete mode 100644 examples/android/androidTouchExample/addons.make delete mode 100644 examples/android/androidVBOExample/addons.make delete mode 100644 examples/android/androidVibratorExample/addons.make delete mode 100644 examples/android/androidVideoExample/addons.make delete mode 100644 examples/events/rpiTouchExample/addons.make delete mode 100644 examples/gl/transformFeedbackExample/addons.make delete mode 100644 examples/gl/vboMeshDrawInstancedExample/addons.make delete mode 100644 examples/graphics/colorsExtendedExample/addons.make delete mode 100644 examples/ios/GLKitNativeARCExample/addons.make delete mode 100644 examples/ios/iosNativeARCExample/addons.make delete mode 100644 examples/shader/01_simpleColorQuad/addons.make delete mode 100644 examples/shader/02_simpleVertexDisplacement/addons.make delete mode 100644 examples/shader/03_simpleShaderInteraction/addons.make delete mode 100644 examples/shader/04_simpleTexturing/addons.make delete mode 100644 examples/shader/05_alphaMasking/addons.make delete mode 100644 examples/shader/06_multiTexture/addons.make delete mode 100644 examples/shader/07_fboAlphaMask/addons.make delete mode 100644 examples/shader/08_displacementMap/addons.make delete mode 100644 examples/shader/09_gaussianBlurFilter/addons.make delete mode 100644 examples/windowing/noWindowExample/addons.make diff --git a/addons/ofxAndroid/src/ofxAndroidSoundPlayer.cpp b/addons/ofxAndroid/src/ofxAndroidSoundPlayer.cpp index 2d1af47887e..26088ed5273 100644 --- a/addons/ofxAndroid/src/ofxAndroidSoundPlayer.cpp +++ b/addons/ofxAndroid/src/ofxAndroidSoundPlayer.cpp @@ -43,7 +43,7 @@ ofxAndroidSoundPlayer::~ofxAndroidSoundPlayer(){ //------------------------------------------------------------ -bool ofxAndroidSoundPlayer::load(const std::filesystem::path& fileName, bool stream){ +bool ofxAndroidSoundPlayer::load(const filesystem::path& fileName, bool stream){ if(!javaSoundPlayer){ ofLogError("ofxAndroidSoundPlayer") << "loadSound(): java SoundPlayer not loaded"; return false; diff --git a/addons/ofxAndroid/src/ofxAndroidSoundPlayer.h b/addons/ofxAndroid/src/ofxAndroidSoundPlayer.h index 86cde2e3c56..c70d1a07a2c 100644 --- a/addons/ofxAndroid/src/ofxAndroidSoundPlayer.h +++ b/addons/ofxAndroid/src/ofxAndroidSoundPlayer.h @@ -8,7 +8,7 @@ class ofxAndroidSoundPlayer: public ofBaseSoundPlayer{ ofxAndroidSoundPlayer(); virtual ~ofxAndroidSoundPlayer(); - bool load(const std::filesystem::path& fileName, bool stream = false); + bool load(const filesystem::path& fileName, bool stream = false); void unload(); void play(); void stop(); diff --git a/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.cpp b/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.cpp index d1a203c2970..5a6c16e22c6 100644 --- a/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.cpp +++ b/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.cpp @@ -39,7 +39,7 @@ ofxEmscriptenSoundPlayer::~ofxEmscriptenSoundPlayer(){ } -bool ofxEmscriptenSoundPlayer::load(const std::filesystem::path& fileName, bool stream){ +bool ofxEmscriptenSoundPlayer::load(const filesystem::path& fileName, bool stream){ if(context!=-1){ sound = html5audio_sound_load(context,ofToDataPath(fileName).c_str()); } diff --git a/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.h b/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.h index 4942ed00ea0..da3bf143dc1 100644 --- a/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.h +++ b/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.h @@ -9,7 +9,7 @@ class ofxEmscriptenSoundPlayer: public ofBaseSoundPlayer { ~ofxEmscriptenSoundPlayer(); - bool load(const std::filesystem::path& fileName, bool stream = false); + bool load(const filesystem::path& fileName, bool stream = false); void unload(); void play(); void stop(); diff --git a/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp b/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp index ac112436872..a94b1385e01 100644 --- a/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp +++ b/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp @@ -30,12 +30,12 @@ int ofxEmscriptenURLFileLoader::getAsync(const string & url, const string & na return req->getId(); } -ofHttpResponse ofxEmscriptenURLFileLoader::saveTo(const string & url, const std::filesystem::path & path){ +ofHttpResponse ofxEmscriptenURLFileLoader::saveTo(const string & url, const filesystem::path & path){ saveAsync(url,path); return ofHttpResponse(); } -int ofxEmscriptenURLFileLoader::saveAsync(const string & url, const std::filesystem::path & path){ +int ofxEmscriptenURLFileLoader::saveAsync(const string & url, const filesystem::path & path){ ofHttpRequest * req = new ofHttpRequest(url,url,true); #if __EMSCRIPTEN_major__>1 || (__EMSCRIPTEN_major__==1 && __EMSCRIPTEN_minor__>22) emscripten_async_wget2(url.c_str(), path.c_str(), "GET", "", req, &onload_file_cb, &onerror_file_cb, NULL); diff --git a/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h b/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h index 1c9ae5339be..4fb68abfe3b 100644 --- a/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h +++ b/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h @@ -13,8 +13,8 @@ class ofxEmscriptenURLFileLoader: public ofBaseURLFileLoader { virtual ~ofxEmscriptenURLFileLoader(); ofHttpResponse get(const std::string & url); int getAsync(const std::string & url, const std::string & name=""); // returns id - ofHttpResponse saveTo(const std::string & url, const std::filesystem::path & path); - int saveAsync(const std::string & url, const std::filesystem::path & path); + ofHttpResponse saveTo(const std::string & url, const filesystem::path & path); + int saveAsync(const std::string & url, const filesystem::path & path); ofHttpResponse handleRequest(const ofHttpRequest & request); int handleRequestAsync(const ofHttpRequest & request); void remove(int id); diff --git a/addons/ofxPoco/src/ofxXmlPoco.cpp b/addons/ofxPoco/src/ofxXmlPoco.cpp index 5b9901b8e97..24cb464236d 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 filesystem::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 filesystem::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..afad03b16cd 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 filesystem::path & path); + bool save(const filesystem::path & path); bool addChild( const std::string& path ); void addXml( ofxXmlPoco& xml, bool copyAll = false); diff --git a/addons/ofxUnitTests/src/ofxUnitTests.h b/addons/ofxUnitTests/src/ofxUnitTests.h index cafff93a801..cb521ed451b 100644 --- a/addons/ofxUnitTests/src/ofxUnitTests.h +++ b/addons/ofxUnitTests/src/ofxUnitTests.h @@ -228,9 +228,9 @@ class ofxUnitTestsApp: public ofBaseApp{ const std::string APPVEYOR_API_URL = "APPVEYOR_API_URL"; if(ofGetEnv(APPVEYOR_API_URL)!=""){ //ofSystem("appveyor AddTest -Name " + projectName.string() + " -Framework ofxUnitTests -FileName " + exeName.string() + " -Outcome " + (passed?"Passed":"Failed") + " -Duration " + ofToString(now-then)); - auto projectDir = std::filesystem::canonical(std::filesystem::path(ofFilePath::getCurrentExeDir()) / ".."); + auto projectDir = filesystem::canonical(filesystem::path(ofFilePath::getCurrentExeDir()) / ".."); auto projectName = projectDir.stem(); - auto exeName = std::filesystem::path(ofFilePath::getCurrentExePath()).filename(); + auto exeName = filesystem::path(ofFilePath::getCurrentExePath()).filename(); auto stdOut = logger->getStdOut(); ofStringReplace(stdOut, "\\", "\\\\"); ofStringReplace(stdOut, "\"", "\\\""); diff --git a/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.cpp b/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.cpp index 7b5fc15acf8..2c6cfc574a3 100644 --- a/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.cpp +++ b/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.cpp @@ -90,7 +90,7 @@ ofxOpenALSoundPlayer::~ofxOpenALSoundPlayer() { //-------------------------------------------------------------- -bool ofxOpenALSoundPlayer::load(const std::filesystem::path& filePath, bool stream) { +bool ofxOpenALSoundPlayer::load(const filesystem::path& filePath, bool stream) { if(!SoundEngineInitialized) { ofxOpenALSoundPlayer::initializeSoundEngine(); diff --git a/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.h b/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.h index f679acc4b71..58ec666034d 100644 --- a/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.h +++ b/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.h @@ -62,7 +62,7 @@ class ofxOpenALSoundPlayer : public ofBaseSoundPlayer{ ofxOpenALSoundPlayer(); ~ofxOpenALSoundPlayer(); - bool load(const std::filesystem::path& fileName, bool stream=false); + bool load(const filesystem::path& fileName, bool stream=false); void unload(); void play(); diff --git a/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.h b/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.h index 57d882aad35..daa971bb37d 100644 --- a/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.h +++ b/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.h @@ -15,7 +15,7 @@ class ofxiOSSoundPlayer : public ofBaseSoundPlayer { ofxiOSSoundPlayer(); ~ofxiOSSoundPlayer(); - bool load(const std::filesystem::path& fileName, bool stream = false); + bool load(const filesystem::path& fileName, bool stream = false); void unload(); void play(); void stop(); diff --git a/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.mm b/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.mm index 8632fda22b1..5ad19876472 100644 --- a/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.mm +++ b/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.mm @@ -19,7 +19,7 @@ unload(); } -bool ofxiOSSoundPlayer::load(const std::filesystem::path& fileName, bool stream) { +bool ofxiOSSoundPlayer::load(const filesystem::path& fileName, bool stream) { if(soundPlayer != NULL) { unload(); } diff --git a/examples/3d/ofNodeExample/addons.make b/examples/3d/ofNodeExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidAccelerometerExample/addons.make b/examples/android/androidAccelerometerExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidAdvanced3DExample/addons.make b/examples/android/androidAdvanced3DExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidAudioExample/addons.make b/examples/android/androidAudioExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidCameraExample/addons.make b/examples/android/androidCameraExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidEmptyExample/addons.make b/examples/android/androidEmptyExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidFontExample/addons.make b/examples/android/androidFontExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidImageExample/addons.make b/examples/android/androidImageExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidJavaOnlyActivityExample/addons.make b/examples/android/androidJavaOnlyActivityExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidMultiOFActivitiesExample/addons.make b/examples/android/androidMultiOFActivitiesExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidPolygonExample/addons.make b/examples/android/androidPolygonExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidShaderExample/addons.make b/examples/android/androidShaderExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidSoundPlayerExample/addons.make b/examples/android/androidSoundPlayerExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidSwipeExample/addons.make b/examples/android/androidSwipeExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidTouchExample/addons.make b/examples/android/androidTouchExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidVBOExample/addons.make b/examples/android/androidVBOExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidVibratorExample/addons.make b/examples/android/androidVibratorExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/android/androidVideoExample/addons.make b/examples/android/androidVideoExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/events/rpiTouchExample/addons.make b/examples/events/rpiTouchExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/gl/transformFeedbackExample/addons.make b/examples/gl/transformFeedbackExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/gl/vboMeshDrawInstancedExample/addons.make b/examples/gl/vboMeshDrawInstancedExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/graphics/colorsExtendedExample/addons.make b/examples/graphics/colorsExtendedExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/ios/GLKitNativeARCExample/addons.make b/examples/ios/GLKitNativeARCExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/ios/iosNativeARCExample/addons.make b/examples/ios/iosNativeARCExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/shader/01_simpleColorQuad/addons.make b/examples/shader/01_simpleColorQuad/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/shader/02_simpleVertexDisplacement/addons.make b/examples/shader/02_simpleVertexDisplacement/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/shader/03_simpleShaderInteraction/addons.make b/examples/shader/03_simpleShaderInteraction/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/shader/04_simpleTexturing/addons.make b/examples/shader/04_simpleTexturing/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/shader/05_alphaMasking/addons.make b/examples/shader/05_alphaMasking/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/shader/06_multiTexture/addons.make b/examples/shader/06_multiTexture/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/shader/07_fboAlphaMask/addons.make b/examples/shader/07_fboAlphaMask/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/shader/08_displacementMap/addons.make b/examples/shader/08_displacementMap/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/shader/09_gaussianBlurFilter/addons.make b/examples/shader/09_gaussianBlurFilter/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/examples/windowing/noWindowExample/addons.make b/examples/windowing/noWindowExample/addons.make deleted file mode 100644 index e69de29bb2d..00000000000 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..3120163fcdc 100644 --- a/libs/openFrameworks/3d/ofMesh.inl +++ b/libs/openFrameworks/3d/ofMesh.inl @@ -1030,8 +1030,10 @@ void ofMesh_::append(const ofMesh_ & mesh){ //-------------------------------------------------------------- template -void ofMesh_::load(const std::filesystem::path& path){ - ofFile is(path, ofFile::ReadOnly); +void ofMesh_::load(const fs::path& path){ + ofFile is = {path, ofFile::ReadOnly}; +// ofFile is(path, ofFile::ReadOnly); +// ofFile is(path); auto & data = *this; @@ -1271,7 +1273,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..b3f55b90b46 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,11 +292,11 @@ 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. - string absoluteFilePath = ofFilePath::getAbsolutePath(filename, true); + auto absoluteFilePath = ofFilePath::getAbsolutePath(filename, true); string sourceDirectoryPath = ofFilePath::getEnclosingDirectory(absoluteFilePath,false); if(buffer.size()) { return setupShaderFromSource(type, buffer.getText(), sourceDirectoryPath); @@ -307,14 +307,14 @@ 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. - string absoluteFilePath = ofFilePath::getAbsolutePath(filename, true); - string sourceDirectoryPath = ofFilePath::getEnclosingDirectory(absoluteFilePath,false); + auto absoluteFilePath = ofFilePath::getAbsolutePath(filename, true); + auto sourceDirectoryPath = ofFilePath::getEnclosingDirectory(absoluteFilePath,false); if(buffer.size()) { - return Source{type, buffer.getText(), sourceDirectoryPath}; + return Source{type, buffer.getText(), sourceDirectoryPath.string() }; } else { ofLogError("ofShader") << "setupShaderFromFile(): couldn't load " << nameForType(type) << " shader " << " from \"" << absoluteFilePath << "\""; return Source{}; @@ -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" ); @@ -486,7 +486,10 @@ string ofShader::parseForIncludes( const string& source, vector& include // we store the absolute paths so as have (more) unique file identifiers. - include = ofFile(ofFilePath::join(sourceDirectoryPath, include)).getAbsolutePath(); + include = ofFile( +// ofFilePath::join(sourceDirectoryPath, include) + sourceDirectoryPath / include + ).getAbsolutePath(); included.push_back( include ); ofBuffer buffer = ofBufferFromFile( include ); 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/ofCairoRenderer.cpp b/libs/openFrameworks/graphics/ofCairoRenderer.cpp index 2eb09f15912..b125d42807f 100644 --- a/libs/openFrameworks/graphics/ofCairoRenderer.cpp +++ b/libs/openFrameworks/graphics/ofCairoRenderer.cpp @@ -37,7 +37,7 @@ ofCairoRenderer::~ofCairoRenderer(){ close(); } -void ofCairoRenderer::setup(string _filename, Type _type, bool multiPage_, bool b3D_, ofRectangle outputsize){ +void ofCairoRenderer::setup(const string & _filename, Type _type, bool multiPage_, bool b3D_, ofRectangle outputsize){ if( outputsize.width == 0 || outputsize.height == 0 ){ outputsize.set(0, 0, ofGetViewportWidth(), ofGetViewportHeight()); } 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..083227acd52 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp @@ -372,10 +372,12 @@ 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; - filename = ofToDataPath(_fontname,true); - ofFile fontFile(filename,ofFile::Reference); +static bool loadFontFace(const fs::path& _fontname, FT_Face & face, fs::path & filename, int index){ + fs::path fontname = _fontname; + // makes no sense +// filename = ofToDataPath(_fontname,true); + auto fn = ofToDataPath(_fontname,true); + ofFile fontFile(fn,ofFile::Reference); int fontID = index; if(!fontFile.exists()){ #ifdef TARGET_LINUX @@ -695,7 +697,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..1b967354073 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -451,6 +451,7 @@ std::unique_ptr make_unique(Args&&... args) { #define OF_HAS_CPP17 0 #endif + #ifndef OF_USING_STD_FS #if OF_HAS_CPP17 #define OF_USING_STD_FS 1 @@ -499,6 +500,8 @@ std::unique_ptr make_unique(Args&&... args) { #endif #endif +#define OF_USING_STD_FS 1 + #if OF_USING_STD_FS #if OF_USE_EXPERIMENTAL_FS // C++17 experimental fs support @@ -535,6 +538,7 @@ std::unique_ptr make_unique(Args&&... args) { #else // Regular C++17 fs support #include + #endif #else // No experimental or c++17 filesytem support use boost @@ -552,3 +556,15 @@ std::unique_ptr make_unique(Args&&... args) { namespace filesystem = boost::filesystem; } #endif + + +// namespace std::__fs::filesystem = std::filesystem; +// using std::filesystem; +// namespace std::filesystem = std::__fs::filesystem; +namespace fs = std::__fs::filesystem; +// using std::__fs::filesystem; +// namespace std::filesystem = std::__fs::filesystem; + +// namespace std { + // namespace filesystem = __fs::filesystem; +// } diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 897d408a308..5ee68554c32 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -28,16 +28,19 @@ namespace{ //-------------------------------------------------- string defaultDataPath(){ #if defined TARGET_OSX - try{ - return std::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../data/")).string(); - }catch(...){ - return ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../data/"); - } + return ofFilePath::getCurrentExeDir() / "../../../data/"; +// try{ +// return ofFilePath::getCurrentExeDir() / "../../../data/"; +//// return fs::canonical(ofFilePath::getCurrentExeDir() / "../../../data/"); +//// return fs::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../data/")).string(); +// }catch(...){ +// return ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../data/"); +// } #elif defined TARGET_ANDROID 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 +48,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 +63,7 @@ namespace{ namespace of{ namespace priv{ void initfileutils(){ - defaultWorkingDirectory() = std::filesystem::absolute(std::filesystem::current_path()); + defaultWorkingDirectory() = fs::absolute(fs::current_path()); } } } @@ -450,13 +453,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 +476,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); @@ -520,7 +523,9 @@ bool ofFile::openStream(Mode _mode, bool _binary){ case WriteOnly: case ReadWrite: case Append: - if(!ofDirectory(ofFilePath::getEnclosingDirectory(path())).exists()){ + if(!ofDirectory( + ofFilePath::getEnclosingDirectory(path()) + ).exists()){ ofFilePath::createEnclosingDirectory(path()); } break; @@ -555,16 +560,17 @@ 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 = ofToDataPath(_path); 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()); + myFile = _path; return openStream(_mode, binary); } @@ -573,7 +579,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 +594,7 @@ bool ofFile::isWriteMode(){ //------------------------------------------------------------------------------------------------------------- void ofFile::close(){ - myFile = std::filesystem::path(); + myFile = fs::path(); if(mode!=Reference) fstream::close(); } @@ -598,7 +604,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 +620,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,12 +649,12 @@ bool ofFile::exists() const { return false; } - return std::filesystem::exists(myFile); + return fs::exists(myFile); } //------------------------------------------------------------------------------------------------------------ -string ofFile::path() const { - return myFile.string(); +fs::path ofFile::path() const { + return myFile; } //------------------------------------------------------------------------------------------------------------ @@ -672,18 +678,18 @@ string ofFile::getBaseName() const { } //------------------------------------------------------------------------------------------------------------ -string ofFile::getEnclosingDirectory() const { +fs::path ofFile::getEnclosingDirectory() const { return ofFilePath::getEnclosingDirectory(path()); } //------------------------------------------------------------------------------------------------------------ -string ofFile::getAbsolutePath() const { +fs::path ofFile::getAbsolutePath() const { return ofFilePath::getAbsolutePath(path()); } //------------------------------------------------------------------------------------------------------------ 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 +702,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 +722,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 +735,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 +755,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 +763,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 +783,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 +802,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 +823,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 +854,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 +880,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 +908,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()){ @@ -930,7 +936,8 @@ bool ofFile::copyTo(const std::filesystem::path& _path, bool bRelativeToData, bo ofFile tmp; tmp.openFromCWD(path,ofFile::Reference); if(tmp.isDirectory()){ - path = ofFilePath::join(path,getFileName()); + path = path / getFileName(); +// path = ofFilePath::join(path,getFileName()); } } if(ofFile::doesFileExist(path, false)){ @@ -944,11 +951,12 @@ bool ofFile::copyTo(const std::filesystem::path& _path, bool bRelativeToData, bo try{ ofDirectory destDir; - destDir.openFromCWD(ofFilePath::getEnclosingDirectory(path,false)); + auto p = ofFilePath::getEnclosingDirectory(path,false); + destDir.openFromCWD(p); 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 +966,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 +1009,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 +1024,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 +1044,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 +1059,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 +1100,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 +1112,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 +1123,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 +1134,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 +1157,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 +1187,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,20 +1203,20 @@ bool ofDirectory::create(bool recursive){ //------------------------------------------------------------------------------------------------------------ bool ofDirectory::exists() const { - return (myDir == "" || std::filesystem::exists(myDir)); + return (myDir == "" || fs::exists(myDir)); } //------------------------------------------------------------------------------------------------------------ -string ofDirectory::path() const { - return myDir.string(); +fs::path ofDirectory::path() const { + return myDir; } //------------------------------------------------------------------------------------------------------------ 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 +1268,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,13 +1307,13 @@ 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)){ + if(!current.copyTo(dst,false,overwrite)){ return false; } }else{ @@ -1319,7 +1327,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 +1336,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 +1381,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 +1476,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 +1520,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 +1534,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 +1552,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 +1568,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 +1583,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 +1654,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 +1666,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 +1684,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 +1703,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 +1713,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 +1723,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){ - std::string filePath = _filePath.string(); +fs::path 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(_filePath.parent_path()); } //------------------------------------------------------------------------------------------------------------ -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){ +fs::path 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)); }catch(...){ - return std::filesystem::absolute(path).string(); + return fs::absolute(path); } } } //------------------------------------------------------------------------------------------------------------ -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(); } //------------------------------------------------------------------------------------------------------------ @@ -1805,8 +1813,8 @@ string ofFilePath::getCurrentExePath(){ } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::getCurrentExeDir(){ - return getEnclosingDirectory(getCurrentExePath(), false); +fs::path ofFilePath::getCurrentExeDir(){ + return ofFilePath::getEnclosingDirectory(ofFilePath::getCurrentExePath(), false); } //------------------------------------------------------------------------------------------------------------ @@ -1824,15 +1832,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 +1868,7 @@ void ofDisableDataPath(){ //-------------------------------------------------- bool ofRestoreWorkingDirectoryToDefault(){ try{ - std::filesystem::current_path(defaultWorkingDirectory()); + fs::current_path(defaultWorkingDirectory()); return true; }catch(...){ return false; @@ -1868,12 +1876,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){ +fs::path ofToDataPath(const fs::path & path, bool makeAbsolute){ if (makeAbsolute && path.is_absolute()) { return path.string(); } @@ -1886,7 +1894,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 +1905,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(); @@ -1918,11 +1926,11 @@ string ofToDataPath(const std::filesystem::path & path, bool makeAbsolute){ // here we check whether path already refers to the data folder by looking for common elements // if the path begins with the full contents of dataPathRoot then the data path has already been added // we compare inputPath.toString() rather that the input var path to ensure common formatting against dataPath.toString() - auto dirDataPath = dataPath.string(); +// auto dirDataPath = dataPath.string(); // 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); + dirDataPath = ofFilePath::addTrailingSlash(dataPath); - 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 +1949,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){ - return ofFilePath::addTrailingSlash(outpath.string()); + auto outpath = fs::canonical(fs::absolute(outputPath)).make_preferred(); + if(fs::is_directory(outpath) && hasTrailingSlash){ + return ofFilePath::addTrailingSlash(outpath); }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 4868485712f..053db73216b 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -3,6 +3,11 @@ #include "ofConstants.h" #include +// #include + +// using std::filesystem; +// using std::fs; +// using namespace std::filesystem; //---------------------------------------------------------- // ofBuffer //---------------------------------------------------------- @@ -269,7 +274,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. @@ -280,7 +285,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(fs::path & path, const ofBuffer& buffer, bool binary=true); //-------------------------------------------------- /// \class ofFilePath @@ -294,32 +299,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 fs::path 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. /// @@ -328,7 +333,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". @@ -338,7 +343,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 fs::path getAbsolutePath(const fs::path& path, bool bRelativeToData = true); /// Check if a path is an absolute (aka a full path), /// ie. "images" -> false, @@ -346,7 +351,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(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 @@ -357,7 +362,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(fs::path& filePath, bool bRelativeToData = true); /// Get a file name without its extension, /// ie. "images/duck.jpg" -> "duck" and @@ -365,7 +370,7 @@ class ofFilePath{ /// /// \param filePath file path /// \returns basename - static std::string getBaseName(const std::filesystem::path& filePath); + static std::string getBaseName(fs::path& filePath); /// Get the enclosing parent directory of a path, /// ie. "images/duck.jpg" -> "images", assumes the path is in the data @@ -376,7 +381,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 fs::path 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". @@ -390,7 +395,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. /// @@ -408,7 +413,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(fs::path& path1, fs::path& path2); /// Get the full path to the application's executable file. /// @@ -425,7 +430,7 @@ class ofFilePath{ /// Mac: the Contents/MacOS folder within the application's .app bundle /// /// \returns current executable directory - static std::string getCurrentExeDir(); + static fs::path getCurrentExeDir(); /// Get the absolute path to the user's home directory. /// @@ -443,7 +448,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(fs::path & from, fs::path & to); }; /// \class ofFile @@ -481,7 +486,8 @@ 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(fs::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. @@ -506,7 +512,8 @@ 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(fs::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. /// @@ -518,7 +525,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. /// @@ -545,7 +552,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. /// @@ -555,7 +562,7 @@ class ofFile: public std::fstream{ /// Get the current path. /// /// \returns current path - std::string path() const; + fs::path path() const; /// Get the current path without its extension, /// ie. "duck.jpg" ->"duck". @@ -581,13 +588,13 @@ class ofFile: public std::fstream{ /// directory. /// /// \returns current path's enclosing directory - std::string getEnclosingDirectory() const; + fs::path getEnclosingDirectory() const; /// \biref Get the absolute, full path of the file, /// ie. "images" -> "/Users/mickey/of/apps/myApps/Donald/bin/data/images". /// /// \returns current path as an absolute path - std::string getAbsolutePath() const; + fs::path getAbsolutePath() const; /// Check if the current path is readable. /// @@ -659,7 +666,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. /// @@ -673,7 +680,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. /// @@ -687,7 +694,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. /// @@ -741,11 +748,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 fs::path() const{ return myFile; } @@ -765,7 +772,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. /// @@ -781,7 +788,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. /// @@ -790,7 +797,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. /// @@ -798,13 +805,14 @@ 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; }; @@ -827,17 +835,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(); @@ -856,13 +864,13 @@ class ofDirectory{ /// Get the current path. /// /// \returns current path - std::string path() const; + fs::path path() const; /// Get the absolute, full path of the directory, /// ie. "images" -> "/Users/mickey/of/apps/myApps/Donald/bin/data/images". /// /// \return current path as an absolute path - std::string getAbsolutePath() const; + fs::path getAbsolutePath() const; /// Check if the current path is readable. /// @@ -929,7 +937,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. /// @@ -943,7 +951,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. /// @@ -957,7 +965,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. /// @@ -1107,11 +1115,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 fs::path() const{ return myDir; } @@ -1129,7 +1137,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. /// @@ -1140,7 +1148,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. /// @@ -1150,7 +1158,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 @@ -1160,15 +1168,14 @@ 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; std::vector::const_reverse_iterator rbegin() const; std::vector::const_reverse_iterator rend() const; -private: - std::filesystem::path myDir; + fs::path myDir; std::string originalDirectory; std::vector extensions; std::vector files; @@ -1200,7 +1207,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); +fs::path ofToDataPath(const fs::path & path, bool absolute=false); /// \brief Reset the working directory to the platform default. /// @@ -1219,7 +1226,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(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 13660a6b1dc..68afa7aebb4 100644 --- a/libs/openFrameworks/utils/ofLog.cpp +++ b/libs/openFrameworks/utils/ofLog.cpp @@ -61,7 +61,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)); } @@ -261,7 +261,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); } @@ -273,7 +273,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 ddb23622054..4d324d35b24 100644 --- a/libs/openFrameworks/utils/ofLog.h +++ b/libs/openFrameworks/utils/ofLog.h @@ -236,7 +236,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. /// @@ -703,7 +703,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(); @@ -711,7 +711,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); 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..07b89bdb719 100644 --- a/libs/openFrameworks/utils/ofXml.cpp +++ b/libs/openFrameworks/utils/ofXml.cpp @@ -15,9 +15,11 @@ 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()); + auto p = ofToDataPath(file); + auto res = auxDoc->load_file( + ofToDataPath(file).string().c_str()); if( res ){ doc = auxDoc; xml = doc->root(); @@ -47,7 +49,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; diff --git a/libs/openFrameworksCompiled/project/osx/config.osx.default.mk b/libs/openFrameworksCompiled/project/osx/config.osx.default.mk index 083ea74476b..6c377355a97 100644 --- a/libs/openFrameworksCompiled/project/osx/config.osx.default.mk +++ b/libs/openFrameworksCompiled/project/osx/config.osx.default.mk @@ -69,6 +69,8 @@ PLATFORM_REQUIRED_ADDONS = # Note: Be sure to leave a leading space when using a += operator to add items to the list ########################################################################################## +MAC_OS_MIN_VERSION = 10.15 + ifndef MAC_OS_MIN_VERSION MAC_OS_MIN_VERSION = 10.9 endif @@ -82,7 +84,7 @@ ifndef MAC_OS_CPP_VER endif # Link against libstdc++ to silence tr1/memory errors on latest versions of osx -PLATFORM_CFLAGS = -stdlib=$(MAC_OS_STD_LIB) +PLATFORM_CFLAGS += -stdlib=$(MAC_OS_STD_LIB) # Warning Flags (http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html) PLATFORM_CFLAGS += -Wall @@ -166,6 +168,9 @@ endif PLATFORM_LDFLAGS = -stdlib=$(MAC_OS_STD_LIB) +PLATFORM_LDFLAGS += -lstdc++fs + + #PLATFORM_LDFLAGS += -arch i386 PLATFORM_LDFLAGS += -mmacosx-version-min=$(MAC_OS_MIN_VERSION) -v @@ -242,6 +247,21 @@ ifeq ($(USE_FMOD),0) PLATFORM_CFLAGS += -DUSE_FMOD=0 endif + +# DIMITRE LITE +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/fmodex/% +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/rtAudio/% +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/% +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/sound/% +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/communication/% +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/3d/% + +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/json/% +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/boost/% +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/pugixml/% + + + ########################################################################################## # PLATFORM HEADER SEARCH PATHS # These are header search paths that are platform specific and are specified @@ -303,22 +323,42 @@ PLATFORM_LIBRARY_SEARCH_PATHS = # Note: Be sure to leave a leading space when using a += operator to add items to the list ########################################################################################## +# PLATFORM_FRAMEWORKS = +# PLATFORM_FRAMEWORKS += Accelerate +# PLATFORM_FRAMEWORKS += QTKit +# PLATFORM_FRAMEWORKS += AGL +# PLATFORM_FRAMEWORKS += ApplicationServices +# PLATFORM_FRAMEWORKS += AudioToolbox +# PLATFORM_FRAMEWORKS += CoreAudio +# PLATFORM_FRAMEWORKS += CoreFoundation +# PLATFORM_FRAMEWORKS += CoreServices +# PLATFORM_FRAMEWORKS += OpenGL +# PLATFORM_FRAMEWORKS += IOKit +# PLATFORM_FRAMEWORKS += Cocoa +# PLATFORM_FRAMEWORKS += CoreVideo +# PLATFORM_FRAMEWORKS += AVFoundation +# PLATFORM_FRAMEWORKS += CoreMedia +# PLATFORM_FRAMEWORKS += QuartzCore +# PLATFORM_FRAMEWORKS += Security + +# DIMITRE LITE + PLATFORM_FRAMEWORKS = PLATFORM_FRAMEWORKS += Accelerate -PLATFORM_FRAMEWORKS += QTKit -PLATFORM_FRAMEWORKS += AGL -PLATFORM_FRAMEWORKS += ApplicationServices -PLATFORM_FRAMEWORKS += AudioToolbox -PLATFORM_FRAMEWORKS += CoreAudio +# PLATFORM_FRAMEWORKS += QTKit +# PLATFORM_FRAMEWORKS += AGL +# PLATFORM_FRAMEWORKS += ApplicationServices +# PLATFORM_FRAMEWORKS += AudioToolbox +# PLATFORM_FRAMEWORKS += CoreAudio PLATFORM_FRAMEWORKS += CoreFoundation -PLATFORM_FRAMEWORKS += CoreServices +# PLATFORM_FRAMEWORKS += CoreServices PLATFORM_FRAMEWORKS += OpenGL PLATFORM_FRAMEWORKS += IOKit PLATFORM_FRAMEWORKS += Cocoa PLATFORM_FRAMEWORKS += CoreVideo PLATFORM_FRAMEWORKS += AVFoundation PLATFORM_FRAMEWORKS += CoreMedia -PLATFORM_FRAMEWORKS += QuartzCore +# PLATFORM_FRAMEWORKS += QuartzCore PLATFORM_FRAMEWORKS += Security ifeq ($(USE_GST),1) From 2c9f061efcc344cf8d3e80532a2b2a673733e375 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 10 Aug 2022 00:20:32 -0300 Subject: [PATCH 02/91] some more --- examples/ios/moviePlayerExample/src/ofApp.mm | 10 +++++----- libs/openFrameworks/utils/ofFileUtils.cpp | 3 ++- libs/openFrameworks/utils/ofFileUtils.h | 10 +++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/examples/ios/moviePlayerExample/src/ofApp.mm b/examples/ios/moviePlayerExample/src/ofApp.mm index c137637a8f2..a8323df49f2 100644 --- a/examples/ios/moviePlayerExample/src/ofApp.mm +++ b/examples/ios/moviePlayerExample/src/ofApp.mm @@ -22,7 +22,7 @@ [ofxiOSGetGLParentView() addSubview:controls.view]; AVFoundationVideoPlayer * avVideoPlayer; - avVideoPlayer = (AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer(); + avVideoPlayer = (__bridge AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer(); [avVideoPlayer setVideoPosition:CGPointMake(0, 240)]; [ofxiOSGetGLParentView() insertSubview:avVideoPlayer.playerView belowSubview:controls.view]; avVideoPlayer.playerView.hidden = YES; @@ -127,7 +127,7 @@ video.play(); AVFoundationVideoPlayer * avVideoPlayer; - avVideoPlayer = (AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer(); + avVideoPlayer = (__bridge AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer(); [avVideoPlayer setVideoPosition:CGPointMake(0, 240)]; [ofxiOSGetGLParentView() insertSubview:avVideoPlayer.playerView belowSubview:controls.view]; avVideoPlayer.playerView.hidden = YES; @@ -151,12 +151,12 @@ } void ofApp::nativeOnPressed() { - [(AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer() playerView].hidden = NO; + [(__bridge AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer() playerView].hidden = NO; [controls setNative:YES]; } void ofApp::nativeOffPressed() { - [(AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer() playerView].hidden = YES; + [(__bridge AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer() playerView].hidden = YES; [controls setNative:NO]; } @@ -175,7 +175,7 @@ if(controls) { [controls.view removeFromSuperview]; controls.delegate = nil; - [controls release]; +// [controls release]; controls = nil; } } diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 5ee68554c32..7a878834ecb 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -1666,7 +1666,8 @@ string ofFilePath::addLeadingSlash(const fs::path& _path){ } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::addTrailingSlash(const fs::path& _path){ +//string ofFilePath::addTrailingSlash(const fs::path & _path){ +fs::path ofFilePath::addTrailingSlash(const fs::path & _path){ #if OF_USING_STD_FS && !OF_USE_EXPERIMENTAL_FS if(_path.string().empty()) return ""; return (fs::path(_path).make_preferred() / "").string(); diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index 053db73216b..08a475740d5 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -351,7 +351,7 @@ class ofFilePath{ /// /// \param path file or directory path /// \returns true if the path is an absolute path - static bool isAbsolute(fs::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 @@ -362,7 +362,7 @@ class ofFilePath{ /// are *not* in the data folder and want the direct path without relative /// "../../" /// \returns filename - static std::string getFileName(fs::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 @@ -370,7 +370,7 @@ class ofFilePath{ /// /// \param filePath file path /// \returns basename - static std::string getBaseName(fs::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 @@ -413,7 +413,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(fs::path& path1, fs::path& path2); + static std::string join(const fs::path& path1, const fs::path& path2); /// Get the full path to the application's executable file. /// @@ -448,7 +448,7 @@ class ofFilePath{ /// \param from starting path /// \param to destination path /// \returns relative path - static std::string makeRelative(fs::path & from, fs::path & to); + static std::string makeRelative(const fs::path & from, const fs::path & to); }; /// \class ofFile From 910f7d249feda8ef9cfdab505e7e10f227da3128 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 10 Aug 2022 08:56:30 -0300 Subject: [PATCH 03/91] ok finally --- .../graphics/ofCairoRenderer.cpp | 2 +- .../openFrameworks/graphics/ofCairoRenderer.h | 3 ++- .../graphics/ofTrueTypeFont.cpp | 8 +++--- .../sound/ofFmodSoundPlayer.cpp | 2 +- libs/openFrameworks/utils/ofFileUtils.cpp | 27 +++++++++++++------ libs/openFrameworks/utils/ofFileUtils.h | 2 +- 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/libs/openFrameworks/graphics/ofCairoRenderer.cpp b/libs/openFrameworks/graphics/ofCairoRenderer.cpp index b125d42807f..7464c859500 100644 --- a/libs/openFrameworks/graphics/ofCairoRenderer.cpp +++ b/libs/openFrameworks/graphics/ofCairoRenderer.cpp @@ -37,7 +37,7 @@ ofCairoRenderer::~ofCairoRenderer(){ close(); } -void ofCairoRenderer::setup(const string & _filename, Type _type, bool multiPage_, bool b3D_, ofRectangle outputsize){ +void ofCairoRenderer::setup(const std::string & _filename, Type _type, bool multiPage_, bool b3D_, ofRectangle outputsize){ if( outputsize.width == 0 || outputsize.height == 0 ){ outputsize.set(0, 0, ofGetViewportWidth(), ofGetViewportHeight()); } diff --git a/libs/openFrameworks/graphics/ofCairoRenderer.h b/libs/openFrameworks/graphics/ofCairoRenderer.h index 5576cb9aec2..560fc134f28 100644 --- a/libs/openFrameworks/graphics/ofCairoRenderer.h +++ b/libs/openFrameworks/graphics/ofCairoRenderer.h @@ -24,7 +24,8 @@ class ofCairoRenderer: public ofBaseRenderer{ IMAGE, FROM_FILE_EXTENSION }; - void setup(std::string filename, Type type=ofCairoRenderer::FROM_FILE_EXTENSION, bool multiPage=true, bool b3D=false, ofRectangle outputsize = ofRectangle(0,0,0,0)); + + void setup(const std::string & filename, Type type=ofCairoRenderer::FROM_FILE_EXTENSION, bool multiPage=true, bool b3D=false, ofRectangle outputsize = ofRectangle(0,0,0,0)); void setupMemoryOnly(Type _type, bool multiPage=true, bool b3D=false, ofRectangle viewport = ofRectangle(0,0,0,0)); void close(); void flush(); diff --git a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp index 083227acd52..07b7cd64be9 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp @@ -375,9 +375,8 @@ static std::string linuxFontPathByName(const std::string& fontname){ static bool loadFontFace(const fs::path& _fontname, FT_Face & face, fs::path & filename, int index){ fs::path fontname = _fontname; // makes no sense -// filename = ofToDataPath(_fontname,true); - auto fn = ofToDataPath(_fontname,true); - ofFile fontFile(fn,ofFile::Reference); + filename = ofToDataPath(_fontname, true); + ofFile fontFile(filename, ofFile::Reference); int fontID = index; if(!fontFile.exists()){ #ifdef TARGET_LINUX @@ -414,6 +413,9 @@ static bool loadFontFace(const fs::path& _fontname, FT_Face & face, fs::path & f } FT_Error err; err = FT_New_Face( library, filename.string().c_str(), fontID, &face ); + using std::cout, std::endl; + cout << "xxx" << endl; + cout << filename << endl; if (err) { // simple error table in lieu of full table (see fterrors.h) string errorString = "unknown freetype"; diff --git a/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp b/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp index bff1013be40..fdbea12a20c 100644 --- a/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp @@ -206,7 +206,7 @@ bool ofFmodSoundPlayer::load(const fs::path& _fileName, bool stream){ int fmodFlags = FMOD_DEFAULT; if(stream)fmodFlags = FMOD_DEFAULT | FMOD_CREATESTREAM; - result = FMOD_System_CreateSound(sys, fileName.data(), fmodFlags, nullptr, &sound); + result = FMOD_System_CreateSound(sys, fileName.string().data(), fmodFlags, nullptr, &sound); if (result != FMOD_OK){ bLoadedOk = false; diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 7a878834ecb..20530745c2e 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -611,7 +611,9 @@ bool ofFile::create(const fs::path & path){ auto oldpath = this->path(); success = open(path,ofFile::WriteOnly,binary); close(); - if( oldpath.length() ){ + + // FIXME: why length? + if( oldpath.string().length() ){ open(oldpath,oldmode,binary); } @@ -645,10 +647,15 @@ std::filebuf *ofFile::getFileBuffer() const { //------------------------------------------------------------------------------------------------------------ bool ofFile::exists() const { + using std::cout, std::endl; + cout << "ofFile::exists()" << endl; if(path().empty()){ + cout << "path empty" << path() << endl; return false; } + cout << "path " << path() << endl; + cout << (fs::exists(myFile) ? "exist" : "dont exist") << endl; return fs::exists(myFile); } @@ -1212,11 +1219,13 @@ fs::path ofDirectory::path() const { } //------------------------------------------------------------------------------------------------------------ -string ofDirectory::getAbsolutePath() const { +fs::path ofDirectory::getAbsolutePath() const { try{ - return fs::canonical(fs::absolute(myDir)).string(); +// return fs::canonical(fs::absolute(myDir)).string(); + return fs::canonical(fs::absolute(myDir)); }catch(...){ - return fs::absolute(myDir).string(); +// return fs::absolute(myDir).string(); + return fs::absolute(myDir); } } @@ -1742,10 +1751,11 @@ string ofFilePath::getBaseName(const fs::path& filePath){ //------------------------------------------------------------------------------------------------------------ fs::path ofFilePath::getEnclosingDirectory(const fs::path & _filePath, bool bRelativeToData){ // std::string filePath = _filePath.string(); + fs::path fp = _filePath; if(bRelativeToData){ - filePath = ofToDataPath(filePath); + fp = ofToDataPath(fp); } - return addTrailingSlash(_filePath.parent_path()); + return addTrailingSlash(fp.parent_path()); } //------------------------------------------------------------------------------------------------------------ @@ -1884,11 +1894,11 @@ void ofSetDataPathRoot(const fs::path& newRoot){ //-------------------------------------------------- fs::path ofToDataPath(const fs::path & path, bool makeAbsolute){ if (makeAbsolute && path.is_absolute()) { - return path.string(); + return path; } if (!enableDataPath) { - return path.string(); + return path; } bool hasTrailingSlash = !path.empty() && path.generic_string().back()=='/'; @@ -1928,6 +1938,7 @@ fs::path ofToDataPath(const fs::path & path, bool makeAbsolute){ // if the path begins with the full contents of dataPathRoot then the data path has already been added // we compare inputPath.toString() rather that the input var path to ensure common formatting against dataPath.toString() // auto dirDataPath = dataPath.string(); + auto dirDataPath = dataPath; // 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(dataPath); diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index 08a475740d5..c9c63ae5e73 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -486,7 +486,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(fs::path & path, Mode mode=ReadOnly, bool binary=true); +// ofFile(fs::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 From 554beb1d63845af5fc38b495a19555be452567b5 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 11 Aug 2022 20:19:29 -0300 Subject: [PATCH 04/91] update --- .../graphics/ofTrueTypeFont.cpp | 5 +- libs/openFrameworks/utils/ofConstants.h | 44 +++++++++-------- libs/openFrameworks/utils/ofFileUtils.cpp | 25 +++++----- .../project/osx/config.osx.default.mk | 47 +++---------------- .../project.pbxproj | 2 + 5 files changed, 48 insertions(+), 75 deletions(-) diff --git a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp index 07b7cd64be9..3f37cb6aca1 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp @@ -374,7 +374,7 @@ static std::string linuxFontPathByName(const std::string& fontname){ //----------------------------------------------------------- static bool loadFontFace(const fs::path& _fontname, FT_Face & face, fs::path & filename, int index){ fs::path fontname = _fontname; - // makes no sense + // FIXME: makes no sense: why have two fs::path parameters if they are the same? filename = ofToDataPath(_fontname, true); ofFile fontFile(filename, ofFile::Reference); int fontID = index; @@ -414,8 +414,7 @@ static bool loadFontFace(const fs::path& _fontname, FT_Face & face, fs::path & f FT_Error err; err = FT_New_Face( library, filename.string().c_str(), fontID, &face ); using std::cout, std::endl; - cout << "xxx" << endl; - cout << filename << endl; + if (err) { // simple error table in lieu of full table (see fterrors.h) string errorString = "unknown freetype"; diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index 1b967354073..52aa92793ce 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -500,8 +500,6 @@ std::unique_ptr make_unique(Args&&... args) { #endif #endif -#define OF_USING_STD_FS 1 - #if OF_USING_STD_FS #if OF_USE_EXPERIMENTAL_FS // C++17 experimental fs support @@ -546,25 +544,31 @@ std::unique_ptr make_unique(Args&&... args) { #define BOOST_NO_CXX11_SCOPED_ENUMS #define BOOST_NO_SCOPED_ENUMS #endif - #include - namespace boost { - namespace filesystem { - class path; - } - } - namespace std { - namespace filesystem = boost::filesystem; - } +// #include +// namespace boost { +// namespace filesystem { +// class path; +// } +// } +// namespace std { +// namespace filesystem = boost::filesystem; +// } #endif +#if defined __has_include + #if __has_include() + #include + namespace fs = std::__fs::filesystem; + #define OF_USING_STD_FS 1 + #elif __has_include() + #include + namespace fs = std::experimental::filesystem; + + #elif __has_include() + #include + namespace fs = boost::filesystem; -// namespace std::__fs::filesystem = std::filesystem; -// using std::filesystem; -// namespace std::filesystem = std::__fs::filesystem; -namespace fs = std::__fs::filesystem; -// using std::__fs::filesystem; -// namespace std::filesystem = std::__fs::filesystem; + #endif +#endif -// namespace std { - // namespace filesystem = __fs::filesystem; -// } +//namespace fs = std::__fs::filesystem; diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 20530745c2e..19ad245aac5 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -647,15 +647,16 @@ std::filebuf *ofFile::getFileBuffer() const { //------------------------------------------------------------------------------------------------------------ bool ofFile::exists() const { - using std::cout, std::endl; - cout << "ofFile::exists()" << endl; +// FIXME: remove comments +// using std::cout, std::endl; +// cout << "ofFile::exists()" << endl; if(path().empty()){ - cout << "path empty" << path() << endl; +// cout << "path empty" << path() << endl; return false; } - cout << "path " << path() << endl; - - cout << (fs::exists(myFile) ? "exist" : "dont exist") << endl; + +// cout << "path " << path() << endl; +// cout << (fs::exists(myFile) ? "exist" : "dont exist") << endl; return fs::exists(myFile); } @@ -717,11 +718,11 @@ bool ofFile::canRead() const { } #else if(geteuid() == info.st_uid){ - return perm & fs::owner_read; + return perm & fs::perms::owner_read; }else if (getegid() == info.st_gid){ - return perm & fs::group_read; + return perm & fs::perms::group_read; }else{ - return perm & fs::others_read; + return perm & fs::perms::others_read; } #endif #endif @@ -778,11 +779,11 @@ bool ofFile::canExecute() const { } #else if(geteuid() == info.st_uid){ - return perm & fs::owner_exe; + return perm & fs::perms::owner_exec; }else if (getegid() == info.st_gid){ - return perm & fs::group_exe; + return perm & fs::perms::group_exec; }else{ - return perm & fs::others_exe; + return perm & fs::perms::others_exec; } #endif #endif diff --git a/libs/openFrameworksCompiled/project/osx/config.osx.default.mk b/libs/openFrameworksCompiled/project/osx/config.osx.default.mk index 6c377355a97..fb50f03a635 100644 --- a/libs/openFrameworksCompiled/project/osx/config.osx.default.mk +++ b/libs/openFrameworksCompiled/project/osx/config.osx.default.mk @@ -248,19 +248,6 @@ ifeq ($(USE_FMOD),0) endif -# DIMITRE LITE -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/fmodex/% -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/rtAudio/% -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/video/% -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/sound/% -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/communication/% -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/3d/% - -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/json/% -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/boost/% -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/pugixml/% - - ########################################################################################## # PLATFORM HEADER SEARCH PATHS @@ -323,42 +310,22 @@ PLATFORM_LIBRARY_SEARCH_PATHS = # Note: Be sure to leave a leading space when using a += operator to add items to the list ########################################################################################## -# PLATFORM_FRAMEWORKS = -# PLATFORM_FRAMEWORKS += Accelerate -# PLATFORM_FRAMEWORKS += QTKit -# PLATFORM_FRAMEWORKS += AGL -# PLATFORM_FRAMEWORKS += ApplicationServices -# PLATFORM_FRAMEWORKS += AudioToolbox -# PLATFORM_FRAMEWORKS += CoreAudio -# PLATFORM_FRAMEWORKS += CoreFoundation -# PLATFORM_FRAMEWORKS += CoreServices -# PLATFORM_FRAMEWORKS += OpenGL -# PLATFORM_FRAMEWORKS += IOKit -# PLATFORM_FRAMEWORKS += Cocoa -# PLATFORM_FRAMEWORKS += CoreVideo -# PLATFORM_FRAMEWORKS += AVFoundation -# PLATFORM_FRAMEWORKS += CoreMedia -# PLATFORM_FRAMEWORKS += QuartzCore -# PLATFORM_FRAMEWORKS += Security - -# DIMITRE LITE - PLATFORM_FRAMEWORKS = PLATFORM_FRAMEWORKS += Accelerate -# PLATFORM_FRAMEWORKS += QTKit -# PLATFORM_FRAMEWORKS += AGL -# PLATFORM_FRAMEWORKS += ApplicationServices -# PLATFORM_FRAMEWORKS += AudioToolbox -# PLATFORM_FRAMEWORKS += CoreAudio +PLATFORM_FRAMEWORKS += QTKit +PLATFORM_FRAMEWORKS += AGL +PLATFORM_FRAMEWORKS += ApplicationServices +PLATFORM_FRAMEWORKS += AudioToolbox +PLATFORM_FRAMEWORKS += CoreAudio PLATFORM_FRAMEWORKS += CoreFoundation -# PLATFORM_FRAMEWORKS += CoreServices +PLATFORM_FRAMEWORKS += CoreServices PLATFORM_FRAMEWORKS += OpenGL PLATFORM_FRAMEWORKS += IOKit PLATFORM_FRAMEWORKS += Cocoa PLATFORM_FRAMEWORKS += CoreVideo PLATFORM_FRAMEWORKS += AVFoundation PLATFORM_FRAMEWORKS += CoreMedia -# PLATFORM_FRAMEWORKS += QuartzCore +PLATFORM_FRAMEWORKS += QuartzCore PLATFORM_FRAMEWORKS += Security ifeq ($(USE_GST),1) diff --git a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj index 21222d9b322..51f71bc6303 100644 --- a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj +++ b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj @@ -863,6 +863,7 @@ E4B27C1610CBEB8E00536013 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_X86_VECTOR_INSTRUCTIONS = default; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/osx/"; COPY_PHASE_STRIP = NO; @@ -890,6 +891,7 @@ E4B27C1710CBEB8E00536013 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_X86_VECTOR_INSTRUCTIONS = default; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/osx/"; COPY_PHASE_STRIP = YES; From 992b2d5d98f8709a415529db8b58e21ba37cd66d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 11 Aug 2022 20:44:14 -0300 Subject: [PATCH 05/91] of::filesystem --- libs/openFrameworks/3d/ofMesh.h | 4 +- libs/openFrameworks/3d/ofMesh.inl | 4 +- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 2 +- libs/openFrameworks/gl/ofShader.cpp | 14 +- libs/openFrameworks/gl/ofShader.h | 26 +- libs/openFrameworks/graphics/ofImage.cpp | 24 +- libs/openFrameworks/graphics/ofImage.h | 20 +- .../graphics/ofTrueTypeFont.cpp | 8 +- libs/openFrameworks/graphics/ofTrueTypeFont.h | 6 +- .../sound/ofFmodSoundPlayer.cpp | 2 +- libs/openFrameworks/sound/ofFmodSoundPlayer.h | 2 +- .../sound/ofOpenALSoundPlayer.cpp | 16 +- .../sound/ofOpenALSoundPlayer.h | 14 +- libs/openFrameworks/sound/ofSoundBaseTypes.h | 2 +- libs/openFrameworks/sound/ofSoundPlayer.cpp | 2 +- libs/openFrameworks/sound/ofSoundPlayer.h | 2 +- libs/openFrameworks/utils/ofConstants.h | 13 +- libs/openFrameworks/utils/ofFileUtils.cpp | 354 +++++++++--------- libs/openFrameworks/utils/ofFileUtils.h | 106 +++--- libs/openFrameworks/utils/ofJson.h | 6 +- libs/openFrameworks/utils/ofLog.cpp | 6 +- libs/openFrameworks/utils/ofLog.h | 6 +- libs/openFrameworks/utils/ofURLFileLoader.cpp | 16 +- libs/openFrameworks/utils/ofURLFileLoader.h | 12 +- libs/openFrameworks/utils/ofXml.cpp | 4 +- libs/openFrameworks/utils/ofXml.h | 4 +- .../project.pbxproj | 6 +- 27 files changed, 344 insertions(+), 337 deletions(-) diff --git a/libs/openFrameworks/3d/ofMesh.h b/libs/openFrameworks/3d/ofMesh.h index c5303682385..16798816b4b 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 fs::path& path); + void load(const of::filesystem::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 fs::path& path, bool useBinary = false) const; + void save(const of::filesystem::path& path, bool useBinary = false) const; /// \} diff --git a/libs/openFrameworks/3d/ofMesh.inl b/libs/openFrameworks/3d/ofMesh.inl index 3120163fcdc..de7bc7e6082 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 fs::path& path){ +void ofMesh_::load(const of::filesystem::path& path){ ofFile is = {path, ofFile::ReadOnly}; // ofFile is(path, ofFile::ReadOnly); // ofFile is(path); @@ -1273,7 +1273,7 @@ void ofMesh_::load(const fs::path& path){ //-------------------------------------------------------------- template -void ofMesh_::save(const fs::path& path, bool useBinary) const{ +void ofMesh_::save(const of::filesystem::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 bf61346e80b..0722eb0d24e 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] = fs::path(dropString[i]).string(); + drag.files[i] = of::filesystem::path(dropString[i]).string(); } instance->events().notifyDragEvent(drag); } diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index b3f55b90b46..2aa20d3a73f 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 fs::path& shaderName) { +bool ofShader::load(const of::filesystem::path& shaderName) { return load(shaderName.string() + ".vert", shaderName.string() + ".frag"); } //-------------------------------------------------------------- -bool ofShader::load(const fs::path& vertName, const fs::path& fragName, const fs::path& geomName) { +bool ofShader::load(const of::filesystem::path& vertName, const of::filesystem::path& fragName, const of::filesystem::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 fs::path& vertName, const fs::path& fragName, const fs #if !defined(TARGET_OPENGLES) && defined(glDispatchCompute) //-------------------------------------------------------------- -bool ofShader::loadCompute(const fs::path& shaderName) { +bool ofShader::loadCompute(const of::filesystem::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 fs::path & filename) { +bool ofShader::setupShaderFromFile(GLenum type, const of::filesystem::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 fs::path & filename) { } //-------------------------------------------------------------- -ofShader::Source ofShader::sourceFromFile(GLenum type, const fs::path& filename) { +ofShader::Source ofShader::sourceFromFile(GLenum type, const of::filesystem::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 fs::path& sourceDirectoryPath) { +string ofShader::parseForIncludes( const string& source, const of::filesystem::path& sourceDirectoryPath) { vector included; return parseForIncludes( source, included, 0, sourceDirectoryPath); } //-------------------------------------------------------------- -string ofShader::parseForIncludes( const string& source, vector& included, int level, const fs::path& sourceDirectoryPath) { +string ofShader::parseForIncludes( const string& source, vector& included, int level, const of::filesystem::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 d924197b7a1..937eb666ed0 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; - fs::path sourceDirectoryPath; + of::filesystem::path sourceDirectoryPath; bool bindDefaults = true; }; class ofShader { struct Source{ - Source(GLuint type, const std::string & source, const fs::path & directoryPath) + Source(GLuint type, const std::string & source, const of::filesystem::path & directoryPath) :type(type) ,source(source) ,directoryPath(directoryPath){} @@ -47,7 +47,7 @@ class ofShader { GLuint type; std::string source; std::string expandedSource; - fs::path directoryPath; + of::filesystem::path directoryPath; std::map intDefines; std::map floatDefines; }; @@ -60,20 +60,20 @@ class ofShader { ofShader(ofShader && shader); ofShader & operator=(ofShader && shader); - bool load(const fs::path& shaderName); - bool load(const fs::path& vertName, const fs::path& fragName, const fs::path& geomName=""); + bool load(const of::filesystem::path& shaderName); + bool load(const of::filesystem::path& vertName, const of::filesystem::path& fragName, const of::filesystem::path& geomName=""); #if !defined(TARGET_OPENGLES) && defined(glDispatchCompute) - bool loadCompute(const fs::path& shaderName); + bool loadCompute(const of::filesystem::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; - fs::path sourceDirectoryPath; + of::filesystem::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 fs::path& filename); + bool setupShaderFromFile(GLenum type, const of::filesystem::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 fs::path& filename); + ofShader::Source sourceFromFile(GLenum type, const of::filesystem::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 fs::path& sourceDirectoryPath = ""); - static std::string parseForIncludes( const std::string& source, std::vector& included, int level = 0, const fs::path& sourceDirectoryPath = ""); + static std::string parseForIncludes( const std::string& source, const of::filesystem::path& sourceDirectoryPath = ""); + static std::string parseForIncludes( const std::string& source, std::vector& included, int level = 0, const of::filesystem::path& sourceDirectoryPath = ""); void checkAndCreateProgram(); #ifdef TARGET_ANDROID diff --git a/libs/openFrameworks/graphics/ofImage.cpp b/libs/openFrameworks/graphics/ofImage.cpp index fcf54709d08..19cf1a150f8 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 fs::path& _fileName, const ofImageLoadSettings& settings){ +static bool loadImage(ofPixels_ & pix, const of::filesystem::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 fs::path& path, const ofImageLoadSettings &settings) { +bool ofLoadImage(ofPixels & pix, const of::filesystem::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 fs::path& path, const ofImageLoadSettings &settings) { +bool ofLoadImage(ofShortPixels & pix, const of::filesystem::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 fs::path& path, const ofImageLoadSettings &settings) { +bool ofLoadImage(ofFloatPixels & pix, const of::filesystem::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 fs::path& path, const ofImageLoadSettings &settings){ +bool ofLoadImage(ofTexture & tex, const of::filesystem::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 fs::path& _fileName, ofImageQualityType qualityLevel) { +static bool saveImage(const ofPixels_ & _pix, const of::filesystem::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 fs::path& _fileNa } //---------------------------------------------------------------- -bool ofSaveImage(const ofPixels & pix, const fs::path& fileName, ofImageQualityType qualityLevel){ +bool ofSaveImage(const ofPixels & pix, const of::filesystem::path& fileName, ofImageQualityType qualityLevel){ return saveImage(pix,fileName,qualityLevel); } //---------------------------------------------------------------- -bool ofSaveImage(const ofFloatPixels & pix, const fs::path& fileName, ofImageQualityType qualityLevel) { +bool ofSaveImage(const ofFloatPixels & pix, const of::filesystem::path& fileName, ofImageQualityType qualityLevel) { return saveImage(pix,fileName,qualityLevel); } //---------------------------------------------------------------- -bool ofSaveImage(const ofShortPixels & pix, const fs::path& fileName, ofImageQualityType qualityLevel) { +bool ofSaveImage(const ofShortPixels & pix, const of::filesystem::path& fileName, ofImageQualityType qualityLevel) { return saveImage(pix,fileName,qualityLevel); } @@ -603,7 +603,7 @@ ofImage_::ofImage_(const ofPixels_ & pix){ } template -ofImage_::ofImage_(const fs::path & fileName, const ofImageLoadSettings &settings){ +ofImage_::ofImage_(const of::filesystem::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 fs::path& fileName, const ofImageLoadSettings &settings){ +bool ofImage_::load(const of::filesystem::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 fs::path& fileName, ofImageQualityType qualityLevel) const { +bool ofImage_::save(const of::filesystem::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 1f3030d423d..e0267ce379e 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 fs::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); +bool ofLoadImage(ofPixels & pix, const of::filesystem::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); bool ofLoadImage(ofPixels & pix, const ofBuffer & buffer, const ofImageLoadSettings &settings = ofImageLoadSettings()); -bool ofLoadImage(ofFloatPixels & pix, const fs::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); +bool ofLoadImage(ofFloatPixels & pix, const of::filesystem::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); bool ofLoadImage(ofFloatPixels & pix, const ofBuffer & buffer, const ofImageLoadSettings &settings = ofImageLoadSettings()); -bool ofLoadImage(ofShortPixels & pix, const fs::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); +bool ofLoadImage(ofShortPixels & pix, const of::filesystem::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 fs::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings()); +bool ofLoadImage(ofTexture & tex, const of::filesystem::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 fs::path& path, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST); +bool ofSaveImage(const ofPixels & pix, const of::filesystem::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 fs::path& path, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST); +bool ofSaveImage(const ofFloatPixels & pix, const of::filesystem::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 fs::path& path, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST); +bool ofSaveImage(const ofShortPixels & pix, const of::filesystem::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 fs::path & fileName, const ofImageLoadSettings &settings = ofImageLoadSettings()); + ofImage_(const of::filesystem::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 fs::path& fileName, const ofImageLoadSettings &settings = ofImageLoadSettings()); + bool load(const of::filesystem::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 fs::path & fileName, ofImageQualityType compressionLevel = OF_IMAGE_QUALITY_BEST) const; + bool save(const of::filesystem::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 3f37cb6aca1..b0d9ec421b5 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp @@ -372,9 +372,9 @@ static std::string linuxFontPathByName(const std::string& fontname){ #endif //----------------------------------------------------------- -static bool loadFontFace(const fs::path& _fontname, FT_Face & face, fs::path & filename, int index){ - fs::path fontname = _fontname; - // FIXME: makes no sense: why have two fs::path parameters if they are the same? +static bool loadFontFace(const of::filesystem::path& _fontname, FT_Face & face, of::filesystem::path & filename, int index){ + of::filesystem::path fontname = _fontname; + // FIXME: makes no sense: why have two of::filesystem::path parameters if they are the same? filename = ofToDataPath(_fontname, true); ofFile fontFile(filename, ofFile::Reference); int fontID = index; @@ -698,7 +698,7 @@ ofTrueTypeFont::glyph ofTrueTypeFont::loadGlyph(uint32_t utf8) const{ } //----------------------------------------------------------- -bool ofTrueTypeFont::load(const fs::path& filename, int fontSize, bool antialiased, bool fullCharacterSet, bool makeContours, float simplifyAmt, int dpi) { +bool ofTrueTypeFont::load(const of::filesystem::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 e3fdfb018b6..f6e08f02df0 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.h +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.h @@ -138,7 +138,7 @@ enum ofTrueTypeFontDirection : uint32_t { struct ofTrueTypeFontSettings{ - fs::path fontName; + of::filesystem::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 fs::path & name, int size) + ofTrueTypeFontSettings(const of::filesystem::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 fs::path& filename, + bool load(const of::filesystem::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 fdbea12a20c..d36148f6cc0 100644 --- a/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp @@ -177,7 +177,7 @@ void ofFmodSoundPlayer::closeFmod(){ } //------------------------------------------------------------ -bool ofFmodSoundPlayer::load(const fs::path& _fileName, bool stream){ +bool ofFmodSoundPlayer::load(const of::filesystem::path& _fileName, bool stream){ auto fileName = ofToDataPath(_fileName); diff --git a/libs/openFrameworks/sound/ofFmodSoundPlayer.h b/libs/openFrameworks/sound/ofFmodSoundPlayer.h index e787f6bed04..838a0c23127 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 fs::path& fileName, bool stream = false); + bool load(const of::filesystem::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 caa12563c3c..64881987980 100644 --- a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp @@ -229,7 +229,7 @@ void ofOpenALSoundPlayer::close(){ } // ---------------------------------------------------------------------------- -bool ofOpenALSoundPlayer::sfReadFile(const fs::path& path, std::vector & buffer, std::vector & fftAuxBuffer){ +bool ofOpenALSoundPlayer::sfReadFile(const of::filesystem::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 fs::path& path, std::vector & #ifdef OF_USING_MPG123 //------------------------------------------------------------ -bool ofOpenALSoundPlayer::mpg123ReadFile(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer){ +bool ofOpenALSoundPlayer::mpg123ReadFile(const of::filesystem::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 fs::path& path,std::vector #endif //------------------------------------------------------------ -bool ofOpenALSoundPlayer::sfStream(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer){ +bool ofOpenALSoundPlayer::sfStream(const of::filesystem::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 fs::path& path,std::vector & buf #ifdef OF_USING_MPG123 //------------------------------------------------------------ -bool ofOpenALSoundPlayer::mpg123Stream(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer){ +bool ofOpenALSoundPlayer::mpg123Stream(const of::filesystem::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 fs::path& path,std::vector & #endif //------------------------------------------------------------ -bool ofOpenALSoundPlayer::stream(const fs::path& fileName, std::vector & buffer){ +bool ofOpenALSoundPlayer::stream(const of::filesystem::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 fs::path& fileName, std::vector & return true; } -bool ofOpenALSoundPlayer::readFile(const fs::path& fileName, std::vector & buffer){ +bool ofOpenALSoundPlayer::readFile(const of::filesystem::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 fs::path& fileName, std::vector } //------------------------------------------------------------ -bool ofOpenALSoundPlayer::load(const fs::path& _fileName, bool is_stream){ +bool ofOpenALSoundPlayer::load(const of::filesystem::path& _fileName, bool is_stream){ - fs::path fileName = ofToDataPath(_fileName); + of::filesystem::path fileName = ofToDataPath(_fileName); bMultiPlay = false; isStreaming = is_stream; diff --git a/libs/openFrameworks/sound/ofOpenALSoundPlayer.h b/libs/openFrameworks/sound/ofOpenALSoundPlayer.h index b10af783425..7a36b77e217 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 fs::path& fileName, bool stream = false); + bool load(const of::filesystem::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 fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer); - bool sfStream(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer); + bool sfReadFile(const of::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer); + bool sfStream(const of::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer); #ifdef OF_USING_MPG123 - bool mpg123ReadFile(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer); - bool mpg123Stream(const fs::path& path,std::vector & buffer,std::vector & fftAuxBuffer); + bool mpg123ReadFile(const of::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer); + bool mpg123Stream(const of::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer); #endif - bool readFile(const fs::path& fileName,std::vector & buffer); - bool stream(const fs::path& fileName, std::vector & buffer); + bool readFile(const of::filesystem::path& fileName,std::vector & buffer); + bool stream(const of::filesystem::path& fileName, std::vector & buffer); bool isStreaming; bool bMultiPlay; diff --git a/libs/openFrameworks/sound/ofSoundBaseTypes.h b/libs/openFrameworks/sound/ofSoundBaseTypes.h index 405cf280fed..7271abf3f78 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 fs::path& fileName, bool stream = false)=0; + virtual bool load(const of::filesystem::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 4bbe7ba4a3c..ad9e95dde47 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 fs::path& fileName, bool stream){ +bool ofSoundPlayer::load(const of::filesystem::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 168d3e9b1fb..5f04073d1d6 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 fs::path& fileName, bool stream = false); + bool load(const of::filesystem::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 52aa92793ce..08a7f78a76c 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -558,17 +558,22 @@ std::unique_ptr make_unique(Args&&... args) { #if defined __has_include #if __has_include() #include - namespace fs = std::__fs::filesystem; +namespace of{ + namespace filesystem = std::__fs::filesystem; +} #define OF_USING_STD_FS 1 #elif __has_include() #include - namespace fs = std::experimental::filesystem; +namespace of{ + namespace filesystem = std::experimental::filesystem; +} #elif __has_include() #include - namespace fs = boost::filesystem; +namespace of{ + namespace filesystem = boost::filesystem; +} #endif #endif -//namespace fs = std::__fs::filesystem; diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 19ad245aac5..86e899d548c 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -31,8 +31,8 @@ namespace{ return ofFilePath::getCurrentExeDir() / "../../../data/"; // try{ // return ofFilePath::getCurrentExeDir() / "../../../data/"; -//// return fs::canonical(ofFilePath::getCurrentExeDir() / "../../../data/"); -//// return fs::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../data/")).string(); +//// return of::filesystem::canonical(ofFilePath::getCurrentExeDir() / "../../../data/"); +//// return of::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../data/")).string(); // }catch(...){ // return ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../data/"); // } @@ -40,7 +40,7 @@ namespace{ return string("sdcard/"); #else try{ - return fs::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); + return of::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); }catch(...){ return ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/"); } @@ -48,14 +48,14 @@ namespace{ } //-------------------------------------------------- - fs::path & defaultWorkingDirectory(){ - static auto * defaultWorkingDirectory = new fs::path(ofFilePath::getCurrentExeDir()); + of::filesystem::path & defaultWorkingDirectory(){ + static auto * defaultWorkingDirectory = new of::filesystem::path(ofFilePath::getCurrentExeDir()); return * defaultWorkingDirectory; } //-------------------------------------------------- - fs::path & dataPathRoot(){ - static auto * dataPathRoot = new fs::path(defaultDataPath()); + of::filesystem::path & dataPathRoot(){ + static auto * dataPathRoot = new of::filesystem::path(defaultDataPath()); return *dataPathRoot; } } @@ -63,7 +63,7 @@ namespace{ namespace of{ namespace priv{ void initfileutils(){ - defaultWorkingDirectory() = fs::absolute(fs::current_path()); + defaultWorkingDirectory() = of::filesystem::absolute(of::filesystem::current_path()); } } } @@ -453,13 +453,13 @@ istream & operator>>(istream & istr, ofBuffer & buf){ } //-------------------------------------------------- -ofBuffer ofBufferFromFile(const fs::path & path, bool binary){ +ofBuffer ofBufferFromFile(const of::filesystem::path & path, bool binary){ ofFile f(path,ofFile::ReadOnly, binary); return ofBuffer(f); } //-------------------------------------------------- -bool ofBufferToFile(const fs::path & path, const ofBuffer& buffer, bool binary){ +bool ofBufferToFile(const of::filesystem::path & path, const ofBuffer& buffer, bool binary){ ofFile f(path, ofFile::WriteOnly, binary); return buffer.writeTo(f); } @@ -476,7 +476,7 @@ ofFile::ofFile() ,binary(true){ } -ofFile::ofFile(const fs::path & path, Mode mode, bool binary) +ofFile::ofFile(const of::filesystem::path & path, Mode mode, bool binary) :mode(mode) ,binary(true){ open(path, mode, binary); @@ -560,16 +560,16 @@ bool ofFile::openStream(Mode _mode, bool _binary){ } //------------------------------------------------------------------------------------------------------------ -bool ofFile::open(const fs::path & _path, Mode _mode, bool binary){ +bool ofFile::open(const of::filesystem::path & _path, Mode _mode, bool binary){ close(); myFile = ofToDataPath(_path); return openStream(_mode, binary); } //------------------------------------------------------------------------------------------------------------ -bool ofFile::openFromCWD(const fs::path & _path, Mode _mode, bool binary){ +bool ofFile::openFromCWD(const of::filesystem::path & _path, Mode _mode, bool binary){ close(); -// myFile = fs::path(_path.string()); +// myFile = of::filesystem::path(_path.string()); myFile = _path; return openStream(_mode, binary); } @@ -579,7 +579,7 @@ bool ofFile::changeMode(Mode _mode, bool binary){ if(_mode != mode){ string _path = path(); close(); - myFile = fs::path(_path); + myFile = of::filesystem::path(_path); return openStream(_mode, binary); } else{ @@ -594,7 +594,7 @@ bool ofFile::isWriteMode(){ //------------------------------------------------------------------------------------------------------------- void ofFile::close(){ - myFile = fs::path(); + myFile = of::filesystem::path(); if(mode!=Reference) fstream::close(); } @@ -604,7 +604,7 @@ bool ofFile::create(){ } //------------------------------------------------------------------------------------------------------------ -bool ofFile::create(const fs::path & path){ +bool ofFile::create(const of::filesystem::path & path){ bool success = false; auto oldmode = this->mode; @@ -622,7 +622,7 @@ bool ofFile::create(const fs::path & path){ //------------------------------------------------------------------------------------------------------------ ofBuffer ofFile::readToBuffer(){ - if(myFile.string().empty() || !fs::exists(myFile)){ + if(myFile.string().empty() || !of::filesystem::exists(myFile)){ return ofBuffer(); } @@ -656,12 +656,12 @@ bool ofFile::exists() const { } // cout << "path " << path() << endl; -// cout << (fs::exists(myFile) ? "exist" : "dont exist") << endl; - return fs::exists(myFile); +// cout << (of::filesystem::exists(myFile) ? "exist" : "dont exist") << endl; + return of::filesystem::exists(myFile); } //------------------------------------------------------------------------------------------------------------ -fs::path ofFile::path() const { +of::filesystem::path ofFile::path() const { return myFile; } @@ -686,18 +686,18 @@ string ofFile::getBaseName() const { } //------------------------------------------------------------------------------------------------------------ -fs::path ofFile::getEnclosingDirectory() const { +of::filesystem::path ofFile::getEnclosingDirectory() const { return ofFilePath::getEnclosingDirectory(path()); } //------------------------------------------------------------------------------------------------------------ -fs::path ofFile::getAbsolutePath() const { +of::filesystem::path ofFile::getAbsolutePath() const { return ofFilePath::getAbsolutePath(path()); } //------------------------------------------------------------------------------------------------------------ bool ofFile::canRead() const { - auto perm = fs::status(myFile).permissions(); + auto perm = of::filesystem::status(myFile).permissions(); #ifdef TARGET_WIN32 DWORD attr = GetFileAttributes(myFile.native().c_str()); if (attr == INVALID_FILE_ATTRIBUTES) @@ -710,19 +710,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 & fs::perms::owner_read) != fs::perms::none; + return (perm & of::filesystem::perms::owner_read) != of::filesystem::perms::none; }else if (getegid() == info.st_gid){ - return (perm & fs::perms::group_read) != fs::perms::none; + return (perm & of::filesystem::perms::group_read) != of::filesystem::perms::none; }else{ - return (perm & fs::perms::others_read) != fs::perms::none; + return (perm & of::filesystem::perms::others_read) != of::filesystem::perms::none; } #else if(geteuid() == info.st_uid){ - return perm & fs::perms::owner_read; + return perm & of::filesystem::perms::owner_read; }else if (getegid() == info.st_gid){ - return perm & fs::perms::group_read; + return perm & of::filesystem::perms::group_read; }else{ - return perm & fs::perms::others_read; + return perm & of::filesystem::perms::others_read; } #endif #endif @@ -730,7 +730,7 @@ bool ofFile::canRead() const { //------------------------------------------------------------------------------------------------------------ bool ofFile::canWrite() const { - auto perm = fs::status(myFile).permissions(); + auto perm = of::filesystem::status(myFile).permissions(); #ifdef TARGET_WIN32 DWORD attr = GetFileAttributes(myFile.native().c_str()); if (attr == INVALID_FILE_ATTRIBUTES){ @@ -743,19 +743,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 & fs::perms::owner_write) != fs::perms::none; + return (perm & of::filesystem::perms::owner_write) != of::filesystem::perms::none; }else if (getegid() == info.st_gid){ - return (perm & fs::perms::group_write) != fs::perms::none; + return (perm & of::filesystem::perms::group_write) != of::filesystem::perms::none; }else{ - return (perm & fs::perms::others_write) != fs::perms::none; + return (perm & of::filesystem::perms::others_write) != of::filesystem::perms::none; } #else if(geteuid() == info.st_uid){ - return perm & fs::owner_write; + return perm & of::filesystem::owner_write; }else if (getegid() == info.st_gid){ - return perm & fs::group_write; + return perm & of::filesystem::group_write; }else{ - return perm & fs::others_write; + return perm & of::filesystem::others_write; } #endif #endif @@ -763,7 +763,7 @@ bool ofFile::canWrite() const { //------------------------------------------------------------------------------------------------------------ bool ofFile::canExecute() const { - auto perm = fs::status(myFile).permissions(); + auto perm = of::filesystem::status(myFile).permissions(); #ifdef TARGET_WIN32 return getExtension() == "exe"; #else @@ -771,19 +771,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 & fs::perms::owner_exec) != fs::perms::none; + return (perm & of::filesystem::perms::owner_exec) != of::filesystem::perms::none; }else if (getegid() == info.st_gid){ - return (perm & fs::perms::group_exec) != fs::perms::none; + return (perm & of::filesystem::perms::group_exec) != of::filesystem::perms::none; }else{ - return (perm & fs::perms::others_exec) != fs::perms::none; + return (perm & of::filesystem::perms::others_exec) != of::filesystem::perms::none; } #else if(geteuid() == info.st_uid){ - return perm & fs::perms::owner_exec; + return perm & of::filesystem::perms::owner_exec; }else if (getegid() == info.st_gid){ - return perm & fs::perms::group_exec; + return perm & of::filesystem::perms::group_exec; }else{ - return perm & fs::perms::others_exec; + return perm & of::filesystem::perms::others_exec; } #endif #endif @@ -791,17 +791,17 @@ bool ofFile::canExecute() const { //------------------------------------------------------------------------------------------------------------ bool ofFile::isFile() const { - return fs::is_regular_file(myFile); + return of::filesystem::is_regular_file(myFile); } //------------------------------------------------------------------------------------------------------------ bool ofFile::isLink() const { - return fs::is_symlink(myFile); + return of::filesystem::is_symlink(myFile); } //------------------------------------------------------------------------------------------------------------ bool ofFile::isDirectory() const { - return fs::is_directory(myFile); + return of::filesystem::is_directory(myFile); } //------------------------------------------------------------------------------------------------------------ @@ -810,9 +810,9 @@ bool ofFile::isDevice() const { return false; #else #if OF_USING_STD_FS - return fs::is_block_file(fs::status(myFile)); + return of::filesystem::is_block_file(of::filesystem::status(myFile)); #else - return fs::status(myFile).type() == fs::block_file; + return of::filesystem::status(myFile).type() == of::filesystem::block_file; #endif #endif } @@ -831,19 +831,19 @@ void ofFile::setWriteable(bool flag){ try{ #if !OF_USING_STD_FS || (OF_USING_STD_FS && OF_USE_EXPERIMENTAL_FS) if(flag){ - fs::permissions(myFile,fs::perms::owner_write | fs::perms::add_perms); + of::filesystem::permissions(myFile,of::filesystem::perms::owner_write | of::filesystem::perms::add_perms); }else{ - fs::permissions(myFile,fs::perms::owner_write | fs::perms::remove_perms); + of::filesystem::permissions(myFile,of::filesystem::perms::owner_write | of::filesystem::perms::remove_perms); } #else if(flag){ - fs::permissions(myFile, - fs::perms::owner_write, - fs::perm_options::add); + of::filesystem::permissions(myFile, + of::filesystem::perms::owner_write, + of::filesystem::perm_options::add); }else{ - fs::permissions(myFile, - fs::perms::owner_write, - fs::perm_options::remove); + of::filesystem::permissions(myFile, + of::filesystem::perms::owner_write, + of::filesystem::perm_options::remove); } #endif }catch(std::exception & e){ @@ -862,19 +862,19 @@ void ofFile::setReadable(bool flag){ try{ #if !OF_USING_STD_FS || (OF_USING_STD_FS && OF_USE_EXPERIMENTAL_FS) if(flag){ - fs::permissions(myFile,fs::perms::owner_read | fs::perms::add_perms); + of::filesystem::permissions(myFile,of::filesystem::perms::owner_read | of::filesystem::perms::add_perms); }else{ - fs::permissions(myFile,fs::perms::owner_read | fs::perms::remove_perms); + of::filesystem::permissions(myFile,of::filesystem::perms::owner_read | of::filesystem::perms::remove_perms); } #else if(flag){ - fs::permissions(myFile, - fs::perms::owner_read, - fs::perm_options::add); + of::filesystem::permissions(myFile, + of::filesystem::perms::owner_read, + of::filesystem::perm_options::add); }else{ - fs::permissions(myFile, - fs::perms::owner_read, - fs::perm_options::remove); + of::filesystem::permissions(myFile, + of::filesystem::perms::owner_read, + of::filesystem::perm_options::remove); } #endif }catch(std::exception & e){ @@ -888,26 +888,26 @@ void ofFile::setExecutable(bool flag){ #if OF_USING_STD_FS # if OF_USE_EXPERIMENTAL_FS if(flag){ - fs::permissions(myFile, fs::perms::owner_exec | fs::perms::add_perms); + of::filesystem::permissions(myFile, of::filesystem::perms::owner_exec | of::filesystem::perms::add_perms); } else{ - fs::permissions(myFile, fs::perms::owner_exec | fs::perms::remove_perms); + of::filesystem::permissions(myFile, of::filesystem::perms::owner_exec | of::filesystem::perms::remove_perms); } # else if(flag){ - fs::permissions(myFile, - fs::perms::owner_exec, - fs::perm_options::add); + of::filesystem::permissions(myFile, + of::filesystem::perms::owner_exec, + of::filesystem::perm_options::add); } else{ - fs::permissions(myFile, - fs::perms::owner_exec, - fs::perm_options::remove); + of::filesystem::permissions(myFile, + of::filesystem::perms::owner_exec, + of::filesystem::perm_options::remove); } # endif #else if(flag){ - fs::permissions(myFile, fs::perms::owner_exe | fs::perms::add_perms); + of::filesystem::permissions(myFile, of::filesystem::perms::owner_exe | of::filesystem::perms::add_perms); } else{ - fs::permissions(myFile, fs::perms::owner_exe | fs::perms::remove_perms); + of::filesystem::permissions(myFile, of::filesystem::perms::owner_exe | of::filesystem::perms::remove_perms); } #endif }catch(std::exception & e){ @@ -916,7 +916,7 @@ void ofFile::setExecutable(bool flag){ } //------------------------------------------------------------------------------------------------------------ -bool ofFile::copyTo(const fs::path& _path, bool bRelativeToData, bool overwrite) const{ +bool ofFile::copyTo(const of::filesystem::path& _path, bool bRelativeToData, bool overwrite) const{ auto path = _path; if(path.empty()){ @@ -964,7 +964,7 @@ bool ofFile::copyTo(const fs::path& _path, bool bRelativeToData, bool overwrite) if(!destDir.exists()){ ofFilePath::createEnclosingDirectory(path, false); } - fs::copy_file(myFile,path); + of::filesystem::copy_file(myFile,path); }catch(std::exception & except){ ofLogError("ofFile") << "copyTo(): unable to copy \"" << path << "\":" << except.what(); return false; @@ -974,7 +974,7 @@ bool ofFile::copyTo(const fs::path& _path, bool bRelativeToData, bool overwrite) } //------------------------------------------------------------------------------------------------------------ -bool ofFile::moveTo(const fs::path& _path, bool bRelativeToData, bool overwrite){ +bool ofFile::moveTo(const of::filesystem::path& _path, bool bRelativeToData, bool overwrite){ auto path = _path; if(path.empty()){ @@ -1017,7 +1017,7 @@ bool ofFile::moveTo(const fs::path& _path, bool bRelativeToData, bool overwrite) if(!destDir.exists()){ ofFilePath::createEnclosingDirectory(path,false); } - fs::rename(myFile,path); + of::filesystem::rename(myFile,path); myFile = path; if(mode != ofFile::Reference){ changeMode(mode, binary); @@ -1032,7 +1032,7 @@ bool ofFile::moveTo(const fs::path& _path, bool bRelativeToData, bool overwrite) } //------------------------------------------------------------------------------------------------------------ -bool ofFile::renameTo(const fs::path& path, bool bRelativeToData, bool overwrite){ +bool ofFile::renameTo(const of::filesystem::path& path, bool bRelativeToData, bool overwrite){ return moveTo(path,bRelativeToData,overwrite); } @@ -1052,9 +1052,9 @@ bool ofFile::remove(bool recursive){ open(path(),Reference,binary); } if(recursive){ - fs::remove_all(myFile); + of::filesystem::remove_all(myFile); }else{ - fs::remove(myFile); + of::filesystem::remove(myFile); } }catch(std::exception & except){ ofLogError("ofFile") << "remove(): unable to remove \"" << myFile << "\": " << except.what(); @@ -1067,7 +1067,7 @@ bool ofFile::remove(bool recursive){ //------------------------------------------------------------------------------------------------------------ uint64_t ofFile::getSize() const { try{ - return fs::file_size(myFile); + return of::filesystem::file_size(myFile); }catch(std::exception & except){ ofLogError("ofFile") << "getSize(): unable to get size of \"" << myFile << "\": " << except.what(); return 0; @@ -1108,7 +1108,7 @@ bool ofFile::operator>=(const ofFile & file) const { // ofFile Static Methods //------------------------------------------------------------------------------------------------------------ -bool ofFile::copyFromTo(const fs::path& pathSrc, const fs::path& pathDst, bool bRelativeToData, bool overwrite){ +bool ofFile::copyFromTo(const of::filesystem::path& pathSrc, const of::filesystem::path& pathDst, bool bRelativeToData, bool overwrite){ ofFile tmp; if( bRelativeToData ){ tmp.open(pathSrc,ofFile::Reference); @@ -1120,7 +1120,7 @@ bool ofFile::copyFromTo(const fs::path& pathSrc, const fs::path& pathDst, bool b //be careful with slashes here - appending a slash when moving a folder will causes mad headaches //------------------------------------------------------------------------------------------------------------ -bool ofFile::moveFromTo(const fs::path& pathSrc, const fs::path& pathDst, bool bRelativeToData, bool overwrite){ +bool ofFile::moveFromTo(const of::filesystem::path& pathSrc, const of::filesystem::path& pathDst, bool bRelativeToData, bool overwrite){ ofFile tmp; if( bRelativeToData ){ tmp.open(pathSrc,ofFile::Reference); @@ -1131,7 +1131,7 @@ bool ofFile::moveFromTo(const fs::path& pathSrc, const fs::path& pathDst, bool b } //------------------------------------------------------------------------------------------------------------ -bool ofFile::doesFileExist(const fs::path& _fPath, bool bRelativeToData){ +bool ofFile::doesFileExist(const of::filesystem::path& _fPath, bool bRelativeToData){ ofFile tmp; if(bRelativeToData){ tmp.open(_fPath,ofFile::Reference); @@ -1142,7 +1142,7 @@ bool ofFile::doesFileExist(const fs::path& _fPath, bool bRelativeToData){ } //------------------------------------------------------------------------------------------------------------ -bool ofFile::removeFile(const fs::path& _path, bool bRelativeToData){ +bool ofFile::removeFile(const of::filesystem::path& _path, bool bRelativeToData){ ofFile tmp; if(bRelativeToData){ tmp.open(_path,ofFile::Reference); @@ -1165,28 +1165,28 @@ ofDirectory::ofDirectory(){ } //------------------------------------------------------------------------------------------------------------ -ofDirectory::ofDirectory(const fs::path & path){ +ofDirectory::ofDirectory(const of::filesystem::path & path){ showHidden = false; open(path); } //------------------------------------------------------------------------------------------------------------ -void ofDirectory::open(const fs::path & path){ +void ofDirectory::open(const of::filesystem::path & path){ originalDirectory = ofFilePath::getPathForDirectory(path.string()); files.clear(); - myDir = fs::path(ofToDataPath(originalDirectory)); + myDir = of::filesystem::path(ofToDataPath(originalDirectory)); } //------------------------------------------------------------------------------------------------------------ -void ofDirectory::openFromCWD(const fs::path & path){ +void ofDirectory::openFromCWD(const of::filesystem::path & path){ originalDirectory = ofFilePath::getPathForDirectory(path.string()); files.clear(); - myDir = fs::path(originalDirectory); + myDir = of::filesystem::path(originalDirectory); } //------------------------------------------------------------------------------------------------------------ void ofDirectory::close(){ - myDir = fs::path(); + myDir = of::filesystem::path(); } //------------------------------------------------------------------------------------------------------------ @@ -1195,9 +1195,9 @@ bool ofDirectory::create(bool recursive){ if(!myDir.string().empty()){ try{ if(recursive){ - fs::create_directories(myDir); + of::filesystem::create_directories(myDir); }else{ - fs::create_directory(myDir); + of::filesystem::create_directory(myDir); } } catch(std::exception & except){ @@ -1211,22 +1211,22 @@ bool ofDirectory::create(bool recursive){ //------------------------------------------------------------------------------------------------------------ bool ofDirectory::exists() const { - return (myDir == "" || fs::exists(myDir)); + return (myDir == "" || of::filesystem::exists(myDir)); } //------------------------------------------------------------------------------------------------------------ -fs::path ofDirectory::path() const { +of::filesystem::path ofDirectory::path() const { return myDir; } //------------------------------------------------------------------------------------------------------------ -fs::path ofDirectory::getAbsolutePath() const { +of::filesystem::path ofDirectory::getAbsolutePath() const { try{ -// return fs::canonical(fs::absolute(myDir)).string(); - return fs::canonical(fs::absolute(myDir)); +// return of::filesystem::canonical(of::filesystem::absolute(myDir)).string(); + return of::filesystem::canonical(of::filesystem::absolute(myDir)); }catch(...){ -// return fs::absolute(myDir).string(); - return fs::absolute(myDir); +// return of::filesystem::absolute(myDir).string(); + return of::filesystem::absolute(myDir); } } @@ -1278,22 +1278,22 @@ void ofDirectory::setShowHidden(bool showHidden){ //------------------------------------------------------------------------------------------------------------ bool ofDirectory::isDirectory() const { - return fs::is_directory(myDir); + return of::filesystem::is_directory(myDir); } //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::copyTo(const fs::path& _path, bool bRelativeToData, bool overwrite){ +bool ofDirectory::copyTo(const of::filesystem::path& _path, bool bRelativeToData, bool overwrite){ auto path = _path; if(myDir.string().empty()){ ofLogError("ofDirectory") << "copyTo(): source path is empty"; return false; } - if(!fs::exists(myDir)){ + if(!of::filesystem::exists(myDir)){ ofLogError("ofDirectory") << "copyTo(): source directory does not exist"; return false; } - if(!fs::is_directory(myDir)){ + if(!of::filesystem::is_directory(myDir)){ ofLogError("ofDirectory") << "copyTo(): source path is not a directory"; return false; } @@ -1317,10 +1317,10 @@ bool ofDirectory::copyTo(const fs::path& _path, bool bRelativeToData, bool overw dir.create(true); // Iterate through the source directory - 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)){ + for(of::filesystem::directory_iterator file(myDir); file != of::filesystem::directory_iterator(); ++file){ + auto currentPath = of::filesystem::absolute(file->path()); + auto dst = of::filesystem::path(path) / currentPath.filename(); + if(of::filesystem::is_directory(currentPath)){ ofDirectory current(currentPath); // Found directory: Recursion if(!current.copyTo(dst,false,overwrite)){ @@ -1337,7 +1337,7 @@ bool ofDirectory::copyTo(const fs::path& _path, bool bRelativeToData, bool overw } //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::moveTo(const fs::path& path, bool bRelativeToData, bool overwrite){ +bool ofDirectory::moveTo(const of::filesystem::path& path, bool bRelativeToData, bool overwrite){ if(copyTo(path,bRelativeToData,overwrite)){ return remove(true); } @@ -1346,21 +1346,21 @@ bool ofDirectory::moveTo(const fs::path& path, bool bRelativeToData, bool overwr } //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::renameTo(const fs::path& path, bool bRelativeToData, bool overwrite){ +bool ofDirectory::renameTo(const of::filesystem::path& path, bool bRelativeToData, bool overwrite){ return moveTo(path, bRelativeToData, overwrite); } //------------------------------------------------------------------------------------------------------------ bool ofDirectory::remove(bool recursive){ - if(path().empty() || !fs::exists(myDir)){ + if(path().empty() || !of::filesystem::exists(myDir)){ return false; } try{ if(recursive){ - fs::remove_all(fs::canonical(myDir)); + of::filesystem::remove_all(of::filesystem::canonical(myDir)); }else{ - fs::remove(fs::canonical(myDir)); + of::filesystem::remove(of::filesystem::canonical(myDir)); } }catch(std::exception & except){ ofLogError("ofDirectory") << "remove(): unable to remove file/directory: " << except.what(); @@ -1391,14 +1391,14 @@ std::size_t ofDirectory::listDir(){ ofLogError("ofDirectory") << "listDir(): directory path is empty"; return 0; } - if(!fs::exists(myDir)){ + if(!of::filesystem::exists(myDir)){ ofLogError("ofDirectory") << "listDir:() source directory does not exist: \"" << myDir << "\""; return 0; } - 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){ + of::filesystem::directory_iterator end_iter; + if ( of::filesystem::exists(myDir) && of::filesystem::is_directory(myDir)){ + for( of::filesystem::directory_iterator dir_iter(myDir) ; dir_iter != end_iter ; ++dir_iter){ files.emplace_back(dir_iter->path().string(), ofFile::Reference); } }else{ @@ -1486,8 +1486,8 @@ static bool natural(const ofFile& a, const ofFile& b) { //------------------------------------------------------------------------------------------------------------ static bool byDate(const ofFile& a, const ofFile& b) { - auto ta = fs::last_write_time(a); - auto tb = fs::last_write_time(b); + auto ta = of::filesystem::last_write_time(a); + auto tb = of::filesystem::last_write_time(b); return ta < tb; } @@ -1530,7 +1530,7 @@ int ofDirectory::numFiles(){ //------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::removeDirectory(const fs::path& _path, bool deleteIfNotEmpty, bool bRelativeToData){ +bool ofDirectory::removeDirectory(const of::filesystem::path& _path, bool deleteIfNotEmpty, bool bRelativeToData){ auto path = _path; ofFile dirToRemove; @@ -1544,14 +1544,14 @@ bool ofDirectory::removeDirectory(const fs::path& _path, bool deleteIfNotEmpty, } //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::createDirectory(const fs::path& _dirPath, bool bRelativeToData, bool recursive){ +bool ofDirectory::createDirectory(const of::filesystem::path& _dirPath, bool bRelativeToData, bool recursive){ auto dirPath = _dirPath; if(bRelativeToData){ dirPath = ofToDataPath(dirPath); } - // on OSX,fs::create_directories seems to return false *if* the path has folders that already exist + // on OSX,of::filesystem::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: @@ -1562,9 +1562,9 @@ bool ofDirectory::createDirectory(const fs::path& _dirPath, bool bRelativeToData bool success = false; try{ if(!recursive){ - success = fs::create_directory(dirPath); + success = of::filesystem::create_directory(dirPath); }else{ - success = fs::create_directories(dirPath); + success = of::filesystem::create_directories(dirPath); } } catch(std::exception & except){ ofLogError("ofDirectory") << "createDirectory(): couldn't create directory \"" << dirPath << "\": " << except.what(); @@ -1578,13 +1578,13 @@ bool ofDirectory::createDirectory(const fs::path& _dirPath, bool bRelativeToData } //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::doesDirectoryExist(const fs::path& _dirPath, bool bRelativeToData){ +bool ofDirectory::doesDirectoryExist(const of::filesystem::path& _dirPath, bool bRelativeToData){ auto dirPath = _dirPath; try { if (bRelativeToData) { dirPath = ofToDataPath(dirPath); } - return fs::exists(dirPath) && fs::is_directory(dirPath); + return of::filesystem::exists(dirPath) && of::filesystem::is_directory(dirPath); } catch (std::exception & except) { ofLogError("ofDirectory") << "doesDirectoryExist(): couldn't find directory \"" << dirPath << "\": " << except.what() << std::endl; @@ -1593,14 +1593,14 @@ bool ofDirectory::doesDirectoryExist(const fs::path& _dirPath, bool bRelativeToD } //------------------------------------------------------------------------------------------------------------ -bool ofDirectory::isDirectoryEmpty(const fs::path& _dirPath, bool bRelativeToData){ +bool ofDirectory::isDirectoryEmpty(const of::filesystem::path& _dirPath, bool bRelativeToData){ auto dirPath = _dirPath; if(bRelativeToData){ dirPath = ofToDataPath(dirPath); } - if(!dirPath.empty() && fs::exists(dirPath) && fs::is_directory(dirPath)){ - return fs::directory_iterator(dirPath) == fs::directory_iterator(); + if(!dirPath.empty() && of::filesystem::exists(dirPath) && of::filesystem::is_directory(dirPath)){ + return of::filesystem::directory_iterator(dirPath) == of::filesystem::directory_iterator(); } return false; } @@ -1664,9 +1664,9 @@ vector::const_reverse_iterator ofDirectory::rend() const{ //------------------------------------------------------------------------------------------------------------ -string ofFilePath::addLeadingSlash(const fs::path& _path){ +string ofFilePath::addLeadingSlash(const of::filesystem::path& _path){ auto path = _path.string(); - auto sep = fs::path("/").make_preferred(); + auto sep = of::filesystem::path("/").make_preferred(); if(!path.empty()){ if(ofToString(path[0]) != sep.string()){ path = (sep / path).string(); @@ -1676,14 +1676,14 @@ string ofFilePath::addLeadingSlash(const fs::path& _path){ } //------------------------------------------------------------------------------------------------------------ -//string ofFilePath::addTrailingSlash(const fs::path & _path){ -fs::path ofFilePath::addTrailingSlash(const fs::path & _path){ +//string ofFilePath::addTrailingSlash(const of::filesystem::path & _path){ +of::filesystem::path ofFilePath::addTrailingSlash(const of::filesystem::path & _path){ #if OF_USING_STD_FS && !OF_USE_EXPERIMENTAL_FS if(_path.string().empty()) return ""; - return (fs::path(_path).make_preferred() / "").string(); + return (of::filesystem::path(_path).make_preferred() / "").string(); #else - auto path = fs::path(_path).make_preferred().string(); - auto sep = fs::path("/").make_preferred(); + auto path = of::filesystem::path(_path).make_preferred().string(); + auto sep = of::filesystem::path("/").make_preferred(); if(!path.empty()){ if(ofToString(path.back()) != sep.string()){ path = (path / sep).string(); @@ -1695,18 +1695,18 @@ fs::path ofFilePath::addTrailingSlash(const fs::path & _path){ //------------------------------------------------------------------------------------------------------------ -string ofFilePath::getFileExt(const fs::path& filename){ +string ofFilePath::getFileExt(const of::filesystem::path& filename){ return ofFile(filename,ofFile::Reference).getExtension(); } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::removeExt(const fs::path& filename){ +string ofFilePath::removeExt(const of::filesystem::path& filename){ return ofFilePath::join(getEnclosingDirectory(filename,false), ofFile(filename,ofFile::Reference).getBaseName()); } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::getPathForDirectory(const fs::path& path){ +string ofFilePath::getPathForDirectory(const of::filesystem::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 "/" @@ -1714,7 +1714,7 @@ string ofFilePath::getPathForDirectory(const fs::path& path){ if(path.string().empty()) return ""; return (path / "").string(); #else - auto sep = fs::path("/").make_preferred(); + auto sep = of::filesystem::path("/").make_preferred(); if(!path.empty() && ofToString(path.string().back())!=sep.string()){ return (path / sep).string(); }else{ @@ -1724,7 +1724,7 @@ string ofFilePath::getPathForDirectory(const fs::path& path){ } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::removeTrailingSlash(const fs::path& _path){ +string ofFilePath::removeTrailingSlash(const of::filesystem::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); @@ -1734,25 +1734,25 @@ string ofFilePath::removeTrailingSlash(const fs::path& _path){ //------------------------------------------------------------------------------------------------------------ -string ofFilePath::getFileName(const fs::path& _filePath, bool bRelativeToData){ +string ofFilePath::getFileName(const of::filesystem::path& _filePath, bool bRelativeToData){ std::string filePath = _filePath.string(); if(bRelativeToData){ filePath = ofToDataPath(_filePath); } - return fs::path(filePath).filename().string(); + return of::filesystem::path(filePath).filename().string(); } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::getBaseName(const fs::path& filePath){ +string ofFilePath::getBaseName(const of::filesystem::path& filePath){ return ofFile(filePath,ofFile::Reference).getBaseName(); } //------------------------------------------------------------------------------------------------------------ -fs::path ofFilePath::getEnclosingDirectory(const fs::path & _filePath, bool bRelativeToData){ +of::filesystem::path ofFilePath::getEnclosingDirectory(const of::filesystem::path & _filePath, bool bRelativeToData){ // std::string filePath = _filePath.string(); - fs::path fp = _filePath; + of::filesystem::path fp = _filePath; if(bRelativeToData){ fp = ofToDataPath(fp); } @@ -1760,37 +1760,37 @@ fs::path ofFilePath::getEnclosingDirectory(const fs::path & _filePath, bool bRel } //------------------------------------------------------------------------------------------------------------ -bool ofFilePath::createEnclosingDirectory(const fs::path& filePath, bool bRelativeToData, bool bRecursive) { +bool ofFilePath::createEnclosingDirectory(const of::filesystem::path& filePath, bool bRelativeToData, bool bRecursive) { return ofDirectory::createDirectory(ofFilePath::getEnclosingDirectory(filePath,bRelativeToData), bRelativeToData, bRecursive); } //------------------------------------------------------------------------------------------------------------ -fs::path ofFilePath::getAbsolutePath(const fs::path& path, bool bRelativeToData){ +of::filesystem::path ofFilePath::getAbsolutePath(const of::filesystem::path& path, bool bRelativeToData){ if(bRelativeToData){ return ofToDataPath(path, true); }else{ try{ - return fs::canonical(fs::absolute(path)); + return of::filesystem::canonical(of::filesystem::absolute(path)); }catch(...){ - return fs::absolute(path); + return of::filesystem::absolute(path); } } } //------------------------------------------------------------------------------------------------------------ -bool ofFilePath::isAbsolute(const fs::path& path){ - return fs::path(path).is_absolute(); +bool ofFilePath::isAbsolute(const of::filesystem::path& path){ + return of::filesystem::path(path).is_absolute(); } //------------------------------------------------------------------------------------------------------------ string ofFilePath::getCurrentWorkingDirectory(){ - return fs::current_path().string(); + return of::filesystem::current_path().string(); } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::join(const fs::path& path1, const fs::path& path2){ - return (fs::path(path1) / fs::path(path2)).string(); +string ofFilePath::join(const of::filesystem::path& path1, const of::filesystem::path& path2){ + return (of::filesystem::path(path1) / of::filesystem::path(path2)).string(); } //------------------------------------------------------------------------------------------------------------ @@ -1825,7 +1825,7 @@ string ofFilePath::getCurrentExePath(){ } //------------------------------------------------------------------------------------------------------------ -fs::path ofFilePath::getCurrentExeDir(){ +of::filesystem::path ofFilePath::getCurrentExeDir(){ return ofFilePath::getEnclosingDirectory(ofFilePath::getCurrentExePath(), false); } @@ -1844,15 +1844,15 @@ string ofFilePath::getUserHomeDir(){ #endif } -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() ); +string ofFilePath::makeRelative(const of::filesystem::path & from, const of::filesystem::path & to){ + auto pathFrom = of::filesystem::absolute( from ); + auto pathTo = of::filesystem::absolute( to ); + of::filesystem::path ret; + of::filesystem::path::const_iterator itrFrom( pathFrom.begin() ), itrTo( pathTo.begin() ); // Find common base - for( fs::path::const_iterator toEnd( pathTo.end() ), fromEnd( pathFrom.end() ) ; itrFrom != fromEnd && itrTo != toEnd && *itrFrom == *itrTo; ++itrFrom, ++itrTo ); + for( of::filesystem::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( fs::path::const_iterator fromEnd( pathFrom.end() ); itrFrom != fromEnd; ++itrFrom ){ + for( of::filesystem::path::const_iterator fromEnd( pathFrom.end() ); itrFrom != fromEnd; ++itrFrom ){ if( (*itrFrom) != "." ){ ret /= ".."; } @@ -1880,7 +1880,7 @@ void ofDisableDataPath(){ //-------------------------------------------------- bool ofRestoreWorkingDirectoryToDefault(){ try{ - fs::current_path(defaultWorkingDirectory()); + of::filesystem::current_path(defaultWorkingDirectory()); return true; }catch(...){ return false; @@ -1888,12 +1888,12 @@ bool ofRestoreWorkingDirectoryToDefault(){ } //-------------------------------------------------- -void ofSetDataPathRoot(const fs::path& newRoot){ +void ofSetDataPathRoot(const of::filesystem::path& newRoot){ dataPathRoot() = newRoot; } //-------------------------------------------------- -fs::path ofToDataPath(const fs::path & path, bool makeAbsolute){ +of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool makeAbsolute){ if (makeAbsolute && path.is_absolute()) { return path; } @@ -1906,7 +1906,7 @@ fs::path ofToDataPath(const fs::path & path, bool makeAbsolute){ // if our Current Working Directory has changed (e.g. file open dialog) #ifdef TARGET_WIN32 - if (defaultWorkingDirectory() != fs::current_path()) { + if (defaultWorkingDirectory() != of::filesystem::current_path()) { // change our cwd back to where it was on app load bool ret = ofRestoreWorkingDirectoryToDefault(); if(!ret){ @@ -1917,14 +1917,14 @@ fs::path ofToDataPath(const fs::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(); - fs::path inputPath(path); - fs::path outputPath; + of::filesystem::path inputPath(path); + of::filesystem::path outputPath; // if path is already absolute, just return it if (inputPath.is_absolute()) { try { - auto outpath = fs::canonical(inputPath).make_preferred(); - if(fs::is_directory(outpath) && hasTrailingSlash){ + auto outpath = of::filesystem::canonical(inputPath).make_preferred(); + if(of::filesystem::is_directory(outpath) && hasTrailingSlash){ return ofFilePath::addTrailingSlash(outpath.string()); }else{ return outpath.string(); @@ -1943,7 +1943,7 @@ fs::path ofToDataPath(const fs::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(dataPath); - auto relativeDirDataPath = ofFilePath::makeRelative(fs::current_path().string(),dataPath.string()); + auto relativeDirDataPath = ofFilePath::makeRelative(of::filesystem::current_path().string(),dataPath.string()); relativeDirDataPath = ofFilePath::addTrailingSlash(relativeDirDataPath); if (inputPath.string().find(dirDataPath) != 0 && inputPath.string().find(relativeDirDataPath)!=0) { @@ -1962,15 +1962,15 @@ fs::path ofToDataPath(const fs::path & path, bool makeAbsolute){ if(makeAbsolute){ // then we return the absolute form of the path try { - auto outpath = fs::canonical(fs::absolute(outputPath)).make_preferred(); - if(fs::is_directory(outpath) && hasTrailingSlash){ + auto outpath = of::filesystem::canonical(of::filesystem::absolute(outputPath)).make_preferred(); + if(of::filesystem::is_directory(outpath) && hasTrailingSlash){ return ofFilePath::addTrailingSlash(outpath); }else{ return outpath.string(); } } catch (std::exception &) { - return fs::absolute(outputPath).string(); + return of::filesystem::absolute(outputPath).string(); } }else{ // or output the relative path diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index c9c63ae5e73..817222d8300 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -274,7 +274,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 fs::path & path, bool binary=true); +ofBuffer ofBufferFromFile(const of::filesystem::path & path, bool binary=true); //-------------------------------------------------- /// Write the contents of a buffer to a file at path. @@ -285,7 +285,7 @@ ofBuffer ofBufferFromFile(const fs::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(fs::path & path, const ofBuffer& buffer, bool binary=true); +bool ofBufferToFile(of::filesystem::path & path, const ofBuffer& buffer, bool binary=true); //-------------------------------------------------- /// \class ofFilePath @@ -299,32 +299,32 @@ class ofFilePath{ /// /// \param filename file path /// \returns filename extension only - static std::string getFileExt(const fs::path& filename); + static std::string getFileExt(const of::filesystem::path& filename); /// Remove extension from a filename, ie. "duck.jpg" ->"duck". /// /// \param filename file path /// \returns filename without extension - static std::string removeExt(const fs::path& filename); + static std::string removeExt(const of::filesystem::path& filename); /// Prepend path with a slash, ie. "images" -> "/images". /// /// \param path file or directory path /// \returns slah + path - static std::string addLeadingSlash(const fs::path& path); + static std::string addLeadingSlash(const of::filesystem::path& path); /// Append path with a slash, ie. "images" -> "images/". /// /// \param path directory path /// \returns path + slash - static fs::path addTrailingSlash(const fs::path& path); + static of::filesystem::path addTrailingSlash(const of::filesystem::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 fs::path& path); + static std::string removeTrailingSlash(const of::filesystem::path& path); /// Cleaned up a directory path by adding a trailing slash if needed. /// @@ -333,7 +333,7 @@ class ofFilePath{ /// /// \param path directory path /// \returns cleaned path + trailing slash (if needed) - static std::string getPathForDirectory(const fs::path& path); + static std::string getPathForDirectory(const of::filesystem::path& path); /// Get the absolute, full path for a given path, /// ie. "images" -> "/Users/mickey/of/apps/myApps/Donald/bin/data/images". @@ -343,7 +343,7 @@ class ofFilePath{ /// are *not* in the data folder and want the direct path without relative /// "../../" /// \returns absolute path - static fs::path getAbsolutePath(const fs::path& path, bool bRelativeToData = true); + static of::filesystem::path getAbsolutePath(const of::filesystem::path& path, bool bRelativeToData = true); /// Check if a path is an absolute (aka a full path), /// ie. "images" -> false, @@ -351,7 +351,7 @@ class ofFilePath{ /// /// \param path file or directory path /// \returns true if the path is an absolute path - static bool isAbsolute(const fs::path& path); + static bool isAbsolute(const of::filesystem::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 @@ -362,7 +362,7 @@ class ofFilePath{ /// are *not* in the data folder and want the direct path without relative /// "../../" /// \returns filename - static std::string getFileName(const fs::path& filePath, bool bRelativeToData = true); + static std::string getFileName(const of::filesystem::path& filePath, bool bRelativeToData = true); /// Get a file name without its extension, /// ie. "images/duck.jpg" -> "duck" and @@ -370,7 +370,7 @@ class ofFilePath{ /// /// \param filePath file path /// \returns basename - static std::string getBaseName(const fs::path& filePath); + static std::string getBaseName(const of::filesystem::path& filePath); /// Get the enclosing parent directory of a path, /// ie. "images/duck.jpg" -> "images", assumes the path is in the data @@ -381,7 +381,7 @@ class ofFilePath{ /// are *not* in the data folder and want the direct path without relative /// "../../" ///\returns enclosing directory - static fs::path getEnclosingDirectory(const fs::path& filePath, bool bRelativeToData = true); + static of::filesystem::path getEnclosingDirectory(const of::filesystem::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". @@ -395,7 +395,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 fs::path& filePath, bool bRelativeToData = true, bool bRecursive = true); + static bool createEnclosingDirectory(const of::filesystem::path& filePath, bool bRelativeToData = true, bool bRecursive = true); /// Get the full path to the app's current working directory. /// @@ -413,7 +413,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 fs::path& path1, const fs::path& path2); + static std::string join(const of::filesystem::path& path1, const of::filesystem::path& path2); /// Get the full path to the application's executable file. /// @@ -430,7 +430,7 @@ class ofFilePath{ /// Mac: the Contents/MacOS folder within the application's .app bundle /// /// \returns current executable directory - static fs::path getCurrentExeDir(); + static of::filesystem::path getCurrentExeDir(); /// Get the absolute path to the user's home directory. /// @@ -448,7 +448,7 @@ class ofFilePath{ /// \param from starting path /// \param to destination path /// \returns relative path - static std::string makeRelative(const fs::path & from, const fs::path & to); + static std::string makeRelative(const of::filesystem::path & from, const of::filesystem::path & to); }; /// \class ofFile @@ -486,8 +486,8 @@ 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(fs::path & path, Mode mode=ReadOnly, bool binary=true); - ofFile(const fs::path & path, Mode mode=ReadOnly, bool binary=true); +// ofFile(of::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); + ofFile(const of::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); /// Create a new file path using the same path & settings of another /// file. @@ -512,8 +512,8 @@ 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(fs::path & path, Mode mode=ReadOnly, bool binary=true); - bool open(const fs::path & path, Mode mode=ReadOnly, bool binary=true); + bool open(of::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); + bool open(const of::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); /// Open the path as a file. /// @@ -525,7 +525,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 fs::path & path, Mode mode=ReadOnly, bool binary=true); + bool openFromCWD(const of::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); /// Reopen the current file path with a different access mode. /// @@ -552,7 +552,7 @@ class ofFile: public std::fstream{ /// /// \param path file path /// \returns true if the file was created - bool create(const fs::path & path); + bool create(const of::filesystem::path & path); /// Check if a file exists at the current path. /// @@ -562,7 +562,7 @@ class ofFile: public std::fstream{ /// Get the current path. /// /// \returns current path - fs::path path() const; + of::filesystem::path path() const; /// Get the current path without its extension, /// ie. "duck.jpg" ->"duck". @@ -588,13 +588,13 @@ class ofFile: public std::fstream{ /// directory. /// /// \returns current path's enclosing directory - fs::path getEnclosingDirectory() const; + of::filesystem::path getEnclosingDirectory() const; /// \biref Get the absolute, full path of the file, /// ie. "images" -> "/Users/mickey/of/apps/myApps/Donald/bin/data/images". /// /// \returns current path as an absolute path - fs::path getAbsolutePath() const; + of::filesystem::path getAbsolutePath() const; /// Check if the current path is readable. /// @@ -666,7 +666,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 fs::path& path, bool bRelativeToData = true, bool overwrite = false) const; + bool copyTo(const of::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false) const; /// Move the current file or directory path to a new path. /// @@ -680,7 +680,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 fs::path& path, bool bRelativeToData = true, bool overwrite = false); + bool moveTo(const of::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false); /// Rename the current file or directory path to a new path. /// @@ -694,7 +694,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 fs::path& path, bool bRelativeToData = true, bool overwrite = false); + bool renameTo(const of::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false); /// Removes the file or directory at the current path. /// @@ -748,11 +748,11 @@ class ofFile: public std::fstream{ /// \return output stream std::filebuf * getFileBuffer() const; - operator fs::path(){ + operator of::filesystem::path(){ return myFile; } // - operator fs::path() const{ + operator of::filesystem::path() const{ return myFile; } @@ -772,7 +772,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 fs::path& pathSrc, const fs::path& pathDst, bool bRelativeToData = true, bool overwrite = false); + static bool copyFromTo(const of::filesystem::path& pathSrc, const of::filesystem::path& pathDst, bool bRelativeToData = true, bool overwrite = false); /// Move source path to destination path. /// @@ -788,7 +788,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 fs::path& pathSrc, const fs::path& pathDst, bool bRelativeToData = true, bool overwrite = false); + static bool moveFromTo(const of::filesystem::path& pathSrc, const of::filesystem::path& pathDst, bool bRelativeToData = true, bool overwrite = false); /// Check if a file or directory exists at a given path. /// @@ -797,7 +797,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 fs::path& fPath, bool bRelativeToData = true); + static bool doesFileExist(const of::filesystem::path& fPath, bool bRelativeToData = true); /// Remove a file or directory at a given path. /// @@ -805,14 +805,14 @@ 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 fs::path& path, bool bRelativeToData = true); + static bool removeFile(const of::filesystem::path& path, bool bRelativeToData = true); private: bool isWriteMode(); bool openStream(Mode _mode, bool binary); void copyFrom(const ofFile & mom); - fs::path myFile; + of::filesystem::path myFile; Mode mode; bool binary; }; @@ -835,17 +835,17 @@ class ofDirectory{ /// Create an ofDirectory instance and attempt to open the path. /// /// \param path directory path - ofDirectory(const fs::path & path); + ofDirectory(const of::filesystem::path & path); /// Open a directory path, clears the current file list. /// /// \param path directory path - void open(const fs::path & path); + void open(const of::filesystem::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 fs::path & path); + void openFromCWD(const of::filesystem::path & path); /// Close the currently open path. void close(); @@ -864,13 +864,13 @@ class ofDirectory{ /// Get the current path. /// /// \returns current path - fs::path path() const; + of::filesystem::path path() const; /// Get the absolute, full path of the directory, /// ie. "images" -> "/Users/mickey/of/apps/myApps/Donald/bin/data/images". /// /// \return current path as an absolute path - fs::path getAbsolutePath() const; + of::filesystem::path getAbsolutePath() const; /// Check if the current path is readable. /// @@ -937,7 +937,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 fs::path& path, bool bRelativeToData = true, bool overwrite = false); + bool copyTo(const of::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false); /// Move the current file or directory path to a new path. /// @@ -951,7 +951,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 fs::path& path, bool bRelativeToData = true, bool overwrite = false); + bool moveTo(const of::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false); /// Rename the current file or directory path to a new path. /// @@ -965,7 +965,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 fs::path& path, bool bRelativeToData = true, bool overwrite = false); + bool renameTo(const of::filesystem::path& path, bool bRelativeToData = true, bool overwrite = false); /// Removes the file or directory at the current path. /// @@ -1115,11 +1115,11 @@ class ofDirectory{ bool operator>(const ofDirectory & dir) const; bool operator>=(const ofDirectory & dir) const; - operator fs::path(){ + operator of::filesystem::path(){ return myDir; } - operator fs::path() const{ + operator of::filesystem::path() const{ return myDir; } @@ -1137,7 +1137,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 fs::path& dirPath, bool bRelativeToData = true, bool recursive = false); + static bool createDirectory(const of::filesystem::path& dirPath, bool bRelativeToData = true, bool recursive = false); /// Check if a directory at a given path is empty. /// @@ -1148,7 +1148,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 fs::path& dirPath, bool bRelativeToData = true ); + static bool isDirectoryEmpty(const of::filesystem::path& dirPath, bool bRelativeToData = true ); /// Check if a directory exists at a given path. /// @@ -1158,7 +1158,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 fs::path& dirPath, bool bRelativeToData = true); + static bool doesDirectoryExist(const of::filesystem::path& dirPath, bool bRelativeToData = true); /// remove a directory at a given path @@ -1168,14 +1168,14 @@ 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 fs::path& path, bool deleteIfNotEmpty, bool bRelativeToData = true); + static bool removeDirectory(const of::filesystem::path& path, bool deleteIfNotEmpty, bool bRelativeToData = true); std::vector::const_iterator begin() const; std::vector::const_iterator end() const; std::vector::const_reverse_iterator rbegin() const; std::vector::const_reverse_iterator rend() const; - fs::path myDir; + of::filesystem::path myDir; std::string originalDirectory; std::vector extensions; std::vector files; @@ -1207,7 +1207,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(). -fs::path ofToDataPath(const fs::path & path, bool absolute=false); +of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool absolute=false); /// \brief Reset the working directory to the platform default. /// @@ -1226,7 +1226,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(fs::path& root); +void ofSetDataPathRoot(of::filesystem::path& root); /*! \cond PRIVATE */ namespace of{ diff --git a/libs/openFrameworks/utils/ofJson.h b/libs/openFrameworks/utils/ofJson.h index 0c974909068..8907e0f84d6 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 fs::path& filename){ +inline ofJson ofLoadJson(const of::filesystem::path& filename){ ofJson json; ofFile jsonFile(filename); if(jsonFile.exists()){ @@ -35,7 +35,7 @@ inline ofJson ofLoadJson(const fs::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 fs::path& filename, const ofJson & json){ +inline bool ofSaveJson(const of::filesystem::path& filename, const ofJson & json){ ofFile jsonFile(filename, ofFile::WriteOnly); try{ jsonFile << json; @@ -53,7 +53,7 @@ inline bool ofSaveJson(const fs::path& filename, const ofJson & json){ /// \param filename The destination path. /// \param json The Json to save. /// \returns true if the json was saved successfully. -inline bool ofSavePrettyJson(const fs::path& filename, const ofJson & json){ +inline bool ofSavePrettyJson(const of::filesystem::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 68afa7aebb4..0bea13cb3d4 100644 --- a/libs/openFrameworks/utils/ofLog.cpp +++ b/libs/openFrameworks/utils/ofLog.cpp @@ -61,7 +61,7 @@ ofLogLevel ofGetLogLevel(string module){ } //-------------------------------------------------- -void ofLogToFile(const fs::path & path, bool append){ +void ofLogToFile(const of::filesystem::path & path, bool append){ ofLog::setChannel(std::make_shared(path,append)); } @@ -261,7 +261,7 @@ void ofDebugViewLoggerChannel::log(ofLogLevel level, const string & module, cons ofFileLoggerChannel::ofFileLoggerChannel(){ } -ofFileLoggerChannel::ofFileLoggerChannel(const fs::path & path, bool append){ +ofFileLoggerChannel::ofFileLoggerChannel(const of::filesystem::path & path, bool append){ setFile(path,append); } @@ -273,7 +273,7 @@ void ofFileLoggerChannel::close(){ file.close(); } -void ofFileLoggerChannel::setFile(const fs::path & path,bool append){ +void ofFileLoggerChannel::setFile(const of::filesystem::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 4d324d35b24..4c587dc1c53 100644 --- a/libs/openFrameworks/utils/ofLog.h +++ b/libs/openFrameworks/utils/ofLog.h @@ -236,7 +236,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 fs::path & path, bool append=false); +void ofLogToFile(const of::filesystem::path & path, bool append=false); /// \brief Set the logging to ouptut to the console. /// @@ -703,7 +703,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 fs::path & path, bool append); + ofFileLoggerChannel(const of::filesystem::path & path, bool append); /// \brief Destroy the file logger channel. virtual ~ofFileLoggerChannel(); @@ -711,7 +711,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 fs::path & path,bool append=false); + void setFile(const of::filesystem::path & path,bool append=false); void log(ofLogLevel level, const std::string & module, const std::string & message); diff --git a/libs/openFrameworks/utils/ofURLFileLoader.cpp b/libs/openFrameworks/utils/ofURLFileLoader.cpp index a05c5eb8f9c..26e5f93d457 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 fs::path& path); - int saveAsync(const string& url, const fs::path& path); + ofHttpResponse saveTo(const string& url, const of::filesystem::path& path); + int saveAsync(const string& url, const of::filesystem::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 fs::path& path){ +ofHttpResponse ofURLFileLoaderImpl::saveTo(const string& url, const of::filesystem::path& path){ ofHttpRequest request(url,path.string(),true); return handleRequest(request); } -int ofURLFileLoaderImpl::saveAsync(const string& url, const fs::path& path){ +int ofURLFileLoaderImpl::saveAsync(const string& url, const of::filesystem::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 fs::path & path){ +ofHttpResponse ofURLFileLoader::saveTo(const string& url, const of::filesystem::path & path){ return impl->saveTo(url,path); } -int ofURLFileLoader::saveAsync(const string& url, const fs::path & path){ +int ofURLFileLoader::saveAsync(const string& url, const of::filesystem::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 fs::path& path){ +ofHttpResponse ofSaveURLTo(const string& url, const of::filesystem::path& path){ return getFileLoader().saveTo(url,path); } -int ofSaveURLAsync(const string& url, const fs::path& path){ +int ofSaveURLAsync(const string& url, const of::filesystem::path& path){ return getFileLoader().saveAsync(url,path); } diff --git a/libs/openFrameworks/utils/ofURLFileLoader.h b/libs/openFrameworks/utils/ofURLFileLoader.h index 6d58167a3f7..f23e6a9ef33 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 fs::path& path); +ofHttpResponse ofSaveURLTo(const std::string& url, const of::filesystem::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 fs::path& 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 fs::path& path); +int ofSaveURLAsync(const std::string& url, const of::filesystem::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 fs::path& path); + ofHttpResponse saveTo(const std::string& url, const of::filesystem::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 fs::path& path); + int saveAsync(const std::string& url, const of::filesystem::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 fs::path& path)=0; + virtual ofHttpResponse saveTo(const std::string& url, const of::filesystem::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 fs::path& path)=0; + virtual int saveAsync(const std::string& url, const of::filesystem::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 07b89bdb719..5d9dff1de62 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 fs::path & file){ +bool ofXml::load(const of::filesystem::path & file){ auto auxDoc = std::make_shared(); auto p = ofToDataPath(file); auto res = auxDoc->load_file( @@ -49,7 +49,7 @@ bool ofXml::parse(const std::string & xmlStr){ } } -bool ofXml::save(const fs::path & file) const{ +bool ofXml::save(const of::filesystem::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 9f69110f7ad..d4f62c91ce3 100644 --- a/libs/openFrameworks/utils/ofXml.h +++ b/libs/openFrameworks/utils/ofXml.h @@ -100,10 +100,10 @@ class ofXml{ ofXml(); - bool load(const fs::path & file); + bool load(const of::filesystem::path & file); bool load(const ofBuffer & buffer); bool parse(const std::string & xmlStr); - bool save(const fs::path & file) const; + bool save(const of::filesystem::path & file) const; void clear(); std::string toString(const std::string & indent = "\t") const; diff --git a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj index 51f71bc6303..58cbaaf5f28 100644 --- a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj +++ b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj @@ -863,7 +863,8 @@ E4B27C1610CBEB8E00536013 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_X86_VECTOR_INSTRUCTIONS = default; + ARCHS = "$(ARCHS)"; + CLANG_X86_VECTOR_INSTRUCTIONS = sse3; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/osx/"; COPY_PHASE_STRIP = NO; @@ -891,7 +892,8 @@ E4B27C1710CBEB8E00536013 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_X86_VECTOR_INSTRUCTIONS = default; + ARCHS = "$(ARCHS)"; + CLANG_X86_VECTOR_INSTRUCTIONS = sse3; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/osx/"; COPY_PHASE_STRIP = YES; From b101f89ce24eed976a89c025296b5261a5eb762f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 11 Aug 2022 21:20:18 -0300 Subject: [PATCH 06/91] fix non macos files --- addons/ofxAndroid/src/ofxAndroidSoundPlayer.cpp | 2 +- addons/ofxAndroid/src/ofxAndroidSoundPlayer.h | 2 +- addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.cpp | 2 +- addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.h | 2 +- addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp | 4 ++-- addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h | 4 ++-- addons/ofxPoco/src/ofxXmlPoco.cpp | 4 ++-- addons/ofxPoco/src/ofxXmlPoco.h | 4 ++-- addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.cpp | 2 +- addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.h | 2 +- addons/ofxiOS/src/sound/ofxiOSSoundPlayer.h | 2 +- addons/ofxiOS/src/sound/ofxiOSSoundPlayer.mm | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/addons/ofxAndroid/src/ofxAndroidSoundPlayer.cpp b/addons/ofxAndroid/src/ofxAndroidSoundPlayer.cpp index 26088ed5273..747495e69c1 100644 --- a/addons/ofxAndroid/src/ofxAndroidSoundPlayer.cpp +++ b/addons/ofxAndroid/src/ofxAndroidSoundPlayer.cpp @@ -43,7 +43,7 @@ ofxAndroidSoundPlayer::~ofxAndroidSoundPlayer(){ //------------------------------------------------------------ -bool ofxAndroidSoundPlayer::load(const filesystem::path& fileName, bool stream){ +bool ofxAndroidSoundPlayer::load(const of::filesystem::path& fileName, bool stream){ if(!javaSoundPlayer){ ofLogError("ofxAndroidSoundPlayer") << "loadSound(): java SoundPlayer not loaded"; return false; diff --git a/addons/ofxAndroid/src/ofxAndroidSoundPlayer.h b/addons/ofxAndroid/src/ofxAndroidSoundPlayer.h index c70d1a07a2c..d077bc21f9d 100644 --- a/addons/ofxAndroid/src/ofxAndroidSoundPlayer.h +++ b/addons/ofxAndroid/src/ofxAndroidSoundPlayer.h @@ -8,7 +8,7 @@ class ofxAndroidSoundPlayer: public ofBaseSoundPlayer{ ofxAndroidSoundPlayer(); virtual ~ofxAndroidSoundPlayer(); - bool load(const filesystem::path& fileName, bool stream = false); + bool load(const of::filesystem::path& fileName, bool stream = false); void unload(); void play(); void stop(); diff --git a/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.cpp b/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.cpp index 5a6c16e22c6..9d4ff688290 100644 --- a/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.cpp +++ b/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.cpp @@ -39,7 +39,7 @@ ofxEmscriptenSoundPlayer::~ofxEmscriptenSoundPlayer(){ } -bool ofxEmscriptenSoundPlayer::load(const filesystem::path& fileName, bool stream){ +bool ofxEmscriptenSoundPlayer::load(const of::filesystem::path& fileName, bool stream){ if(context!=-1){ sound = html5audio_sound_load(context,ofToDataPath(fileName).c_str()); } diff --git a/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.h b/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.h index da3bf143dc1..cbcfa8e7712 100644 --- a/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.h +++ b/addons/ofxEmscripten/src/ofxEmscriptenSoundPlayer.h @@ -9,7 +9,7 @@ class ofxEmscriptenSoundPlayer: public ofBaseSoundPlayer { ~ofxEmscriptenSoundPlayer(); - bool load(const filesystem::path& fileName, bool stream = false); + bool load(const of::filesystem::path& fileName, bool stream = false); void unload(); void play(); void stop(); diff --git a/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp b/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp index a94b1385e01..7b8045a346e 100644 --- a/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp +++ b/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp @@ -30,12 +30,12 @@ int ofxEmscriptenURLFileLoader::getAsync(const string & url, const string & na return req->getId(); } -ofHttpResponse ofxEmscriptenURLFileLoader::saveTo(const string & url, const filesystem::path & path){ +ofHttpResponse ofxEmscriptenURLFileLoader::saveTo(const string & url, const of::filesystem::path & path){ saveAsync(url,path); return ofHttpResponse(); } -int ofxEmscriptenURLFileLoader::saveAsync(const string & url, const filesystem::path & path){ +int ofxEmscriptenURLFileLoader::saveAsync(const string & url, const of::filesystem::path & path){ ofHttpRequest * req = new ofHttpRequest(url,url,true); #if __EMSCRIPTEN_major__>1 || (__EMSCRIPTEN_major__==1 && __EMSCRIPTEN_minor__>22) emscripten_async_wget2(url.c_str(), path.c_str(), "GET", "", req, &onload_file_cb, &onerror_file_cb, NULL); diff --git a/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h b/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h index 4fb68abfe3b..7e9d55ab97b 100644 --- a/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h +++ b/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h @@ -13,8 +13,8 @@ class ofxEmscriptenURLFileLoader: public ofBaseURLFileLoader { virtual ~ofxEmscriptenURLFileLoader(); ofHttpResponse get(const std::string & url); int getAsync(const std::string & url, const std::string & name=""); // returns id - ofHttpResponse saveTo(const std::string & url, const filesystem::path & path); - int saveAsync(const std::string & url, const filesystem::path & path); + ofHttpResponse saveTo(const std::string & url, const of::filesystem::path & path); + int saveAsync(const std::string & url, const of::filesystem::path & path); ofHttpResponse handleRequest(const ofHttpRequest & request); int handleRequestAsync(const ofHttpRequest & request); void remove(int id); diff --git a/addons/ofxPoco/src/ofxXmlPoco.cpp b/addons/ofxPoco/src/ofxXmlPoco.cpp index 24cb464236d..0702888d528 100644 --- a/addons/ofxPoco/src/ofxXmlPoco.cpp +++ b/addons/ofxPoco/src/ofxXmlPoco.cpp @@ -42,7 +42,7 @@ ofxXmlPoco::ofxXmlPoco(){ } -bool ofxXmlPoco::load(const filesystem::path & path){ +bool ofxXmlPoco::load(const of::filesystem::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 filesystem::path & path){ } -bool ofxXmlPoco::save(const filesystem::path & path){ +bool ofxXmlPoco::save(const of::filesystem::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 afad03b16cd..fce42c9a66a 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 filesystem::path & path); - bool save(const filesystem::path & path); + bool load(const of::filesystem::path & path); + bool save(const of::filesystem::path & path); bool addChild( const std::string& path ); void addXml( ofxXmlPoco& xml, bool copyAll = false); diff --git a/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.cpp b/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.cpp index 2c6cfc574a3..55ffca0eac7 100644 --- a/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.cpp +++ b/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.cpp @@ -90,7 +90,7 @@ ofxOpenALSoundPlayer::~ofxOpenALSoundPlayer() { //-------------------------------------------------------------- -bool ofxOpenALSoundPlayer::load(const filesystem::path& filePath, bool stream) { +bool ofxOpenALSoundPlayer::load(const of::filesystem::path& filePath, bool stream) { if(!SoundEngineInitialized) { ofxOpenALSoundPlayer::initializeSoundEngine(); diff --git a/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.h b/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.h index 58ec666034d..00a0dd1a943 100644 --- a/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.h +++ b/addons/ofxiOS/src/sound/ofxOpenALSoundPlayer.h @@ -62,7 +62,7 @@ class ofxOpenALSoundPlayer : public ofBaseSoundPlayer{ ofxOpenALSoundPlayer(); ~ofxOpenALSoundPlayer(); - bool load(const filesystem::path& fileName, bool stream=false); + bool load(const of::filesystem::path& fileName, bool stream=false); void unload(); void play(); diff --git a/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.h b/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.h index daa971bb37d..4f8034e0c36 100644 --- a/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.h +++ b/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.h @@ -15,7 +15,7 @@ class ofxiOSSoundPlayer : public ofBaseSoundPlayer { ofxiOSSoundPlayer(); ~ofxiOSSoundPlayer(); - bool load(const filesystem::path& fileName, bool stream = false); + bool load(const of::filesystem::path& fileName, bool stream = false); void unload(); void play(); void stop(); diff --git a/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.mm b/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.mm index 5ad19876472..974c028ead2 100644 --- a/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.mm +++ b/addons/ofxiOS/src/sound/ofxiOSSoundPlayer.mm @@ -19,7 +19,7 @@ unload(); } -bool ofxiOSSoundPlayer::load(const filesystem::path& fileName, bool stream) { +bool ofxiOSSoundPlayer::load(const of::filesystem::path& fileName, bool stream) { if(soundPlayer != NULL) { unload(); } From 5b4d74e134878a49ad46bc2fe2f2765bf8503d4e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 13 Aug 2022 22:38:16 -0300 Subject: [PATCH 07/91] now working with make --- libs/openFrameworks/gl/ofShader.cpp | 8 +- libs/openFrameworks/graphics/ofImage.cpp | 4 +- .../graphics/ofTrueTypeFont.cpp | 3 +- libs/openFrameworks/utils/ofConstants.h | 92 ++++++++++++------- libs/openFrameworks/utils/ofFileUtils.cpp | 36 +++++--- libs/openFrameworks/utils/ofFileUtils.h | 2 +- .../project/osx/config.osx.default.mk | 6 +- 7 files changed, 94 insertions(+), 57 deletions(-) diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index 2aa20d3a73f..faac4885068 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -297,9 +297,9 @@ bool ofShader::setupShaderFromFile(GLenum type, const of::filesystem::path & fil // 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. auto absoluteFilePath = ofFilePath::getAbsolutePath(filename, true); - string sourceDirectoryPath = ofFilePath::getEnclosingDirectory(absoluteFilePath,false); + auto sourceDirectoryPath = ofFilePath::getEnclosingDirectory(absoluteFilePath,false); if(buffer.size()) { - return setupShaderFromSource(type, buffer.getText(), sourceDirectoryPath); + return setupShaderFromSource(type, buffer.getText(), sourceDirectoryPath.string()); } else { ofLogError("ofShader") << "setupShaderFromFile(): couldn't load " << nameForType(type) << " shader " << " from \"" << absoluteFilePath << "\""; return false; @@ -489,7 +489,7 @@ string ofShader::parseForIncludes( const string& source, vector& include include = ofFile( // ofFilePath::join(sourceDirectoryPath, include) sourceDirectoryPath / include - ).getAbsolutePath(); + ).getAbsolutePath().string(); included.push_back( include ); ofBuffer buffer = ofBufferFromFile( include ); @@ -498,7 +498,7 @@ string ofShader::parseForIncludes( const string& source, vector& include continue; } - string currentDir = ofFile(include).getEnclosingDirectory(); + string currentDir = ofFile(include).getEnclosingDirectory().string(); output << parseForIncludes( buffer.getText(), included, level + 1, currentDir ) << endl; } diff --git a/libs/openFrameworks/graphics/ofImage.cpp b/libs/openFrameworks/graphics/ofImage.cpp index 19cf1a150f8..a8c3583b0e8 100644 --- a/libs/openFrameworks/graphics/ofImage.cpp +++ b/libs/openFrameworks/graphics/ofImage.cpp @@ -209,7 +209,7 @@ static bool loadImage(ofPixels_ & pix, const of::filesystem::path& _f return ofLoadImage(pix, ofLoadURL(_fileName.string()).data); } - std::string fileName = ofToDataPath(_fileName, true); + std::string fileName = ofToDataPath(_fileName, true).string(); bool bLoaded = false; FIBITMAP * bmp = nullptr; @@ -358,7 +358,7 @@ static bool saveImage(const ofPixels_ & _pix, const of::filesystem::p } ofFilePath::createEnclosingDirectory(_fileName); - std::string fileName = ofToDataPath(_fileName); + std::string fileName = ofToDataPath(_fileName).string(); FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; fif = FreeImage_GetFileType(fileName.c_str(), 0); if(fif == FIF_UNKNOWN) { diff --git a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp index b0d9ec421b5..298a4b97af1 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp @@ -413,8 +413,7 @@ static bool loadFontFace(const of::filesystem::path& _fontname, FT_Face & face, } FT_Error err; err = FT_New_Face( library, filename.string().c_str(), fontID, &face ); - using std::cout, std::endl; - + if (err) { // simple error table in lieu of full table (see fterrors.h) string errorString = "unknown freetype"; diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index 08a7f78a76c..dd9c08252cd 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -1,6 +1,11 @@ #pragma once #include +#define Stringize( L ) #L +#define MakeString( M, L ) M(L) +#define $Line MakeString( Stringize, __LINE__ ) +#define Reminder __FILE__ "(" $Line ") : Reminder: " + //------------------------------- #define OF_VERSION_MAJOR 0 #define OF_VERSION_MINOR 11 @@ -506,6 +511,8 @@ std::unique_ptr make_unique(Args&&... args) { #include #if OF_HAS_CPP17 + #pragma message(Reminder "OF_HAS_CPP17") + namespace std { namespace experimental{ namespace filesystem { @@ -515,9 +522,15 @@ std::unique_ptr make_unique(Args&&... args) { using v1::path; } } - namespace filesystem = experimental::filesystem; +// namespace filesystem = experimental::filesystem; } + // new + namespace of { + using std::__fs::filesystem; + } #else + #pragma message(Reminder "no OF_HAS_CPP17") + namespace std { namespace experimental{ namespace filesystem { @@ -529,14 +542,21 @@ std::unique_ptr make_unique(Args&&... args) { using v1::__cxx11::path; } } - namespace filesystem = experimental::filesystem; +// namespace filesystem = experimental::filesystem; } + // new + namespace of { + namespace filesystem = std::__fs::filesystem; + } + #endif #else // Regular C++17 fs support #include - + namespace of { + namespace filesystem = std::filesystem; + } #endif #else // No experimental or c++17 filesytem support use boost @@ -544,36 +564,46 @@ std::unique_ptr make_unique(Args&&... args) { #define BOOST_NO_CXX11_SCOPED_ENUMS #define BOOST_NO_SCOPED_ENUMS #endif -// #include -// namespace boost { -// namespace filesystem { -// class path; -// } -// } -// namespace std { -// namespace filesystem = boost::filesystem; -// } -#endif +// #pragma message(Reminder "using boost") -#if defined __has_include - #if __has_include() - #include -namespace of{ - namespace filesystem = std::__fs::filesystem; -} - #define OF_USING_STD_FS 1 - #elif __has_include() - #include -namespace of{ - namespace filesystem = std::experimental::filesystem; -} + #include + namespace of { + namespace filesystem = boost::filesystem; + } - #elif __has_include() - #include -namespace of{ - namespace filesystem = boost::filesystem; -} - #endif + + #endif +#if defined __has_include +// #pragma message(Reminder "HAS include") + +// #if __has_include() +//// #define OF_USING_STD_FS 1 +// #include +// #include +// +// #pragma message(Reminder "filesystem") +//namespace of{ +// namespace filesystem = std::__fs::filesystem; +//// namespace filesystem = std::__fs::filesystem; +//} +// #elif __has_include() +// #include +// #pragma message(Reminder "experimental filesystem") +//namespace of{ +//// namespace filesystem = std::experimental::filesystem; +//} +// +// #elif __has_include() +// #include +// #pragma message(Reminder "boost filesystem") +//namespace of{ +//// namespace filesystem = boost::filesystem; +//} +// +// #endif +#endif + + diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 86e899d548c..13b8935c781 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -28,7 +28,7 @@ namespace{ //-------------------------------------------------- string defaultDataPath(){ #if defined TARGET_OSX - return ofFilePath::getCurrentExeDir() / "../../../data/"; + return (ofFilePath::getCurrentExeDir() / "../../../data/").string(); // try{ // return ofFilePath::getCurrentExeDir() / "../../../data/"; //// return of::filesystem::canonical(ofFilePath::getCurrentExeDir() / "../../../data/"); @@ -577,9 +577,10 @@ bool ofFile::openFromCWD(const of::filesystem::path & _path, Mode _mode, bool bi //------------------------------------------------------------------------------------------------------------- bool ofFile::changeMode(Mode _mode, bool binary){ if(_mode != mode){ - string _path = path(); + auto _path = path(); close(); - myFile = of::filesystem::path(_path); + myFile = _path; +// myFile = of::filesystem::path(_path); return openStream(_mode, binary); } else{ @@ -779,16 +780,15 @@ bool ofFile::canExecute() const { } #else if(geteuid() == info.st_uid){ - return perm & of::filesystem::perms::owner_exec; + return perm & of::filesystem::owner_exe; }else if (getegid() == info.st_gid){ - return perm & of::filesystem::perms::group_exec; + return perm & of::filesystem::group_exe; }else{ - return perm & of::filesystem::perms::others_exec; + return perm & of::filesystem::others_exe; } #endif #endif } - //------------------------------------------------------------------------------------------------------------ bool ofFile::isFile() const { return of::filesystem::is_regular_file(myFile); @@ -1676,7 +1676,6 @@ string ofFilePath::addLeadingSlash(const of::filesystem::path& _path){ } //------------------------------------------------------------------------------------------------------------ -//string ofFilePath::addTrailingSlash(const of::filesystem::path & _path){ of::filesystem::path ofFilePath::addTrailingSlash(const of::filesystem::path & _path){ #if OF_USING_STD_FS && !OF_USE_EXPERIMENTAL_FS if(_path.string().empty()) return ""; @@ -1735,13 +1734,22 @@ string ofFilePath::removeTrailingSlash(const of::filesystem::path& _path){ //------------------------------------------------------------------------------------------------------------ string ofFilePath::getFileName(const of::filesystem::path& _filePath, bool bRelativeToData){ - std::string filePath = _filePath.string(); +// std::string filePath = _filePath.string(); +// +// if(bRelativeToData){ +// filePath = ofToDataPath(_filePath); +// } +// +// return of::filesystem::path(filePath).filename().string(); + + auto filePath = _filePath; if(bRelativeToData){ - filePath = ofToDataPath(_filePath); + filePath = ofToDataPath(filePath); } return of::filesystem::path(filePath).filename().string(); + } //------------------------------------------------------------------------------------------------------------ @@ -1844,7 +1852,7 @@ string ofFilePath::getUserHomeDir(){ #endif } -string ofFilePath::makeRelative(const of::filesystem::path & from, const of::filesystem::path & to){ +of::filesystem::path ofFilePath::makeRelative(const of::filesystem::path & from, const of::filesystem::path & to){ auto pathFrom = of::filesystem::absolute( from ); auto pathTo = of::filesystem::absolute( to ); of::filesystem::path ret; @@ -1864,7 +1872,7 @@ string ofFilePath::makeRelative(const of::filesystem::path & from, const of::fil } } - return ret.string(); + return ret; } //-------------------------------------------------- @@ -1944,9 +1952,9 @@ of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool makeAb dirDataPath = ofFilePath::addTrailingSlash(dataPath); auto relativeDirDataPath = ofFilePath::makeRelative(of::filesystem::current_path().string(),dataPath.string()); - relativeDirDataPath = ofFilePath::addTrailingSlash(relativeDirDataPath); + relativeDirDataPath = ofFilePath::addTrailingSlash(relativeDirDataPath.string()); - if (inputPath.string().find(dirDataPath) != 0 && inputPath.string().find(relativeDirDataPath)!=0) { + if (inputPath.string().find(dirDataPath.string()) != 0 && inputPath.string().find(relativeDirDataPath.string())!=0) { // inputPath doesn't contain data path already, so we build the output path as the inputPath relative to the dataPath if(makeAbsolute){ outputPath = dirDataPath / inputPath; diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index 817222d8300..a74cea1f6d8 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -448,7 +448,7 @@ class ofFilePath{ /// \param from starting path /// \param to destination path /// \returns relative path - static std::string makeRelative(const of::filesystem::path & from, const of::filesystem::path & to); + static of::filesystem::path makeRelative(const of::filesystem::path & from, const of::filesystem::path & to); }; /// \class ofFile diff --git a/libs/openFrameworksCompiled/project/osx/config.osx.default.mk b/libs/openFrameworksCompiled/project/osx/config.osx.default.mk index fb50f03a635..71ba7c33ab1 100644 --- a/libs/openFrameworksCompiled/project/osx/config.osx.default.mk +++ b/libs/openFrameworksCompiled/project/osx/config.osx.default.mk @@ -69,7 +69,7 @@ PLATFORM_REQUIRED_ADDONS = # Note: Be sure to leave a leading space when using a += operator to add items to the list ########################################################################################## -MAC_OS_MIN_VERSION = 10.15 +#MAC_OS_MIN_VERSION = 10.15 ifndef MAC_OS_MIN_VERSION MAC_OS_MIN_VERSION = 10.9 @@ -84,7 +84,7 @@ ifndef MAC_OS_CPP_VER endif # Link against libstdc++ to silence tr1/memory errors on latest versions of osx -PLATFORM_CFLAGS += -stdlib=$(MAC_OS_STD_LIB) +PLATFORM_CFLAGS = -stdlib=$(MAC_OS_STD_LIB) # Warning Flags (http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html) PLATFORM_CFLAGS += -Wall @@ -168,7 +168,7 @@ endif PLATFORM_LDFLAGS = -stdlib=$(MAC_OS_STD_LIB) -PLATFORM_LDFLAGS += -lstdc++fs +#PLATFORM_LDFLAGS += -lstdc++fs #PLATFORM_LDFLAGS += -arch i386 From b7756d917c8e0201ca1b96bef812f3ce6d6058f4 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 13 Aug 2022 22:59:52 -0300 Subject: [PATCH 08/91] fileutils --- libs/openFrameworks/utils/ofFileUtils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index a74cea1f6d8..c2d747deadc 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -512,7 +512,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(of::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); +// bool open(of::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); bool open(const of::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); /// Open the path as a file. From 2f338b6781e9c53c29adb9e3d1319cb59ae87d93 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 13 Aug 2022 23:24:37 -0300 Subject: [PATCH 09/91] tests --- tests/utils/fileUtils/src/main.cpp | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/utils/fileUtils/src/main.cpp b/tests/utils/fileUtils/src/main.cpp index 17a7c4f81ef..3814d99b7ec 100644 --- a/tests/utils/fileUtils/src/main.cpp +++ b/tests/utils/fileUtils/src/main.cpp @@ -218,36 +218,36 @@ class ofApp: public ofxUnitTestsApp{ ofLogNotice() << ""; ofLogNotice() << "tests #4462"; if(ofGetTargetPlatform()==OF_TARGET_WINVS || ofGetTargetPlatform()==OF_TARGET_MINGW){ - ofxTestEq(ofToDataPath("movies\\",true).back(), '\\', "absolute ofToDataPath with \\ should end in \\"); - ofxTestEq(ofToDataPath("movies",true).back(), 's', "absolute ofToDataPath without \\ should not end in \\"); + ofxTestEq(ofToDataPath("movies\\",true).string().back(), '\\', "absolute ofToDataPath with \\ should end in \\"); + ofxTestEq(ofToDataPath("movies",true).string().back(), 's', "absolute ofToDataPath without \\ should not end in \\"); ofDirectory("movies").create(); - ofxTestEq(ofToDataPath("movies\\",true).back(), '\\', "absolute ofToDataPath with \\ should end in \\"); - ofxTestEq(ofToDataPath("movies",true).back(), 's', "absolute ofToDataPath without \\ should not end in \\"); + ofxTestEq(ofToDataPath("movies\\",true).string().back(), '\\', "absolute ofToDataPath with \\ should end in \\"); + ofxTestEq(ofToDataPath("movies",true).string().back(), 's', "absolute ofToDataPath without \\ should not end in \\"); }else{ - ofxTestEq(ofToDataPath("movies/",true).back(), '/', "absolute ofToDataPath with / should end in /"); - ofxTestEq(ofToDataPath("movies",true).back(), 's', "absolute ofToDataPath without / should not end in /"); + ofxTestEq(ofToDataPath("movies/",true).string().back(), '/', "absolute ofToDataPath with / should end in /"); + ofxTestEq(ofToDataPath("movies",true).string().back(), 's', "absolute ofToDataPath without / should not end in /"); ofDirectory("movies").create(); - ofxTestEq(ofToDataPath("movies/",true).back(), '/', "absolute ofToDataPath with / should end in /"); - ofxTestEq(ofToDataPath("movies",true).back(), 's', "absolute ofToDataPath without / should not end in /"); + ofxTestEq(ofToDataPath("movies/",true).string().back(), '/', "absolute ofToDataPath with / should end in /"); + ofxTestEq(ofToDataPath("movies",true).string().back(), 's', "absolute ofToDataPath without / should not end in /"); } //======================================================================== ofLogNotice() << ""; ofLogNotice() << "tests #4598"; - ofxTestEq(ofToDataPath("").back(), std::filesystem::path::preferred_separator, "ofToDataPath with empty string shouldn't crash"); + ofxTestEq(ofToDataPath("").string().back(), std::filesystem::path::preferred_separator, "ofToDataPath with empty string shouldn't crash"); //======================================================================== ofLogNotice() << ""; ofLogNotice() << "tests #4563"; #ifdef TARGET_LINUX - ofxTestEq(ofToDataPath("a.txt"), "data/a.txt","#4563 test1"); - ofxTestEq(ofToDataPath("data.txt"), "data/data.txt", "#4563 test2"); - ofxTestEq(ofToDataPath(""), "data/", "#4563 test3"); + ofxTestEq(ofToDataPath("a.txt").string(), "data/a.txt","#4563 test1"); + ofxTestEq(ofToDataPath("data.txt").string(), "data/data.txt", "#4563 test2"); + ofxTestEq(ofToDataPath("").string(), "data/", "#4563 test3"); #elif defined(TARGET_OSX) - ofxTestEq(ofToDataPath("a.txt"), "../../../data/a.txt","#4563 test1"); - ofxTestEq(ofToDataPath("data.txt"), "../../../data/data.txt", "#4563 test2"); - ofxTestEq(ofToDataPath(""), "../../../data/", "#4563 test3"); + ofxTestEq(ofToDataPath("a.txt").string(), "../../../data/a.txt","#4563 test1"); + ofxTestEq(ofToDataPath("data.txt").string(), "../../../data/data.txt", "#4563 test2"); + ofxTestEq(ofToDataPath("").string(), "../../../data/", "#4563 test3"); #endif @@ -268,12 +268,12 @@ class ofApp: public ofxUnitTestsApp{ dir.remove(true); if(ofGetTargetPlatform()==OF_TARGET_WINVS || ofGetTargetPlatform()==OF_TARGET_MINGW){ ofDirectory currentVideoDirectory(ofToDataPath("..\\..\\..\\video", true)); - auto path = currentVideoDirectory.path(); + auto path = currentVideoDirectory.path().string(); std::string pathEnd("data\\..\\..\\..\\video\\"); ofxTestEq(path.substr(path.size()-pathEnd.size()), pathEnd, "#4564"); }else{ ofDirectory currentVideoDirectory(ofToDataPath("../../../video", true)); - auto path = currentVideoDirectory.path(); + auto path = currentVideoDirectory.path().string(); std::string pathEnd("data/../../../video/"); ofxTestEq(path.substr(path.size()-pathEnd.size()), pathEnd, "#4564"); } From 405273ba305e19f75f9aec83764f65f16345ccd7 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 13 Aug 2022 23:38:08 -0300 Subject: [PATCH 10/91] fix other platforms --- libs/openFrameworks/graphics/ofCairoRenderer.cpp | 4 ++-- libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp | 2 +- libs/openFrameworks/utils/ofSystemUtils.cpp | 10 +++++----- libs/openFrameworks/utils/ofXml.cpp | 4 ++-- libs/openFrameworks/video/ofAVFoundationPlayer.mm | 2 +- libs/openFrameworks/video/ofQTKitGrabber.mm | 2 +- libs/openFrameworks/video/ofQTKitPlayer.mm | 2 +- libs/openFrameworks/video/ofQuickTimePlayer.cpp | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libs/openFrameworks/graphics/ofCairoRenderer.cpp b/libs/openFrameworks/graphics/ofCairoRenderer.cpp index 7464c859500..e13935d3891 100644 --- a/libs/openFrameworks/graphics/ofCairoRenderer.cpp +++ b/libs/openFrameworks/graphics/ofCairoRenderer.cpp @@ -73,14 +73,14 @@ void ofCairoRenderer::setup(const std::string & _filename, Type _type, bool mult if(filename==""){ surface = cairo_pdf_surface_create_for_stream(&ofCairoRenderer::stream_function,this,outputsize.width, outputsize.height); }else{ - surface = cairo_pdf_surface_create(ofToDataPath(filename).c_str(),outputsize.width, outputsize.height); + surface = cairo_pdf_surface_create(ofToDataPath(filename).string().c_str(),outputsize.width, outputsize.height); } break; case SVG: if(filename==""){ surface = cairo_svg_surface_create_for_stream(&ofCairoRenderer::stream_function,this,outputsize.width, outputsize.height); }else{ - surface = cairo_svg_surface_create(ofToDataPath(filename).c_str(),outputsize.width, outputsize.height); + surface = cairo_svg_surface_create(ofToDataPath(filename).string().c_str(),outputsize.width, outputsize.height); } break; case IMAGE: diff --git a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp index 64881987980..c2317cc8da0 100644 --- a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp @@ -480,7 +480,7 @@ bool ofOpenALSoundPlayer::readFile(const of::filesystem::path& fileName, std::ve //------------------------------------------------------------ bool ofOpenALSoundPlayer::load(const of::filesystem::path& _fileName, bool is_stream){ - of::filesystem::path fileName = ofToDataPath(_fileName); + auto fileName = ofToDataPath(_fileName); bMultiPlay = false; isStreaming = is_stream; diff --git a/libs/openFrameworks/utils/ofSystemUtils.cpp b/libs/openFrameworks/utils/ofSystemUtils.cpp index 87aaa317778..4aa9b20a9de 100644 --- a/libs/openFrameworks/utils/ofSystemUtils.cpp +++ b/libs/openFrameworks/utils/ofSystemUtils.cpp @@ -333,7 +333,7 @@ static int CALLBACK loadDialogBrowseCallback( std::string defaultPath = *(std::string*)lpData; if(defaultPath!="" && uMsg==BFFM_INITIALIZED){ wchar_t wideCharacterBuffer[MAX_PATH]; - wcscpy(wideCharacterBuffer, convertNarrowToWide(ofToDataPath(defaultPath)).c_str()); + wcscpy(wideCharacterBuffer, convertNarrowToWide(ofToDataPath(defaultPath).string()).c_str()); SendMessage(hwnd,BFFM_SETSELECTION,1,(LPARAM)wideCharacterBuffer); } @@ -414,7 +414,7 @@ ofFileDialogResult ofSystemLoadDialog(std::string windowTitle, bool bFolderSelec //the title if specified wchar_t szTitle[MAX_PATH]; if(defaultPath!=""){ - wcscpy(szDir,convertNarrowToWide(ofToDataPath(defaultPath)).c_str()); + wcscpy(szDir,convertNarrowToWide(ofToDataPath(defaultPath).string()).c_str()); ofn.lpstrInitialDir = szDir; } @@ -490,8 +490,8 @@ ofFileDialogResult ofSystemLoadDialog(std::string windowTitle, bool bFolderSelec //---------------------------------------------------------------------------------------- #if defined( TARGET_LINUX ) && defined (OF_USING_GTK) auto locale = std::locale(); - if(bFolderSelection) results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,windowTitle,ofToDataPath(defaultPath)); - else results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_OPEN,windowTitle,ofToDataPath(defaultPath)); + if(bFolderSelection) results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,windowTitle,ofToDataPath(defaultPath).string()); + else results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_OPEN,windowTitle,ofToDataPath(defaultPath).string()); resetLocale(locale); #endif //---------------------------------------------------------------------------------------- @@ -573,7 +573,7 @@ ofFileDialogResult ofSystemSaveDialog(std::string defaultName, std::string messa //---------------------------------------------------------------------------------------- #if defined( TARGET_LINUX ) && defined (OF_USING_GTK) auto locale = std::locale(); - results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_SAVE, messageName, ofToDataPath(defaultName)); + results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_SAVE, messageName, ofToDataPath(defaultName).string()); resetLocale(locale); #endif //---------------------------------------------------------------------------------------- diff --git a/libs/openFrameworks/utils/ofXml.cpp b/libs/openFrameworks/utils/ofXml.cpp index 5d9dff1de62..af4675eb837 100644 --- a/libs/openFrameworks/utils/ofXml.cpp +++ b/libs/openFrameworks/utils/ofXml.cpp @@ -51,14 +51,14 @@ bool ofXml::parse(const std::string & xmlStr){ bool ofXml::save(const of::filesystem::path & file) const{ if(xml == doc->root()){ - auto res = doc->save_file(ofToDataPath(file).c_str()); + auto res = doc->save_file(ofToDataPath(file).string().c_str()); ofLogVerbose("ofXml")<<"ofXML Save : "<< res; ofLogVerbose("ofXml")<toString(); return res; }else{ pugi::xml_document doc; if(doc.append_copy(xml.root())){ - return doc.save_file(ofToDataPath(file).c_str()); + return doc.save_file(ofToDataPath(file).string().c_str()); } } return false; diff --git a/libs/openFrameworks/video/ofAVFoundationPlayer.mm b/libs/openFrameworks/video/ofAVFoundationPlayer.mm index 24c78410de0..46cd175cef3 100644 --- a/libs/openFrameworks/video/ofAVFoundationPlayer.mm +++ b/libs/openFrameworks/video/ofAVFoundationPlayer.mm @@ -69,7 +69,7 @@ } NSString * videoPath = [NSString stringWithUTF8String:name.c_str()]; - NSString * videoLocalPath = [NSString stringWithUTF8String:ofToDataPath(name).c_str()]; + NSString * videoLocalPath = [NSString stringWithUTF8String:ofToDataPath(name).string().c_str()]; BOOL bStream = NO; diff --git a/libs/openFrameworks/video/ofQTKitGrabber.mm b/libs/openFrameworks/video/ofQTKitGrabber.mm index 240712b076b..b5b0a8100ab 100644 --- a/libs/openFrameworks/video/ofQTKitGrabber.mm +++ b/libs/openFrameworks/video/ofQTKitGrabber.mm @@ -781,7 +781,7 @@ - (void) dealloc void ofQTKitGrabber::startRecording(string filePath){ if(confirmInit()){ @autoreleasepool { - NSString * NSfilePath = [NSString stringWithUTF8String: ofToDataPath(filePath).c_str()]; + NSString * NSfilePath = [NSString stringWithUTF8String: ofToDataPath(filePath).string().c_str()]; [grabber startRecording:NSfilePath]; } } diff --git a/libs/openFrameworks/video/ofQTKitPlayer.mm b/libs/openFrameworks/video/ofQTKitPlayer.mm index c2ee3744610..864839baa21 100644 --- a/libs/openFrameworks/video/ofQTKitPlayer.mm +++ b/libs/openFrameworks/video/ofQTKitPlayer.mm @@ -53,7 +53,7 @@ isURL = true; } else { - movieFilePath = ofToDataPath(movieFilePath, false); + movieFilePath = ofToDataPath(movieFilePath, false).string(); } moviePlayer = [[QTKitMovieRenderer alloc] init]; diff --git a/libs/openFrameworks/video/ofQuickTimePlayer.cpp b/libs/openFrameworks/video/ofQuickTimePlayer.cpp index 56c0ca6fd8a..dcf41c59ceb 100644 --- a/libs/openFrameworks/video/ofQuickTimePlayer.cpp +++ b/libs/openFrameworks/video/ofQuickTimePlayer.cpp @@ -302,7 +302,7 @@ bool ofQuickTimePlayer::load(string name){ if( name.substr(0, 7) == "http://" || name.substr(0,7) == "rtsp://" ){ if(! createMovieFromURL(name, moviePtr) ) return false; }else{ - name = ofToDataPath(name); + name = ofToDataPath(name).string(); if( !createMovieFromPath((char *)name.c_str(), moviePtr) ) return false; } From 9dcd50e89246bd5fe235fd6895bb6b967f37774d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 13 Aug 2022 23:50:26 -0300 Subject: [PATCH 11/91] assimp fix --- .../ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp | 11 ++++++----- libs/openFrameworks/utils/ofFileUtils.cpp | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index 8d0e4afa366..c2be5cdfb26 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -49,7 +49,7 @@ bool ofxAssimpModelLoader::load(string modelName, bool optimize){ unsigned int flags = initImportProperties(optimize); // loads scene from file - std::string path = file.getAbsolutePath(); + std::string path = file.getAbsolutePath().string(); scene = shared_ptr(aiImportFileExWithProperties(path.c_str(), flags, NULL, store.get()), aiReleaseImport); bool bOk = processScene(); @@ -254,10 +254,11 @@ void ofxAssimpModelLoader::loadGLResources(){ // TODO: handle other aiTextureTypes if(AI_SUCCESS == mtl->GetTexture(aiTextureType_DIFFUSE, texIndex, &texPath)){ ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource(): loading image from \"" << texPath.data << "\""; - string modelFolder = file.getEnclosingDirectory(); - string relTexPath = ofFilePath::getEnclosingDirectory(texPath.data,false); - string texFile = ofFilePath::getFileName(texPath.data); - string realPath = ofFilePath::join(ofFilePath::join(modelFolder, relTexPath), texFile); + auto modelFolder = file.getEnclosingDirectory(); + auto relTexPath = ofFilePath::getEnclosingDirectory(texPath.data,false); + auto texFile = ofFilePath::getFileName(texPath.data); + + auto realPath = ofFilePath::join(ofFilePath::join(modelFolder, relTexPath), texFile); if(ofFile::doesFileExist(realPath) == false) { ofLogError("ofxAssimpModelLoader") << "loadGLResource(): texture doesn't exist: \"" diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 13b8935c781..a31b6432d43 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -1801,6 +1801,10 @@ string ofFilePath::join(const of::filesystem::path& path1, const of::filesystem: return (of::filesystem::path(path1) / of::filesystem::path(path2)).string(); } +of::filesystem::path ofFilePath::join(const of::filesystem::path& path1, const of::filesystem::path& path2){ + return (of::filesystem::path(path1) / of::filesystem::path(path2)); +} + //------------------------------------------------------------------------------------------------------------ string ofFilePath::getCurrentExePath(){ #if defined(TARGET_LINUX) || defined(TARGET_ANDROID) From 2011155e8630f1ce97a8925c823a32c6b404d6e0 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 13 Aug 2022 23:54:02 -0300 Subject: [PATCH 12/91] join fix --- libs/openFrameworks/utils/ofFileUtils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index c2d747deadc..d7a980a0219 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -414,7 +414,8 @@ class ofFilePath{ /// \param path2 right half of the path to join /// \returns joined path static std::string join(const of::filesystem::path& path1, const of::filesystem::path& path2); - + static of::filesystem::path join(const of::filesystem::path& path1, const of::filesystem::path& path2); + /// Get the full path to the application's executable file. /// /// Mac: the binary within the application's .app bundle Contents/MacOS dir From 63a3de1977fd5d50cae0c33235d9bebf158fc240 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 09:33:25 -0300 Subject: [PATCH 13/91] more updates --- libs/openFrameworks/utils/ofFileUtils.cpp | 13 ++++++++----- libs/openFrameworks/utils/ofFileUtils.h | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index a31b6432d43..d05888ceb91 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -1699,8 +1699,11 @@ string ofFilePath::getFileExt(const of::filesystem::path& filename){ } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::removeExt(const of::filesystem::path& filename){ - return ofFilePath::join(getEnclosingDirectory(filename,false), ofFile(filename,ofFile::Reference).getBaseName()); +// FIXME: remove const and copy +of::filesystem::path ofFilePath::removeExt(const of::filesystem::path& _filename){ + auto filename = _filename; + return filename.replace_extension(); +// return ofFilePath::join(getEnclosingDirectory(filename,false), ofFile(filename,ofFile::Reference).getBaseName()); } @@ -1797,9 +1800,9 @@ string ofFilePath::getCurrentWorkingDirectory(){ } //------------------------------------------------------------------------------------------------------------ -string ofFilePath::join(const of::filesystem::path& path1, const of::filesystem::path& path2){ - return (of::filesystem::path(path1) / of::filesystem::path(path2)).string(); -} +//string ofFilePath::join(const of::filesystem::path& path1, const of::filesystem::path& path2){ +// return (of::filesystem::path(path1) / of::filesystem::path(path2)).string(); +//} of::filesystem::path ofFilePath::join(const of::filesystem::path& path1, const of::filesystem::path& path2){ return (of::filesystem::path(path1) / of::filesystem::path(path2)); diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index d7a980a0219..761579bc18d 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -305,7 +305,7 @@ class ofFilePath{ /// /// \param filename file path /// \returns filename without extension - static std::string removeExt(const of::filesystem::path& filename); + static of::filesystem::path removeExt(const of::filesystem::path& filename); /// Prepend path with a slash, ie. "images" -> "/images". /// @@ -413,7 +413,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 of::filesystem::path& path1, const of::filesystem::path& path2); +// static std::string join(const of::filesystem::path& path1, const of::filesystem::path& path2); static of::filesystem::path join(const of::filesystem::path& path1, const of::filesystem::path& path2); /// Get the full path to the application's executable file. From d85de52563e93a109546d036b56f55c6224c4321 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 09:42:09 -0300 Subject: [PATCH 14/91] more updates --- libs/openFrameworks/utils/ofFileUtils.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index d05888ceb91..4a4adb10b62 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -39,11 +39,13 @@ namespace{ #elif defined TARGET_ANDROID return string("sdcard/"); #else - try{ - return of::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); - }catch(...){ - return ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/"); - } + return ofFilePath::getCurrentExeDir() / "data/"; + // FIXME: Cleanup comments +// try{ +// return of::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); +// }catch(...){ +// return ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/"); +// } #endif } From 768da30a90ff262b6d32694aa13b02864823cc54 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 09:49:18 -0300 Subject: [PATCH 15/91] more updates 3 --- libs/openFrameworks/utils/ofFileUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 4a4adb10b62..e7ad42c7e60 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -39,7 +39,7 @@ namespace{ #elif defined TARGET_ANDROID return string("sdcard/"); #else - return ofFilePath::getCurrentExeDir() / "data/"; + return ofFilePath::getCurrentExeDir() / os::filesystem::path("data/"); // FIXME: Cleanup comments // try{ // return of::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); From 87e7ee493ba649fb7071eeb9b585cdeb6a62f50c Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 09:53:17 -0300 Subject: [PATCH 16/91] more updates 5 --- libs/openFrameworks/utils/ofFileUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index e7ad42c7e60..512df6333ed 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -39,7 +39,7 @@ namespace{ #elif defined TARGET_ANDROID return string("sdcard/"); #else - return ofFilePath::getCurrentExeDir() / os::filesystem::path("data/"); + return ofFilePath::getCurrentExeDir() / of::filesystem::path("data/"); // FIXME: Cleanup comments // try{ // return of::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); From 2c2397d4a8ee098231b342803841d7321a7fb02a Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 11:48:07 -0300 Subject: [PATCH 17/91] more 6 --- libs/openFrameworks/utils/ofFileUtils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 512df6333ed..32033f9d5f6 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -26,7 +26,7 @@ namespace{ bool enableDataPath = true; //-------------------------------------------------- - string defaultDataPath(){ + of::filesystem::path defaultDataPath(){ #if defined TARGET_OSX return (ofFilePath::getCurrentExeDir() / "../../../data/").string(); // try{ @@ -39,7 +39,7 @@ namespace{ #elif defined TARGET_ANDROID return string("sdcard/"); #else - return ofFilePath::getCurrentExeDir() / of::filesystem::path("data/"); + return (ofFilePath::getCurrentExeDir() / of::filesystem::path("data/")).string(); // FIXME: Cleanup comments // try{ // return of::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); From f99500e89057bea0131d3ac9d144d417a686b7c9 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 12:20:20 -0300 Subject: [PATCH 18/91] update 7 --- addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index c2be5cdfb26..ba8ad330b74 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -258,7 +258,9 @@ void ofxAssimpModelLoader::loadGLResources(){ auto relTexPath = ofFilePath::getEnclosingDirectory(texPath.data,false); auto texFile = ofFilePath::getFileName(texPath.data); - auto realPath = ofFilePath::join(ofFilePath::join(modelFolder, relTexPath), texFile); + // FIXME: addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h could accept filesystem::path as a parameter + // ofLoadImage accept? + auto realPath = ofFilePath::join(ofFilePath::join(modelFolder, relTexPath), texFile).string(); if(ofFile::doesFileExist(realPath) == false) { ofLogError("ofxAssimpModelLoader") << "loadGLResource(): texture doesn't exist: \"" From 9e580bfad9263a7285125cf3b4f4d3df34f3653f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 12:40:19 -0300 Subject: [PATCH 19/91] fix 8 --- addons/ofxOpenCv/src/ofxCvHaarFinder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ofxOpenCv/src/ofxCvHaarFinder.cpp b/addons/ofxOpenCv/src/ofxCvHaarFinder.cpp index 75388893ec4..0ba430ab794 100644 --- a/addons/ofxOpenCv/src/ofxCvHaarFinder.cpp +++ b/addons/ofxOpenCv/src/ofxCvHaarFinder.cpp @@ -53,7 +53,7 @@ void ofxCvHaarFinder::setup(std::string haarFile) { this->haarFile = haarFile; - haarFile = ofToDataPath(haarFile); + haarFile = ofToDataPath(haarFile).string(); #ifdef USE_OLD_CV if(cascade != NULL) cvReleaseHaarClassifierCascade(&cascade); From 0cbe497044352fe3555ae29f6222a3a006ec5f47 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 17:16:07 -0300 Subject: [PATCH 20/91] up 9 --- addons/ofxXmlSettings/src/ofxXmlSettings.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/ofxXmlSettings/src/ofxXmlSettings.cpp b/addons/ofxXmlSettings/src/ofxXmlSettings.cpp index 41bfa0f8ffe..70fd72233fe 100644 --- a/addons/ofxXmlSettings/src/ofxXmlSettings.cpp +++ b/addons/ofxXmlSettings/src/ofxXmlSettings.cpp @@ -48,7 +48,7 @@ ofxXmlSettings::ofxXmlSettings(const string& xmlFile): //we do this so that we have a valid handle //without the need for loadFile storedHandle = TiXmlHandle(&doc); - loadFile(xmlFile); + load(xmlFile); } //--------------------------------------------------------- @@ -73,8 +73,8 @@ void ofxXmlSettings::clear(){ //--------------------------------------------------------- bool ofxXmlSettings::load(const string& xmlFile){ - string fullXmlFile = ofToDataPath(xmlFile); - bool loadOkay = doc.LoadFile(fullXmlFile); + auto fullXmlFile = ofToDataPath(xmlFile); + bool loadOkay = doc.LoadFile(fullXmlFile.string()); //theo removed bool check as it would //return false if the file exists but was @@ -89,8 +89,8 @@ bool ofxXmlSettings::load(const string& xmlFile){ //--------------------------------------------------------- bool ofxXmlSettings::save(const string& xmlFile){ - string fullXmlFile = ofToDataPath(xmlFile); - return doc.SaveFile(fullXmlFile); + auto fullXmlFile = ofToDataPath(xmlFile); + return doc.SaveFile(fullXmlFile.string()); } //--------------------------------------------------------- From 3011a65fb75393a3ac2ec547d28606acb7678b4d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 17:37:30 -0300 Subject: [PATCH 21/91] workflows and ofxSvg --- .github/workflows/build-android.yml | 46 ------------------------ .github/workflows/build-emscripten.yml | 34 ------------------ .github/workflows/build-ios-tvos.yml | 33 ----------------- .github/workflows/build-macos.yml | 41 --------------------- .github/workflows/build-msys2.yml | 42 ---------------------- .github/workflows/build-vs.yml | 50 -------------------------- addons/ofxSvg/src/ofxSvg.cpp | 2 +- 7 files changed, 1 insertion(+), 247 deletions(-) delete mode 100644 .github/workflows/build-android.yml delete mode 100644 .github/workflows/build-emscripten.yml delete mode 100644 .github/workflows/build-ios-tvos.yml delete mode 100644 .github/workflows/build-macos.yml delete mode 100644 .github/workflows/build-msys2.yml delete mode 100644 .github/workflows/build-vs.yml diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml deleted file mode 100644 index 78b989d20c5..00000000000 --- a/.github/workflows/build-android.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: build-android - -on: - push: - paths-ignore: - - '**/*.md' - pull_request: - paths-ignore: - - '**/*.md' - -jobs: - - build-android: - runs-on: ubuntu-18.04 - strategy: - matrix: - cfg: - - {target: android, gradle_target: compileArm7DebugSources} - - {target: android, gradle_target: compileX86DebugSources} - - env: - TARGET: ${{matrix.cfg.target}} - GRADLE_TARGET: ${{matrix.cfg.gradle_target}} - NDK_DIR: android-ndk-r15c - steps: - - uses: actions/checkout@v2 - - name: Cache projectGenerator folder - uses: actions/cache@v2 - with: - path: '~/projectGenerator' - key: ${{ runner.os }}-pg-${{matrix.cfg.gradle_target}} - - name: Cache NDK - uses: actions/cache@v2 - with: - path: '~/android-ndk-r15c' - key: ${{ runner.os }}-android-ndk-${{matrix.cfg.gradle_target}} - - name: install - run: ./scripts/ci/$TARGET/install.sh - - name: Download libs - run: ./scripts/$TARGET/download_libs.sh - - name: Build - run: ./scripts/ci/$TARGET/build.sh - - name: Upload Libs - run: scripts/ci/upload_of_lib.sh; - env: - GA_CI_SECRET: ${{ secrets.CI_SECRET }} diff --git a/.github/workflows/build-emscripten.yml b/.github/workflows/build-emscripten.yml deleted file mode 100644 index 92ea6720615..00000000000 --- a/.github/workflows/build-emscripten.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: build-emscripten - -on: - push: - paths-ignore: - - '**/*.md' - pull_request: - paths-ignore: - - '**/*.md' - -jobs: - - build-emscripten: - runs-on: ubuntu-18.04 - strategy: - matrix: - cfg: - - {target: emscripten} - env: - TARGET: ${{matrix.cfg.target}} - steps: - - uses: actions/checkout@v2 - - name: Docker Step - run: "docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:1.40.0 bash" - - name: Download libs - run: ./scripts/$TARGET/download_libs.sh - - name: Install dependencies - run: ./scripts/ci/$TARGET/install.sh - - name: Build - run: docker exec -i emscripten sh -c "scripts/ci/$TARGET/build.sh"; - - name: Upload Libs - run: scripts/ci/upload_of_lib.sh; - env: - GA_CI_SECRET: ${{ secrets.CI_SECRET }} diff --git a/.github/workflows/build-ios-tvos.yml b/.github/workflows/build-ios-tvos.yml deleted file mode 100644 index 0d3369143d5..00000000000 --- a/.github/workflows/build-ios-tvos.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: build-ios-tvos - -on: - push: - paths-ignore: - - '**/*.md' - pull_request: - paths-ignore: - - '**/*.md' - -jobs: - - build-osx: - runs-on: macos-10.15 - strategy: - matrix: - cfg: - - {target: ios, libs: ios} - - {target: tvos, libs: ios} - env: - TARGET: ${{matrix.cfg.target}} - steps: - - uses: actions/checkout@v2 - - name: Download libs - run: ./scripts/${{matrix.cfg.libs}}/download_libs.sh - - name: install - run: ./scripts/ci/$TARGET/install.sh - - name: Build - run: ./scripts/ci/$TARGET/build.sh; - - env: - DEVELOPER_DIR: "/Applications/Xcode_11.2.app/Contents/Developer" - diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml deleted file mode 100644 index d3d01579a84..00000000000 --- a/.github/workflows/build-macos.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: build-macos - -on: - push: - paths-ignore: - - '**/*.md' - pull_request: - paths-ignore: - - '**/*.md' - -jobs: - - build-osx: - runs-on: macos-10.15 - strategy: - matrix: - cfg: - - {target: osx, opt: ""} - - {target: osx, opt: "makefiles"} - env: - TARGET: ${{matrix.cfg.target}} - OPT: ${{matrix.cfg.opt}} - steps: - - uses: actions/checkout@v2 - - name: Download libs - run: ./scripts/$TARGET/download_libs.sh - - name: rm-dev - run: sudo rm -rf /Library/Developer - - name: install - run: ./scripts/ci/$TARGET/install.sh - - name: Build - run: - if [ "$TARGET" = "osx" ] && [ "$OPT" = "makefiles" ]; then - scripts/ci/$TARGET/run_tests.sh; - else - scripts/ci/$TARGET/build.sh $OPT; - fi - env: - DEVELOPER_DIR: "/Applications/Xcode_12.2.app/Contents/Developer" - SDKROOT: "/Applications/Xcode_12.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" - diff --git a/.github/workflows/build-msys2.yml b/.github/workflows/build-msys2.yml deleted file mode 100644 index 10d89c49432..00000000000 --- a/.github/workflows/build-msys2.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: build-msys2 - -on: - push: - paths-ignore: - - '**/*.md' - pull_request: - paths-ignore: - - '**/*.md' - -jobs: - - build-msys2: - runs-on: windows-latest - strategy: - matrix: - mingw: [MINGW64, MINGW32] - defaults: - run: - shell: msys2 {0} - steps: - - uses: actions/checkout@v2 - - uses: msys2/setup-msys2@v2 - with: - update: true - install: >- - git - unzip - rsync - wget - - name: Install dependencies - run: ./scripts/ci/msys2/install.sh - env: - MSYSTEM: ${{ matrix.mingw }} - - name: Build - run: ./scripts/ci/msys2/build.sh - env: - MSYSTEM: ${{ matrix.mingw }} - - name: Run tests - run: ./scripts/ci/msys2/run_tests.sh - env: - MSYSTEM: ${{ matrix.mingw }} diff --git a/.github/workflows/build-vs.yml b/.github/workflows/build-vs.yml deleted file mode 100644 index c88bcdbf3fe..00000000000 --- a/.github/workflows/build-vs.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: build-vs - -on: - push: - paths-ignore: - - '**/*.md' - pull_request: - paths-ignore: - - '**/*.md' - -jobs: - - build-vs2019: - runs-on: windows-2019 - strategy: - matrix: - include: - - platform: x64 - bits: 64 - env: - BITS: ${{ matrix.bits }} - steps: - - name: Clone repository - uses: actions/checkout@v2 - - uses: msys2/setup-msys2@v2 - with: - update: true - install: >- - git - unzip - rsync - wget - - name: Install dependencies - shell: msys2 {0} - run: - ./scripts/ci/vs/install.sh - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1.1 - - name: Build - working-directory: ${{env.GITHUB_WORKSPACE}} - run: - msbuild libs/openFrameworksCompiled/project/vs/openframeworksLib.vcxproj /p:configuration=release /p:platform=${{ matrix.platform }} - - name: Build emptyExample - working-directory: ${{env.GITHUB_WORKSPACE}} - run: - msbuild examples/templates/emptyExample/emptyExample.vcxproj /p:configuration=release /p:platform=${{ matrix.platform }} - - name: Build allAddonsExample - working-directory: ${{env.GITHUB_WORKSPACE}} - run: - msbuild examples/templates/allAddonsExample/allAddonsExample.vcxproj /p:configuration=release /p:platform=${{ matrix.platform }} diff --git a/addons/ofxSvg/src/ofxSvg.cpp b/addons/ofxSvg/src/ofxSvg.cpp index 670658a6575..7d629cd680c 100644 --- a/addons/ofxSvg/src/ofxSvg.cpp +++ b/addons/ofxSvg/src/ofxSvg.cpp @@ -27,7 +27,7 @@ ofPath & ofxSvg::getPathAt(int n){ } void ofxSvg::load(std::string path){ - path = ofToDataPath(path); + path = ofToDataPath(path).string(); if(path.compare("") == 0){ ofLogError("ofxSVG") << "load(): path does not exist: \"" << path << "\""; From 171310ca2b7ddd834dc896fe277f45bbaee726d7 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 22:37:37 -0300 Subject: [PATCH 22/91] up 10 --- .github/workflows/build-linux.yml | 4 ++-- tests/utils/fileUtils/src/main.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index fe7bba6bccf..8dfed8d6e5a 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -16,8 +16,8 @@ jobs: matrix: cfg: - {target: linux64, libs: 64gcc6} - - {target: linuxarmv6l, libs: armv6l} - - {target: linuxarmv7l, libs: armv7l} + # - {target: linuxarmv6l, libs: armv6l} + # - {target: linuxarmv7l, libs: armv7l} env: TARGET: ${{matrix.cfg.target}} steps: diff --git a/tests/utils/fileUtils/src/main.cpp b/tests/utils/fileUtils/src/main.cpp index 3814d99b7ec..0ba2195dcd8 100644 --- a/tests/utils/fileUtils/src/main.cpp +++ b/tests/utils/fileUtils/src/main.cpp @@ -4,7 +4,7 @@ using namespace std; -std::filesystem::path initial_cwd; +of::filesystem::path initial_cwd; class ofApp: public ofxUnitTestsApp{ void run(){ @@ -185,8 +185,8 @@ class ofApp: public ofxUnitTestsApp{ ofxTestEq(ofFilePath::join("d1","d2"),"d1/d2","ofFilePath::join",ofFilePath::join("d1","d2")); #endif - ofxTest(std::filesystem::exists(ofFile("test.txt")), "ofFile cast to filesystem::path"); - ofxTest(std::filesystem::exists(ofDirectory("d1")), "ofDirectory cast to filesystem::path"); + ofxTest(of::filesystem::exists(ofFile("test.txt")), "ofFile cast to filesystem::path"); + ofxTest(of::filesystem::exists(ofDirectory("d1")), "ofDirectory cast to filesystem::path"); @@ -204,7 +204,7 @@ class ofApp: public ofxUnitTestsApp{ //======================================================================== ofLogNotice() << ""; ofLogNotice() << "tests #4299"; - ofxTestEq(std::filesystem::path(ofFilePath::getCurrentWorkingDirectory()), initial_cwd, "ofFilePath::getCurrentWorkingDirectory()"); + ofxTestEq(of::filesystem::path(ofFilePath::getCurrentWorkingDirectory()), initial_cwd, "ofFilePath::getCurrentWorkingDirectory()"); if(ofGetTargetPlatform()==OF_TARGET_OSX){ ofxTestEq(ofToDataPath("",false),"../../../data/","ofToDataPath relative"); }else if(ofGetTargetPlatform()==OF_TARGET_WINVS || ofGetTargetPlatform()==OF_TARGET_MINGW){ @@ -235,7 +235,7 @@ class ofApp: public ofxUnitTestsApp{ //======================================================================== ofLogNotice() << ""; ofLogNotice() << "tests #4598"; - ofxTestEq(ofToDataPath("").string().back(), std::filesystem::path::preferred_separator, "ofToDataPath with empty string shouldn't crash"); + ofxTestEq(ofToDataPath("").string().back(), of::filesystem::path::preferred_separator, "ofToDataPath with empty string shouldn't crash"); //======================================================================== ofLogNotice() << ""; @@ -285,7 +285,7 @@ class ofApp: public ofxUnitTestsApp{ #include "ofAppRunner.h" //======================================================================== int main( ){ - initial_cwd = std::filesystem::current_path(); + initial_cwd = of::filesystem::current_path(); ofInit(); auto window = std::make_shared(); auto app = std::make_shared(); From 0a0c8d7215a855eb174802ceff4feb471bbe5f00 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 22:57:09 -0300 Subject: [PATCH 23/91] actions --- .github/workflows/2/build-android.yml | 46 ++++++++++++++++++++++ .github/workflows/2/build-emscripten.yml | 34 ++++++++++++++++ .github/workflows/2/build-ios-tvos.yml | 33 ++++++++++++++++ .github/workflows/2/build-macos.yml | 41 +++++++++++++++++++ .github/workflows/2/build-msys2.yml | 42 ++++++++++++++++++++ .github/workflows/2/build-vs.yml | 50 ++++++++++++++++++++++++ .github/workflows/build-linux.yml | 9 ++++- 7 files changed, 254 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/2/build-android.yml create mode 100644 .github/workflows/2/build-emscripten.yml create mode 100644 .github/workflows/2/build-ios-tvos.yml create mode 100644 .github/workflows/2/build-macos.yml create mode 100644 .github/workflows/2/build-msys2.yml create mode 100644 .github/workflows/2/build-vs.yml diff --git a/.github/workflows/2/build-android.yml b/.github/workflows/2/build-android.yml new file mode 100644 index 00000000000..78b989d20c5 --- /dev/null +++ b/.github/workflows/2/build-android.yml @@ -0,0 +1,46 @@ +name: build-android + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +jobs: + + build-android: + runs-on: ubuntu-18.04 + strategy: + matrix: + cfg: + - {target: android, gradle_target: compileArm7DebugSources} + - {target: android, gradle_target: compileX86DebugSources} + + env: + TARGET: ${{matrix.cfg.target}} + GRADLE_TARGET: ${{matrix.cfg.gradle_target}} + NDK_DIR: android-ndk-r15c + steps: + - uses: actions/checkout@v2 + - name: Cache projectGenerator folder + uses: actions/cache@v2 + with: + path: '~/projectGenerator' + key: ${{ runner.os }}-pg-${{matrix.cfg.gradle_target}} + - name: Cache NDK + uses: actions/cache@v2 + with: + path: '~/android-ndk-r15c' + key: ${{ runner.os }}-android-ndk-${{matrix.cfg.gradle_target}} + - name: install + run: ./scripts/ci/$TARGET/install.sh + - name: Download libs + run: ./scripts/$TARGET/download_libs.sh + - name: Build + run: ./scripts/ci/$TARGET/build.sh + - name: Upload Libs + run: scripts/ci/upload_of_lib.sh; + env: + GA_CI_SECRET: ${{ secrets.CI_SECRET }} diff --git a/.github/workflows/2/build-emscripten.yml b/.github/workflows/2/build-emscripten.yml new file mode 100644 index 00000000000..92ea6720615 --- /dev/null +++ b/.github/workflows/2/build-emscripten.yml @@ -0,0 +1,34 @@ +name: build-emscripten + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +jobs: + + build-emscripten: + runs-on: ubuntu-18.04 + strategy: + matrix: + cfg: + - {target: emscripten} + env: + TARGET: ${{matrix.cfg.target}} + steps: + - uses: actions/checkout@v2 + - name: Docker Step + run: "docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:1.40.0 bash" + - name: Download libs + run: ./scripts/$TARGET/download_libs.sh + - name: Install dependencies + run: ./scripts/ci/$TARGET/install.sh + - name: Build + run: docker exec -i emscripten sh -c "scripts/ci/$TARGET/build.sh"; + - name: Upload Libs + run: scripts/ci/upload_of_lib.sh; + env: + GA_CI_SECRET: ${{ secrets.CI_SECRET }} diff --git a/.github/workflows/2/build-ios-tvos.yml b/.github/workflows/2/build-ios-tvos.yml new file mode 100644 index 00000000000..0d3369143d5 --- /dev/null +++ b/.github/workflows/2/build-ios-tvos.yml @@ -0,0 +1,33 @@ +name: build-ios-tvos + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +jobs: + + build-osx: + runs-on: macos-10.15 + strategy: + matrix: + cfg: + - {target: ios, libs: ios} + - {target: tvos, libs: ios} + env: + TARGET: ${{matrix.cfg.target}} + steps: + - uses: actions/checkout@v2 + - name: Download libs + run: ./scripts/${{matrix.cfg.libs}}/download_libs.sh + - name: install + run: ./scripts/ci/$TARGET/install.sh + - name: Build + run: ./scripts/ci/$TARGET/build.sh; + + env: + DEVELOPER_DIR: "/Applications/Xcode_11.2.app/Contents/Developer" + diff --git a/.github/workflows/2/build-macos.yml b/.github/workflows/2/build-macos.yml new file mode 100644 index 00000000000..d3d01579a84 --- /dev/null +++ b/.github/workflows/2/build-macos.yml @@ -0,0 +1,41 @@ +name: build-macos + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +jobs: + + build-osx: + runs-on: macos-10.15 + strategy: + matrix: + cfg: + - {target: osx, opt: ""} + - {target: osx, opt: "makefiles"} + env: + TARGET: ${{matrix.cfg.target}} + OPT: ${{matrix.cfg.opt}} + steps: + - uses: actions/checkout@v2 + - name: Download libs + run: ./scripts/$TARGET/download_libs.sh + - name: rm-dev + run: sudo rm -rf /Library/Developer + - name: install + run: ./scripts/ci/$TARGET/install.sh + - name: Build + run: + if [ "$TARGET" = "osx" ] && [ "$OPT" = "makefiles" ]; then + scripts/ci/$TARGET/run_tests.sh; + else + scripts/ci/$TARGET/build.sh $OPT; + fi + env: + DEVELOPER_DIR: "/Applications/Xcode_12.2.app/Contents/Developer" + SDKROOT: "/Applications/Xcode_12.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" + diff --git a/.github/workflows/2/build-msys2.yml b/.github/workflows/2/build-msys2.yml new file mode 100644 index 00000000000..10d89c49432 --- /dev/null +++ b/.github/workflows/2/build-msys2.yml @@ -0,0 +1,42 @@ +name: build-msys2 + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +jobs: + + build-msys2: + runs-on: windows-latest + strategy: + matrix: + mingw: [MINGW64, MINGW32] + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v2 + - uses: msys2/setup-msys2@v2 + with: + update: true + install: >- + git + unzip + rsync + wget + - name: Install dependencies + run: ./scripts/ci/msys2/install.sh + env: + MSYSTEM: ${{ matrix.mingw }} + - name: Build + run: ./scripts/ci/msys2/build.sh + env: + MSYSTEM: ${{ matrix.mingw }} + - name: Run tests + run: ./scripts/ci/msys2/run_tests.sh + env: + MSYSTEM: ${{ matrix.mingw }} diff --git a/.github/workflows/2/build-vs.yml b/.github/workflows/2/build-vs.yml new file mode 100644 index 00000000000..c88bcdbf3fe --- /dev/null +++ b/.github/workflows/2/build-vs.yml @@ -0,0 +1,50 @@ +name: build-vs + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +jobs: + + build-vs2019: + runs-on: windows-2019 + strategy: + matrix: + include: + - platform: x64 + bits: 64 + env: + BITS: ${{ matrix.bits }} + steps: + - name: Clone repository + uses: actions/checkout@v2 + - uses: msys2/setup-msys2@v2 + with: + update: true + install: >- + git + unzip + rsync + wget + - name: Install dependencies + shell: msys2 {0} + run: + ./scripts/ci/vs/install.sh + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1.1 + - name: Build + working-directory: ${{env.GITHUB_WORKSPACE}} + run: + msbuild libs/openFrameworksCompiled/project/vs/openframeworksLib.vcxproj /p:configuration=release /p:platform=${{ matrix.platform }} + - name: Build emptyExample + working-directory: ${{env.GITHUB_WORKSPACE}} + run: + msbuild examples/templates/emptyExample/emptyExample.vcxproj /p:configuration=release /p:platform=${{ matrix.platform }} + - name: Build allAddonsExample + working-directory: ${{env.GITHUB_WORKSPACE}} + run: + msbuild examples/templates/allAddonsExample/allAddonsExample.vcxproj /p:configuration=release /p:platform=${{ matrix.platform }} diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 8dfed8d6e5a..4c74330c71d 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -21,9 +21,15 @@ jobs: env: TARGET: ${{matrix.cfg.target}} steps: - - uses: actions/checkout@v2 + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x gstreamer0.10-plugins-bad gstreamer0.10-alsa gstreamer0.10-plugins-base gstreamer0.10-plugins-good + version: 1.0 + + - uses: actions/checkout@v3 - name: Download libs run: ./scripts/linux/download_libs.sh -a ${{matrix.cfg.libs}}; + - name: Install dependencies run: ./scripts/ci/$TARGET/install.sh; # - name: Install gcc4 @@ -32,6 +38,7 @@ jobs: # sudo apt-get update -q; # sudo apt-get install gcc-4.9 g++-4.9; # fi + - name: Build run: if [ "$TARGET" = "linux64" ]; then scripts/ci/$TARGET/build.sh; From a7c70ffbcc832d71fca24e92ae417f0001d61887 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:11:59 -0300 Subject: [PATCH 24/91] ccache --- .github/workflows/build-linux.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 4c74330c71d..757f9150b37 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -21,12 +21,15 @@ jobs: env: TARGET: ${{matrix.cfg.target}} steps: - - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x gstreamer0.10-plugins-bad gstreamer0.10-alsa gstreamer0.10-plugins-base gstreamer0.10-plugins-good - version: 1.0 + # - uses: awalsh128/cache-apt-pkgs-action@latest + # with: + # packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x gstreamer0.10-plugins-bad gstreamer0.10-alsa gstreamer0.10-plugins-base gstreamer0.10-plugins-good + # version: 1.0 - uses: actions/checkout@v3 + - run: apt update # Only for Docker jobs + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 - name: Download libs run: ./scripts/linux/download_libs.sh -a ${{matrix.cfg.libs}}; From 16c25a288f76d9a8bcf74316891f295f4faeda83 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:12:49 -0300 Subject: [PATCH 25/91] ccache --- .github/workflows/build-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 757f9150b37..d18c8ded79a 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -27,7 +27,7 @@ jobs: # version: 1.0 - uses: actions/checkout@v3 - - run: apt update # Only for Docker jobs + # - run: apt update # Only for Docker jobs - name: ccache uses: hendrikmuhs/ccache-action@v1.2 - name: Download libs From 685a2d9366c2cb4fb2e01d373ebec68a06bc7b6a Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:22:02 -0300 Subject: [PATCH 26/91] act --- .github/workflows/build-linux.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index d18c8ded79a..56cc1ef2329 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -21,15 +21,18 @@ jobs: env: TARGET: ${{matrix.cfg.target}} steps: - # - uses: awalsh128/cache-apt-pkgs-action@latest - # with: - # packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x gstreamer0.10-plugins-bad gstreamer0.10-alsa gstreamer0.10-plugins-base gstreamer0.10-plugins-good - # version: 1.0 - uses: actions/checkout@v3 # - run: apt update # Only for Docker jobs + - name: cachezinho + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x gstreamer0.10-plugins-bad gstreamer0.10-alsa gstreamer0.10-plugins-base gstreamer0.10-plugins-good + version: 1.0 + - name: ccache uses: hendrikmuhs/ccache-action@v1.2 + - name: Download libs run: ./scripts/linux/download_libs.sh -a ${{matrix.cfg.libs}}; From ccc8febd6e32b75a07424f37e255eb3ba4c4a106 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:23:29 -0300 Subject: [PATCH 27/91] act --- .github/workflows/build-linux.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 56cc1ef2329..e0bd23bf55b 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -27,12 +27,13 @@ jobs: - name: cachezinho uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x gstreamer0.10-plugins-bad gstreamer0.10-alsa gstreamer0.10-plugins-base gstreamer0.10-plugins-good + packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x gstreamer0.10-plugins-bad gstreamer0.10-plugins-base gstreamer0.10-plugins-good + # gstreamer0.10-alsa version: 1.0 - name: ccache uses: hendrikmuhs/ccache-action@v1.2 - + - name: Download libs run: ./scripts/linux/download_libs.sh -a ${{matrix.cfg.libs}}; From 6edfd282cb36505c74b87530dcac10a2ea9187e3 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:24:25 -0300 Subject: [PATCH 28/91] act --- .github/workflows/build-linux.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index e0bd23bf55b..92a5d0b3ec8 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -27,7 +27,8 @@ jobs: - name: cachezinho uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x gstreamer0.10-plugins-bad gstreamer0.10-plugins-base gstreamer0.10-plugins-good + packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x + gstreamer0.10-plugins-base gstreamer0.10-plugins-good # gstreamer0.10-alsa version: 1.0 From d1c0a84866dcecf43f120aa535327299995a0976 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:24:47 -0300 Subject: [PATCH 29/91] act --- .github/workflows/build-linux.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 92a5d0b3ec8..bee611a12cc 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -27,8 +27,7 @@ jobs: - name: cachezinho uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x - gstreamer0.10-plugins-base gstreamer0.10-plugins-good + packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x gstreamer0.10-plugins-base gstreamer0.10-plugins-good # gstreamer0.10-alsa version: 1.0 From 3135f5b44a1dfee9b002ecffd1cfc05a321034f8 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:25:49 -0300 Subject: [PATCH 30/91] act --- .github/workflows/build-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index bee611a12cc..60e8ae1252a 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -27,7 +27,7 @@ jobs: - name: cachezinho uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x gstreamer0.10-plugins-base gstreamer0.10-plugins-good + packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x # gstreamer0.10-alsa version: 1.0 From 7b6ee702dcf0d0e5f47be250d3b289664dc3fc19 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:27:19 -0300 Subject: [PATCH 31/91] act --- .github/workflows/build-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 60e8ae1252a..2c3b4f7e118 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -27,7 +27,7 @@ jobs: - name: cachezinho uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev ${GSTREAMER_FFMPEG} gstreamer0.10-pulseaudio gstreamer0.10-x + packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev gstreamer0.10-ffmpeg gstreamer0.10-x # gstreamer0.10-alsa version: 1.0 From d2d2f04f4fd12f0b4bc7e159e8b6734842af6ea1 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:30:49 -0300 Subject: [PATCH 32/91] actions --- .github/workflows/build-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 2c3b4f7e118..07497dc908f 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -27,7 +27,7 @@ jobs: - name: cachezinho uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev gstreamer0.10-ffmpeg gstreamer0.10-x + packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev gstreamer0.10-x # gstreamer0.10-alsa version: 1.0 From 98fcfa530a757beba820333593a09f8ccd42080c Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:31:39 -0300 Subject: [PATCH 33/91] actions --- .github/workflows/build-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 07497dc908f..89281163cb4 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -27,7 +27,7 @@ jobs: - name: cachezinho uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev gstreamer0.10-x + packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev # gstreamer0.10-alsa version: 1.0 From 5457d30c948cfaeb0a3c1caeb5c306b0afa7866f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:33:06 -0300 Subject: [PATCH 34/91] actions --- .github/workflows/build-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 89281163cb4..24a11349c92 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -27,7 +27,7 @@ jobs: - name: cachezinho uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev + packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 # gstreamer0.10-alsa version: 1.0 From 2b8fa6fa932971ff258a8282d515daea242c7f74 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:34:57 -0300 Subject: [PATCH 35/91] actions --- .github/workflows/build-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 24a11349c92..ea4979d9433 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -27,7 +27,7 @@ jobs: - name: cachezinho uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 + packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 # gstreamer0.10-alsa version: 1.0 From 4f5ee3903986912c109831000685d6de18c56e72 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Aug 2022 23:52:26 -0300 Subject: [PATCH 36/91] make -j -s --- .github/workflows/build-linux.yml | 3 ++- scripts/ci/linux64/build.sh | 6 +++--- scripts/ci/linuxarmv6l/build.sh | 6 +++--- scripts/ci/linuxarmv7l/build_junest.sh | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index ea4979d9433..21739ed1c82 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -27,7 +27,8 @@ jobs: - name: cachezinho uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 + packages: curl libjack-jackd2-0 libjack-jackd2-dev freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 + #PACKAGES="curl libjack-jackd2-0 libjack-jackd2-dev freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++${CXX_VER} libgl1-mesa-dev${XTAG} libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk${GTK_VERSION}-dev libopencv-dev libassimp-dev librtaudio-dev libboost-filesystem${BOOST_VER}-dev libgstreamer${GSTREAMER_VERSION}-dev libgstreamer-plugins-base${GSTREAMER_VERSION}-dev ${GSTREAMER_FFMPEG} gstreamer${GSTREAMER_VERSION}-pulseaudio gstreamer${GSTREAMER_VERSION}-x gstreamer${GSTREAMER_VERSION}-plugins-bad gstreamer${GSTREAMER_VERSION}-alsa gstreamer${GSTREAMER_VERSION}-plugins-base gstreamer${GSTREAMER_VERSION}-plugins-good gdb ${GLFW_PKG} liburiparser-dev libcurl4-openssl-dev libpugixml-dev libgconf-2-4 libgtk2.0-0 libpoco-dev libxcursor-dev libxi-dev libxinerama-dev" # gstreamer0.10-alsa version: 1.0 diff --git a/scripts/ci/linux64/build.sh b/scripts/ci/linux64/build.sh index 16920ec670a..34e839f00a6 100755 --- a/scripts/ci/linux64/build.sh +++ b/scripts/ci/linux64/build.sh @@ -25,16 +25,16 @@ else echo "PLATFORM_CFLAGS += $CUSTOMFLAGS" >> libs/openFrameworksCompiled/project/linux64/config.linux64.default.mk sed -i "s/PLATFORM_OPTIMIZATION_CFLAGS_DEBUG = .*/PLATFORM_OPTIMIZATION_CFLAGS_DEBUG = -g0/" libs/openFrameworksCompiled/project/makefileCommon/config.linux.common.mk cd libs/openFrameworksCompiled/project - make + make -j -s echo "**** Building emptyExample ****" cd $ROOT/scripts/templates/linux64 - make + make -j -s echo "**** Building allAddonsExample ****" cd $ROOT cp scripts/templates/linux64/Makefile examples/templates/allAddonsExample/ cp scripts/templates/linux64/config.make examples/templates/allAddonsExample/ cd examples/templates/allAddonsExample/ - make + make -j -s fi diff --git a/scripts/ci/linuxarmv6l/build.sh b/scripts/ci/linuxarmv6l/build.sh index 52e8f8f2260..01f50e2d8ed 100755 --- a/scripts/ci/linuxarmv6l/build.sh +++ b/scripts/ci/linuxarmv6l/build.sh @@ -25,18 +25,18 @@ export CXX="${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-g++" export CC="${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-gcc" export AR=${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-ar export LD=${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-ld -make Debug +make Debug -j -s echo "**** Building emptyExample ****" cd $OF_ROOT/scripts/templates/linuxarmv6l -make Debug +make Debug -j -s echo "**** Building allAddonsExample ****" cd $OF_ROOT cp scripts/templates/linuxarmv6l/Makefile examples/templates/allAddonsExample/ cp scripts/templates/linuxarmv6l/config.make examples/templates/allAddonsExample/ cd examples/templates/allAddonsExample/ -make Debug +make Debug -j -s git checkout $PROJECTS/makefileCommon/config.linux.common.mk git checkout $PROJECTS/linuxarmv6l/config.linuxarmv6l.default.mk diff --git a/scripts/ci/linuxarmv7l/build_junest.sh b/scripts/ci/linuxarmv7l/build_junest.sh index 270b301fe6d..b35d9378f96 100755 --- a/scripts/ci/linuxarmv7l/build_junest.sh +++ b/scripts/ci/linuxarmv7l/build_junest.sh @@ -37,11 +37,11 @@ sed -i "s/PLATFORM_OPTIMIZATION_CFLAGS_DEBUG = .*/PLATFORM_OPTIMIZATION_CFLAGS_D cd $PROJECTS -make Debug PLATFORM_VARIANT=raspberry2 +make Debug PLATFORM_VARIANT=raspberry2 -j -s echo "**** Building emptyExample ****" cd $OF_ROOT/scripts/templates/linuxarmv7l -make Debug PLATFORM_VARIANT=raspberry2 +make Debug PLATFORM_VARIANT=raspberry2 -j -s echo "**** Building allAddonsExample ****" #cd $OF_ROOT From 469685fef1f0836230ba650c05f67f09afeb7946 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Aug 2022 00:14:02 -0300 Subject: [PATCH 37/91] up --- .github/workflows/build-linux.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 21739ed1c82..e488a1f37d6 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -15,8 +15,8 @@ jobs: strategy: matrix: cfg: - - {target: linux64, libs: 64gcc6} - # - {target: linuxarmv6l, libs: armv6l} + # - {target: linux64, libs: 64gcc6} + - {target: linuxarmv6l, libs: armv6l} # - {target: linuxarmv7l, libs: armv7l} env: TARGET: ${{matrix.cfg.target}} @@ -32,8 +32,8 @@ jobs: # gstreamer0.10-alsa version: 1.0 - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 + # - name: ccache + # uses: hendrikmuhs/ccache-action@v1.2 - name: Download libs run: ./scripts/linux/download_libs.sh -a ${{matrix.cfg.libs}}; @@ -54,8 +54,8 @@ jobs: else scripts/ci/$TARGET/build.sh; fi - - name: Upload Libs - run: scripts/ci/upload_of_lib.sh; - env: - GA_CI_SECRET: ${{ secrets.CI_SECRET }} + # - name: Upload Libs + # run: scripts/ci/upload_of_lib.sh; + # env: + # GA_CI_SECRET: ${{ secrets.CI_SECRET }} From 118955c96635800e7821ef3e4d2ba0932d5a0043 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 17:26:19 -0300 Subject: [PATCH 38/91] reverting some updates to master --- .github/workflows/{2 => }/build-android.yml | 2 ++ .../workflows/{2 => }/build-emscripten.yml | 2 ++ .github/workflows/{2 => }/build-ios-tvos.yml | 8 +++-- .github/workflows/build-linux.yml | 31 ++++++------------- .github/workflows/{2 => }/build-macos.yml | 8 +++-- .github/workflows/{2 => }/build-msys2.yml | 2 ++ .github/workflows/{2 => }/build-vs.yml | 2 ++ apps/projectGenerator | 2 +- scripts/apothecary | 2 +- 9 files changed, 29 insertions(+), 30 deletions(-) rename .github/workflows/{2 => }/build-android.yml (96%) rename .github/workflows/{2 => }/build-emscripten.yml (95%) rename .github/workflows/{2 => }/build-ios-tvos.yml (70%) rename .github/workflows/{2 => }/build-macos.yml (75%) rename .github/workflows/{2 => }/build-msys2.yml (95%) rename .github/workflows/{2 => }/build-vs.yml (97%) diff --git a/.github/workflows/2/build-android.yml b/.github/workflows/build-android.yml similarity index 96% rename from .github/workflows/2/build-android.yml rename to .github/workflows/build-android.yml index 78b989d20c5..65804cfcb53 100644 --- a/.github/workflows/2/build-android.yml +++ b/.github/workflows/build-android.yml @@ -4,9 +4,11 @@ on: push: paths-ignore: - '**/*.md' + - 'examples/**' pull_request: paths-ignore: - '**/*.md' + - 'examples/**' jobs: diff --git a/.github/workflows/2/build-emscripten.yml b/.github/workflows/build-emscripten.yml similarity index 95% rename from .github/workflows/2/build-emscripten.yml rename to .github/workflows/build-emscripten.yml index 92ea6720615..c873b6cab84 100644 --- a/.github/workflows/2/build-emscripten.yml +++ b/.github/workflows/build-emscripten.yml @@ -4,9 +4,11 @@ on: push: paths-ignore: - '**/*.md' + - 'examples/**' pull_request: paths-ignore: - '**/*.md' + - 'examples/**' jobs: diff --git a/.github/workflows/2/build-ios-tvos.yml b/.github/workflows/build-ios-tvos.yml similarity index 70% rename from .github/workflows/2/build-ios-tvos.yml rename to .github/workflows/build-ios-tvos.yml index 0d3369143d5..aa47a615cbf 100644 --- a/.github/workflows/2/build-ios-tvos.yml +++ b/.github/workflows/build-ios-tvos.yml @@ -4,19 +4,21 @@ on: push: paths-ignore: - '**/*.md' + - 'examples/**' pull_request: paths-ignore: - '**/*.md' + - 'examples/**' jobs: build-osx: - runs-on: macos-10.15 + runs-on: macos-12 strategy: matrix: cfg: - {target: ios, libs: ios} - - {target: tvos, libs: ios} + #- {target: tvos, libs: ios} #broken currently maybe better to just remove env: TARGET: ${{matrix.cfg.target}} steps: @@ -29,5 +31,5 @@ jobs: run: ./scripts/ci/$TARGET/build.sh; env: - DEVELOPER_DIR: "/Applications/Xcode_11.2.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode_13.4.1.app/Contents/Developer" diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index e488a1f37d6..0897673eaf2 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -4,9 +4,11 @@ on: push: paths-ignore: - '**/*.md' + - 'examples/**' pull_request: paths-ignore: - '**/*.md' + - 'examples/**' jobs: @@ -15,29 +17,15 @@ jobs: strategy: matrix: cfg: - # - {target: linux64, libs: 64gcc6} + - {target: linux64, libs: 64gcc6} - {target: linuxarmv6l, libs: armv6l} - # - {target: linuxarmv7l, libs: armv7l} + - {target: linuxarmv7l, libs: armv7l} env: TARGET: ${{matrix.cfg.target}} steps: - - - uses: actions/checkout@v3 - # - run: apt update # Only for Docker jobs - - name: cachezinho - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: curl libjack-jackd2-0 libjack-jackd2-dev freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev libgconf-2-4 - #PACKAGES="curl libjack-jackd2-0 libjack-jackd2-dev freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++${CXX_VER} libgl1-mesa-dev${XTAG} libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libgtk${GTK_VERSION}-dev libopencv-dev libassimp-dev librtaudio-dev libboost-filesystem${BOOST_VER}-dev libgstreamer${GSTREAMER_VERSION}-dev libgstreamer-plugins-base${GSTREAMER_VERSION}-dev ${GSTREAMER_FFMPEG} gstreamer${GSTREAMER_VERSION}-pulseaudio gstreamer${GSTREAMER_VERSION}-x gstreamer${GSTREAMER_VERSION}-plugins-bad gstreamer${GSTREAMER_VERSION}-alsa gstreamer${GSTREAMER_VERSION}-plugins-base gstreamer${GSTREAMER_VERSION}-plugins-good gdb ${GLFW_PKG} liburiparser-dev libcurl4-openssl-dev libpugixml-dev libgconf-2-4 libgtk2.0-0 libpoco-dev libxcursor-dev libxi-dev libxinerama-dev" - # gstreamer0.10-alsa - version: 1.0 - - # - name: ccache - # uses: hendrikmuhs/ccache-action@v1.2 - + - uses: actions/checkout@v2 - name: Download libs run: ./scripts/linux/download_libs.sh -a ${{matrix.cfg.libs}}; - - name: Install dependencies run: ./scripts/ci/$TARGET/install.sh; # - name: Install gcc4 @@ -46,7 +34,6 @@ jobs: # sudo apt-get update -q; # sudo apt-get install gcc-4.9 g++-4.9; # fi - - name: Build run: if [ "$TARGET" = "linux64" ]; then scripts/ci/$TARGET/build.sh; @@ -54,8 +41,8 @@ jobs: else scripts/ci/$TARGET/build.sh; fi - # - name: Upload Libs - # run: scripts/ci/upload_of_lib.sh; - # env: - # GA_CI_SECRET: ${{ secrets.CI_SECRET }} + - name: Upload Libs + run: scripts/ci/upload_of_lib.sh; + env: + GA_CI_SECRET: ${{ secrets.CI_SECRET }} diff --git a/.github/workflows/2/build-macos.yml b/.github/workflows/build-macos.yml similarity index 75% rename from .github/workflows/2/build-macos.yml rename to .github/workflows/build-macos.yml index d3d01579a84..74d6574e617 100644 --- a/.github/workflows/2/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -4,14 +4,16 @@ on: push: paths-ignore: - '**/*.md' + - 'examples/**' pull_request: paths-ignore: - '**/*.md' + - 'examples/**' jobs: build-osx: - runs-on: macos-10.15 + runs-on: macos-12 strategy: matrix: cfg: @@ -36,6 +38,6 @@ jobs: scripts/ci/$TARGET/build.sh $OPT; fi env: - DEVELOPER_DIR: "/Applications/Xcode_12.2.app/Contents/Developer" - SDKROOT: "/Applications/Xcode_12.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" + DEVELOPER_DIR: "/Applications/Xcode_13.4.1.app/Contents/Developer" + SDKROOT: "/Applications/Xcode_13.4.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" diff --git a/.github/workflows/2/build-msys2.yml b/.github/workflows/build-msys2.yml similarity index 95% rename from .github/workflows/2/build-msys2.yml rename to .github/workflows/build-msys2.yml index 10d89c49432..4f6b8346205 100644 --- a/.github/workflows/2/build-msys2.yml +++ b/.github/workflows/build-msys2.yml @@ -4,9 +4,11 @@ on: push: paths-ignore: - '**/*.md' + - 'examples/**' pull_request: paths-ignore: - '**/*.md' + - 'examples/**' jobs: diff --git a/.github/workflows/2/build-vs.yml b/.github/workflows/build-vs.yml similarity index 97% rename from .github/workflows/2/build-vs.yml rename to .github/workflows/build-vs.yml index c88bcdbf3fe..eca97ae8263 100644 --- a/.github/workflows/2/build-vs.yml +++ b/.github/workflows/build-vs.yml @@ -4,9 +4,11 @@ on: push: paths-ignore: - '**/*.md' + - 'examples/**' pull_request: paths-ignore: - '**/*.md' + - 'examples/**' jobs: diff --git a/apps/projectGenerator b/apps/projectGenerator index 150e26ac76c..c80275e9663 160000 --- a/apps/projectGenerator +++ b/apps/projectGenerator @@ -1 +1 @@ -Subproject commit 150e26ac76ce9a760e3edf40c781fe9727d99bd4 +Subproject commit c80275e96632b3b7640b2cdc031d90a762147386 diff --git a/scripts/apothecary b/scripts/apothecary index 23f8534cf6c..9f2227aeb72 160000 --- a/scripts/apothecary +++ b/scripts/apothecary @@ -1 +1 @@ -Subproject commit 23f8534cf6c6acdf507c839953b53aa7143cdd6e +Subproject commit 9f2227aeb72878d4e1a9ee5b166e76595e015b76 From 38aba254fbe26bde055dcc9a5b556b5c0a195f4c Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 17:28:12 -0300 Subject: [PATCH 39/91] reverting --- .github/workflows/build-ios-tvos.yml | 2 - .github/workflows/build-macos.yml | 56 ++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-ios-tvos.yml b/.github/workflows/build-ios-tvos.yml index aa47a615cbf..cf57c5da714 100644 --- a/.github/workflows/build-ios-tvos.yml +++ b/.github/workflows/build-ios-tvos.yml @@ -11,7 +11,6 @@ on: - 'examples/**' jobs: - build-osx: runs-on: macos-12 strategy: @@ -32,4 +31,3 @@ jobs: env: DEVELOPER_DIR: "/Applications/Xcode_13.4.1.app/Contents/Developer" - diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 74d6574e617..8fd01b04d6f 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -17,26 +17,60 @@ jobs: strategy: matrix: cfg: - - {target: osx, opt: ""} + - {target: osx, opt: "xcode"} - {target: osx, opt: "makefiles"} env: - TARGET: ${{matrix.cfg.target}} - OPT: ${{matrix.cfg.opt}} + TARGET: ${{matrix.cfg.target}} + OPT: ${{matrix.cfg.opt}} steps: - uses: actions/checkout@v2 - - name: Download libs + - name: Cache compile + id: cache-compile + uses: actions/cache@v3 + env: + cache-name: cache-keep-compile + with: + path: libs/openFrameworksCompiled/lib/osx/**/ + key: ${{ runner.os }}-${{matrix.cfg.opt}}-${{ env.cache-name }}-${{ hashFiles('**/*.cpp') }} + restore-keys: | + ${{ runner.os }}-${{matrix.cfg.opt}}-${{ env.cache-name }}- + + + - name: Cache libs + id: cache-libs + uses: actions/cache@v3 + env: + cache-name: cache-install-libs + with: + path: | + libs + addons/ofxAssimpModelLoader/libs/**/ + addons/ofxKinect/libs/**/ + addons/ofxOpenCv/libs/**/ + addons/ofxSvg/libs/**/ + addons/ofxPoco/libs/**/ + + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.h') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + - if: ${{ steps.cache-libs.outputs.cache-hit != 'true' }} + # name: Download libs + # continue-on-error: true run: ./scripts/$TARGET/download_libs.sh - name: rm-dev run: sudo rm -rf /Library/Developer - - name: install - run: ./scripts/ci/$TARGET/install.sh + + # this step is not needed here because the script is empty + # - name: install + # run: ./scripts/ci/$TARGET/install.sh + - name: Build run: - if [ "$TARGET" = "osx" ] && [ "$OPT" = "makefiles" ]; then - scripts/ci/$TARGET/run_tests.sh; - else - scripts/ci/$TARGET/build.sh $OPT; - fi + if [ "$TARGET" = "osx" ] && [ "$OPT" = "makefiles" ]; then + scripts/ci/$TARGET/build.sh $OPT; + else + scripts/ci/$TARGET/run_tests.sh; + fi env: DEVELOPER_DIR: "/Applications/Xcode_13.4.1.app/Contents/Developer" SDKROOT: "/Applications/Xcode_13.4.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" From 49f20f7ce58d5a344b5f773c011605fe0ef90887 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 17:30:32 -0300 Subject: [PATCH 40/91] updates --- .../graphics/ofTrueTypeFont.cpp | 237 +++++++++--------- scripts/ci/linux64/build.sh | 6 +- scripts/ci/linuxarmv6l/build.sh | 6 +- scripts/ci/linuxarmv7l/build_junest.sh | 6 +- 4 files changed, 130 insertions(+), 125 deletions(-) diff --git a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp index 298a4b97af1..8802cd3340f 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp @@ -192,23 +192,26 @@ static ofPath makeContoursForCharacter(FT_Face face){ charOutlines.setPolyWindingMode(OF_POLY_WINDING_NONZERO); auto moveTo = [](const FT_Vector*to, void * userData){ ofPath * charOutlines = static_cast(userData); - charOutlines->moveTo(to->x/64, -to->y/64); + charOutlines->moveTo(ofTrueTypeFont::int26p6_to_dbl(to->x), ofTrueTypeFont::int26p6_to_dbl(-to->y)); return 0; }; auto lineTo = [](const FT_Vector*to, void * userData){ ofPath * charOutlines = static_cast(userData); - charOutlines->lineTo(to->x/64, -to->y/64); + charOutlines->lineTo(ofTrueTypeFont::int26p6_to_dbl(to->x), ofTrueTypeFont::int26p6_to_dbl(-to->y)); return 0; }; auto conicTo = [](const FT_Vector*cp, const FT_Vector*to, void * userData){ ofPath * charOutlines = static_cast(userData); auto lastP = charOutlines->getCommands().back().to; - charOutlines->quadBezierTo(lastP, {cp->x/64, -cp->y/64}, {to->x/64, -to->y/64}); + charOutlines->quadBezierTo(lastP, { ofTrueTypeFont::int26p6_to_dbl(cp->x), ofTrueTypeFont::int26p6_to_dbl(-cp->y) }, + {ofTrueTypeFont::int26p6_to_dbl(to->x), ofTrueTypeFont::int26p6_to_dbl(-to->y)}); return 0; }; auto cubicTo = [](const FT_Vector*cp1, const FT_Vector*cp2, const FT_Vector*to, void * userData){ ofPath * charOutlines = static_cast(userData); - charOutlines->bezierTo({cp1->x/64, -cp1->y/64}, {cp2->x/64, -cp2->y/64}, {to->x/64, -to->y/64}); + charOutlines->bezierTo({ofTrueTypeFont::int26p6_to_dbl(cp1->x), ofTrueTypeFont::int26p6_to_dbl(-cp1->y)}, + {ofTrueTypeFont::int26p6_to_dbl(cp2->x), ofTrueTypeFont::int26p6_to_dbl(-cp2->y)}, + {ofTrueTypeFont::int26p6_to_dbl(to->x), ofTrueTypeFont::int26p6_to_dbl(-to->y)}); return 0; }; FT_Outline_Funcs funcs{ @@ -228,7 +231,7 @@ static ofPath makeContoursForCharacter(FT_Face face){ #ifdef TARGET_OSX //------------------------------------------------------------------ -static std::string osxFontPathByName(const std::string& fontname){ +static string osxFontPathByName(const string& fontname){ CFStringRef targetName = CFStringCreateWithCString(nullptr, fontname.c_str(), kCFStringEncodingUTF8); CTFontDescriptorRef targetDescriptor = CTFontDescriptorCreateWithNameAndSize(targetName, 0.0); CFURLRef targetURL = (CFURLRef) CTFontDescriptorCopyAttribute(targetDescriptor, kCTFontURLAttribute); @@ -237,7 +240,7 @@ static std::string osxFontPathByName(const std::string& fontname){ if(targetURL) { UInt8 buffer[PATH_MAX]; CFURLGetFileSystemRepresentation(targetURL, true, buffer, PATH_MAX); - fontPath = std::string((char *)buffer); + fontPath = string((char *)buffer); CFRelease(targetURL); } @@ -251,7 +254,7 @@ static std::string osxFontPathByName(const std::string& fontname){ #ifdef TARGET_WIN32 #include // font font face -> file name name mapping -static std::map fonts_table; +static std::map fonts_table; // read font linking information from registry, and store in std::map //------------------------------------------------------------------ void initWindows(){ @@ -296,7 +299,7 @@ void initWindows(){ char fontsPath[2048]; SHGetKnownFolderIDList(FOLDERID_Fonts, 0, nullptr, &ppidl); SHGetPathFromIDList(ppidl,&fontsPath);*/ - std::string fontsDir = getenv ("windir"); + string fontsDir = getenv ("windir"); fontsDir += "\\Fonts\\"; for (DWORD i = 0; i < value_count; ++i) { @@ -311,8 +314,8 @@ void initWindows(){ wcstombs(value_name_char,value_name,2048); wcstombs(value_data_char,reinterpret_cast(value_data),2048); - std::string curr_face = value_name_char; - std::string font_file = value_data_char; + string curr_face = value_name_char; + string font_file = value_data_char; curr_face = curr_face.substr(0, curr_face.find('(') - 1); fonts_table[curr_face] = fontsDir + font_file; } @@ -324,11 +327,11 @@ void initWindows(){ } -static std::string winFontPathByName(const std::string& fontname ){ +static string winFontPathByName(const string& fontname ){ if(fonts_table.find(fontname)!=fonts_table.end()){ return fonts_table[fontname]; } - for(std::map::iterator it = fonts_table.begin(); it!=fonts_table.end(); it++){ + for(std::map::iterator it = fonts_table.begin(); it!=fonts_table.end(); it++){ if(ofIsStringInString(ofToLower(it->first),ofToLower(fontname))) return it->second; } return ""; @@ -337,8 +340,8 @@ static std::string winFontPathByName(const std::string& fontname ){ #ifdef TARGET_LINUX //------------------------------------------------------------------ -static std::string linuxFontPathByName(const std::string& fontname){ - std::string filename; +static string linuxFontPathByName(const string& fontname){ + string filename; FcPattern * pattern = FcNameParse((const FcChar8*)fontname.c_str()); FcBool ret = FcConfigSubstitute(0,pattern,FcMatchPattern); if(!ret){ @@ -372,15 +375,14 @@ static std::string linuxFontPathByName(const std::string& fontname){ #endif //----------------------------------------------------------- -static bool loadFontFace(const of::filesystem::path& _fontname, FT_Face & face, of::filesystem::path & filename, int index){ - of::filesystem::path fontname = _fontname; - // FIXME: makes no sense: why have two of::filesystem::path parameters if they are the same? - filename = ofToDataPath(_fontname, true); - ofFile fontFile(filename, ofFile::Reference); +static bool loadFontFace(const std::filesystem::path& _fontname, FT_Face & face, std::filesystem::path & filename, int index){ + std::filesystem::path fontname = _fontname; + filename = ofToDataPath(_fontname,true); + ofFile fontFile(filename,ofFile::Reference); int fontID = index; if(!fontFile.exists()){ #ifdef TARGET_LINUX - filename = linuxFontPathByName(fontname.string()); + filename = linuxFontPathByName(fontname.string()); #elif defined(TARGET_OSX) if(fontname==OF_TTF_SANS){ fontname = "Helvetica Neue"; @@ -394,7 +396,7 @@ static bool loadFontFace(const of::filesystem::path& _fontname, FT_Face & face, }else if(fontname==OF_TTF_MONO){ fontname = "Menlo Regular"; } - filename = osxFontPathByName(fontname.string()); + filename = osxFontPathByName(fontname.string()); #elif defined(TARGET_WIN32) if(fontname==OF_TTF_SANS){ fontname = "Arial"; @@ -403,7 +405,7 @@ static bool loadFontFace(const of::filesystem::path& _fontname, FT_Face & face, }else if(fontname==OF_TTF_MONO){ fontname = "Courier New"; } - filename = winFontPathByName(fontname.string()); + filename = winFontPathByName(fontname.string()); #endif if(filename == "" ){ ofLogError("ofTrueTypeFont") << "loadFontFace(): couldn't find font \"" << fontname << "\""; @@ -412,8 +414,7 @@ static bool loadFontFace(const of::filesystem::path& _fontname, FT_Face & face, ofLogVerbose("ofTrueTypeFont") << "loadFontFace(): \"" << fontname << "\" not a file in data loading system font from \"" << filename << "\""; } FT_Error err; - err = FT_New_Face( library, filename.string().c_str(), fontID, &face ); - + err = FT_New_Face( library, filename.string().c_str(), fontID, &face ); if (err) { // simple error table in lieu of full table (see fterrors.h) string errorString = "unknown freetype"; @@ -641,15 +642,15 @@ ofTrueTypeFont::glyph ofTrueTypeFont::loadGlyph(uint32_t utf8) const{ // ------------------------- // info about the character: aGlyph.props.glyph = utf8; - aGlyph.props.height = face->glyph->metrics.height>>6; - aGlyph.props.width = face->glyph->metrics.width>>6; - aGlyph.props.bearingX = face->glyph->metrics.horiBearingX>>6; - aGlyph.props.bearingY = face->glyph->metrics.horiBearingY>>6; + aGlyph.props.height = int26p6_to_dbl(face->glyph->metrics.height); + aGlyph.props.width = int26p6_to_dbl(face->glyph->metrics.width); + aGlyph.props.bearingX = int26p6_to_dbl(face->glyph->metrics.horiBearingX); + aGlyph.props.bearingY = int26p6_to_dbl(face->glyph->metrics.horiBearingY); aGlyph.props.xmin = face->glyph->bitmap_left; aGlyph.props.xmax = aGlyph.props.xmin + aGlyph.props.width; aGlyph.props.ymin = -face->glyph->bitmap_top; aGlyph.props.ymax = aGlyph.props.ymin + aGlyph.props.height; - aGlyph.props.advance = face->glyph->metrics.horiAdvance>>6; + aGlyph.props.advance = int26p6_to_dbl(face->glyph->metrics.horiAdvance); aGlyph.props.tW = aGlyph.props.width; aGlyph.props.tH = aGlyph.props.height; @@ -697,7 +698,8 @@ ofTrueTypeFont::glyph ofTrueTypeFont::loadGlyph(uint32_t utf8) const{ } //----------------------------------------------------------- -bool ofTrueTypeFont::load(const of::filesystem::path& filename, int fontSize, bool antialiased, bool fullCharacterSet, bool makeContours, float simplifyAmt, int dpi) { +bool ofTrueTypeFont::load(const std::filesystem::path& filename, int fontSize, bool antialiased, bool fullCharacterSet, bool makeContours, float simplifyAmt, int dpi) { + ofTrueTypeFontSettings settings(filename,fontSize); settings.antialiased = antialiased; settings.contours = makeContours; @@ -727,7 +729,7 @@ bool ofTrueTypeFont::load(const ofTrueTypeFontSettings & _settings){ //--------------- load the library and typeface FT_Face loadFace; - if(!loadFontFace(settings.fontName, loadFace, settings.fontName, settings.index)){ + if(!loadFontFace(settings.fontName, loadFace, settings.fontName, settings.index)){ return false; } face = std::shared_ptr(loadFace,FT_Done_Face); @@ -738,7 +740,7 @@ bool ofTrueTypeFont::load(const ofTrueTypeFontSettings & _settings){ int border = 1; - FT_Set_Char_Size( face.get(), settings.fontSize << 6, settings.fontSize << 6, settings.dpi, settings.dpi); + FT_Set_Char_Size( face.get(), dbl_to_int26p6(settings.fontSize), dbl_to_int26p6(settings.fontSize), settings.dpi, settings.dpi); fontUnitScale = (float(settings.fontSize * settings.dpi)) / (72 * face->units_per_EM); lineHeight = face->height * fontUnitScale; ascenderHeight = face->ascender * fontUnitScale; @@ -779,7 +781,7 @@ bool ofTrueTypeFont::load(const ofTrueTypeFontSettings & _settings){ if(settings.contours){ if(printVectorInfo){ - std::string str; + string str; ofUTF8Append(str,g); ofLogNotice("ofTrueTypeFont") << "character " << str; } @@ -854,16 +856,16 @@ bool ofTrueTypeFont::load(const ofTrueTypeFontSettings & _settings){ atlasPixelsLuminanceAlpha.set(1,0); - int x=0; - int y=0; - auto maxRowHeight = sortedCopy[0].tH + border*2; + float x=0; + float y=0; + auto maxRowHeight = sortedCopy[0].tH + border*2.0; for(auto & glyph: sortedCopy){ ofPixels & charPixels = all_glyphs[glyph.characterIndex].pixels; if(x+glyph.tW + border*2>w){ x = 0; y += maxRowHeight; - maxRowHeight = glyph.tH + border*2; + maxRowHeight = glyph.tH + border*2.0; } cps[glyph.characterIndex].t1 = float(x + border)/float(w); @@ -871,7 +873,7 @@ bool ofTrueTypeFont::load(const ofTrueTypeFontSettings & _settings){ cps[glyph.characterIndex].t2 = float(cps[glyph.characterIndex].tW + x + border)/float(w); cps[glyph.characterIndex].v2 = float(cps[glyph.characterIndex].tH + y + border)/float(h); charPixels.pasteInto(atlasPixelsLuminanceAlpha,x+border,y+border); - x+= glyph.tW + border*2; + x+= glyph.tW + border*2.0; } int maxSize; @@ -992,23 +994,16 @@ void ofTrueTypeFont::drawChar(uint32_t c, float x, float y, bool vFlipped) const return; } - - long xmin, ymin, xmax, ymax; - float t1, v1, t2, v2; auto props = getGlyphProperties(c); - t1 = props.t1; - t2 = props.t2; - v2 = props.v2; - v1 = props.v1; - xmin = long(props.xmin+x); - ymin = props.ymin; - xmax = long(props.xmax+x); - ymax = props.ymax; + float xmin = props.xmin+x; + float ymin = props.ymin; + float xmax = props.xmax+x; + float ymax = props.ymax; if(!vFlipped){ - ymin *= -1; - ymax *= -1; + ymin *= -1.0; + ymax *= -1.0; } ymin += y; @@ -1021,10 +1016,10 @@ void ofTrueTypeFont::drawChar(uint32_t c, float x, float y, bool vFlipped) const stringQuads.addVertex(glm::vec3(xmax,ymax,0.f)); stringQuads.addVertex(glm::vec3(xmin,ymax,0.f)); - stringQuads.addTexCoord(glm::vec2(t1,v1)); - stringQuads.addTexCoord(glm::vec2(t2,v1)); - stringQuads.addTexCoord(glm::vec2(t2,v2)); - stringQuads.addTexCoord(glm::vec2(t1,v2)); + stringQuads.addTexCoord(glm::vec2(props.t1,props.v1)); + stringQuads.addTexCoord(glm::vec2(props.t2,props.v1)); + stringQuads.addTexCoord(glm::vec2(props.t2,props.v2)); + stringQuads.addTexCoord(glm::vec2(props.t1,props.v2)); stringQuads.addIndex(firstIndex); stringQuads.addIndex(firstIndex+1); @@ -1032,23 +1027,25 @@ void ofTrueTypeFont::drawChar(uint32_t c, float x, float y, bool vFlipped) const stringQuads.addIndex(firstIndex+2); stringQuads.addIndex(firstIndex+3); stringQuads.addIndex(firstIndex); + + } //----------------------------------------------------------- -int ofTrueTypeFont::getKerning(uint32_t leftC, uint32_t rightC) const{ +double ofTrueTypeFont::getKerning(uint32_t leftC, uint32_t rightC) const{ if(FT_HAS_KERNING( face )){ FT_Vector kerning; FT_Get_Kerning(face.get(), FT_Get_Char_Index(face.get(), leftC), FT_Get_Char_Index(face.get(), rightC), FT_KERNING_UNFITTED, &kerning); - return kerning.x >> 6; + return int26p6_to_dbl(kerning.x); }else{ - return 0; + return 0.0; } } void ofTrueTypeFont::iterateString(const string & str, float x, float y, bool vFlipped, std::function f) const{ glm::vec2 pos(x,y); - int newLineDirection = 1; + float newLineDirection = 1; if(!vFlipped){ // this would align multiline texts to the last line when vflip is disabled //int lines = ofStringTimesInString(c,"\n"); @@ -1056,10 +1053,10 @@ void ofTrueTypeFont::iterateString(const string & str, float x, float y, bool vF newLineDirection = -1; } - int directionX = settings.direction == OF_TTF_LEFT_TO_RIGHT?1:-1; + float directionX = settings.direction == OF_TTF_LEFT_TO_RIGHT?1:-1; uint32_t prevC = 0; - for(auto c: ofUTF8Iterator(str)){ + for(auto c: ofUTF8Iterator(str)){ try{ if (c == '\n') { pos.y += lineHeight*newLineDirection; @@ -1074,11 +1071,11 @@ void ofTrueTypeFont::iterateString(const string & str, float x, float y, bool vF f(c, pos); } prevC = c; - }else if(c == ' '){ - pos.x += getGlyphProperties(' ').advance * spaceSize * directionX; - f(c, pos); - prevC = c; - }else if(isValidGlyph(c)) { + }else if(c == ' '){ + pos.x += getGlyphProperties(' ').advance * spaceSize * directionX; + f(c, pos); + prevC = c; + }else if(isValidGlyph(c)) { const auto & props = getGlyphProperties(c); if(prevC>0){ if(settings.direction == OF_TTF_LEFT_TO_RIGHT){ @@ -1094,14 +1091,14 @@ void ofTrueTypeFont::iterateString(const string & str, float x, float y, bool vF }else{ pos.x += props.advance * directionX; pos.x += getGlyphProperties(' ').advance * (letterSpacing - 1.f) * directionX; - f(c,pos); + f(c,pos); } prevC = c; - } - }catch(...){ + } + }catch(...){ break; } - } + } } //----------------------------------------------------------- @@ -1163,13 +1160,21 @@ void ofTrueTypeFont::drawCharAsShape(uint32_t c, float x, float y, bool vFlipped } //----------------------------------------------------------- -float ofTrueTypeFont::stringWidth(const std::string& c) const{ - ofRectangle rect = getStringBoundingBox(c, 0,0); - return rect.width; +float ofTrueTypeFont::stringWidth(const string& c) const{ +// return getStringBoundingBox(c, 0,0).width; + int w = 0; + iterateString( c, 0, 0, false, [&]( uint32_t c, glm::vec2 pos ){ + if ( c == '\t' ){ + w += getGlyphProperties(' ').advance * spaceSize * TAB_WIDTH; + } else { + w += getGlyphProperties( c ).advance; + } + }); + return w; } //----------------------------------------------------------- -ofRectangle ofTrueTypeFont::getStringBoundingBox(const std::string& c, float x, float y, bool vflip) const{ +ofRectangle ofTrueTypeFont::getStringBoundingBox(const string& c, float x, float y, bool vflip) const{ if ( c.empty() ){ return ofRectangle( x, y, 0.f, 0.f); @@ -1177,9 +1182,7 @@ ofRectangle ofTrueTypeFont::getStringBoundingBox(const std::string& c, float x, float minX = x; float minY = y; - float maxX = x; float maxY = y; - // Calculate bounding box by iterating over glyph properties // Meaning of props can be deduced from illustration at top of: // https://www.freetype.org/freetype2/docs/tutorial/step2.html @@ -1187,14 +1190,16 @@ ofRectangle ofTrueTypeFont::getStringBoundingBox(const std::string& c, float x, // We deliberately not generate a mesh and iterate over its // vertices, as this would not correctly return spacing for // blank characters. - + + float w = 0; iterateString( c, x, y, vflip, [&]( uint32_t c, glm::vec2 pos ){ - auto props = getGlyphProperties( c ); - + auto props = getGlyphProperties( c ); if ( c == '\t' ){ - props.advance = getGlyphProperties(' ').advance * spaceSize * TAB_WIDTH; + w += props.advance * spaceSize * TAB_WIDTH; + } else { + w += props.advance; } - maxX = max( maxX, pos.x + props.xmin + props.width ); + minX = min( minX, pos.x ); if ( vflip ){ minY = min( minY, pos.y - ( props.ymax - props.ymin ) ); @@ -1203,29 +1208,28 @@ ofRectangle ofTrueTypeFont::getStringBoundingBox(const std::string& c, float x, minY = min( minY, pos.y - ( props.ymax) ); maxY = max( maxY, pos.y - ( props.ymin ) ); } - } ); + }); - float width = maxX - minX; float height = maxY - minY; - return ofRectangle(minX, minY, width, height); + return ofRectangle(minX, minY, w, height); } //----------------------------------------------------------- -float ofTrueTypeFont::stringHeight(const std::string& c) const{ +float ofTrueTypeFont::stringHeight(const string& c) const{ ofRectangle rect = getStringBoundingBox(c, 0,0); return rect.height; } //----------------------------------------------------------- -void ofTrueTypeFont::createStringMesh(const std::string& str, float x, float y, bool vflip) const{ +void ofTrueTypeFont::createStringMesh(const string& str, float x, float y, bool vflip) const{ iterateString(str,x,y,vflip,[&](uint32_t c, glm::vec2 pos){ drawChar(c, pos.x, pos.y, vflip); }); } //----------------------------------------------------------- -const ofMesh & ofTrueTypeFont::getStringMesh(const std::string& c, float x, float y, bool vFlipped) const{ +const ofMesh & ofTrueTypeFont::getStringMesh(const string& c, float x, float y, bool vFlipped) const{ stringQuads.clear(); createStringMesh(c,x,y,vFlipped); return stringQuads; @@ -1237,7 +1241,7 @@ const ofTexture & ofTrueTypeFont::getFontTexture() const{ } //----------------------------------------------------------- -glm::vec2 ofTrueTypeFont::getFirstGlyphPosForTexture(const std::string & str, bool vflip) const{ +glm::vec2 ofTrueTypeFont::getFirstGlyphPosForTexture(const string & str, bool vflip) const{ if(!str.empty()){ try{ auto c = *ofUTF8Iterator(str).begin(); @@ -1253,9 +1257,9 @@ glm::vec2 ofTrueTypeFont::getFirstGlyphPosForTexture(const std::string & str, bo try{ if (c != '\n') { auto g = loadGlyph(c); - if(c == '\t')lineWidth += g.props.advance + getGlyphProperties(' ').advance * spaceSize * TAB_WIDTH; - else if(c == ' ')lineWidth += g.props.advance + getGlyphProperties(' ').advance * spaceSize; - else if(isValidGlyph(c))lineWidth += g.props.advance + getGlyphProperties(' ').advance * (letterSpacing - 1.f); + if(c == '\t')lineWidth += g.props.advance + getGlyphProperties(' ').advance * spaceSize * TAB_WIDTH; + else if(c == ' ')lineWidth += g.props.advance + getGlyphProperties(' ').advance * spaceSize; + else if(isValidGlyph(c))lineWidth += g.props.advance + getGlyphProperties(' ').advance * (letterSpacing - 1.f); width = max(width, lineWidth); }else{ lineWidth = 0; @@ -1277,36 +1281,36 @@ glm::vec2 ofTrueTypeFont::getFirstGlyphPosForTexture(const std::string & str, bo } //----------------------------------------------------------- -ofTexture ofTrueTypeFont::getStringTexture(const std::string& str, bool vflip) const{ +ofTexture ofTrueTypeFont::getStringTexture(const string& str, bool vflip) const{ vector glyphs; vector glyphPositions; - long height = 0; - int width = 0; - int lineWidth = 0; + float height = 0; + float width = 0; + float lineWidth = 0; iterateString(str, 0, 0, vflip, [&](uint32_t c, ofVec2f pos){ try{ - if (c != '\n') { + if (c != '\n') { auto g = loadGlyph(c); - - if (c == '\t'){ - auto temp = loadGlyph(' '); - glyphs.push_back(temp); - }else{ - glyphs.push_back(g); - } - + + if (c == '\t'){ + auto temp = loadGlyph(' '); + glyphs.push_back(temp); + }else{ + glyphs.push_back(g); + } + int x = pos.x + g.props.xmin; - int y = pos.y; + int y = pos.y; glyphPositions.emplace_back(x, y); - - if(c == '\t')lineWidth += g.props.advance + getGlyphProperties(' ').advance * spaceSize * TAB_WIDTH; - else if(c == ' ')lineWidth += g.props.advance + getGlyphProperties(' ').advance * spaceSize; - else if(isValidGlyph(c))lineWidth += g.props.advance + getGlyphProperties(' ').advance * (letterSpacing - 1.f); - - width = max(width, lineWidth); - y += g.props.ymax; - height = max(height, y + long(getLineHeight())); - }else{ + + if(c == '\t')lineWidth += g.props.advance + getGlyphProperties(' ').advance * spaceSize * TAB_WIDTH; + else if(c == ' ')lineWidth += g.props.advance + getGlyphProperties(' ').advance * spaceSize; + else if(isValidGlyph(c))lineWidth += g.props.advance + getGlyphProperties(' ').advance * (letterSpacing - 1.f); + + width = max(width, lineWidth); + y += g.props.ymax; + height = max(height, y + getLineHeight()); + }else{ lineWidth = 0; } }catch(...){ @@ -1336,7 +1340,8 @@ ofTexture ofTrueTypeFont::getStringTexture(const std::string& str, bool vflip) c } //----------------------------------------------------------- -void ofTrueTypeFont::drawString(const std::string & c, float x, float y) const{ +void ofTrueTypeFont::drawString(const string & c, float x, float y) const{ + if (!bLoadedOk){ ofLogError("ofTrueTypeFont") << "drawString(): font not allocated"; return; @@ -1347,7 +1352,7 @@ void ofTrueTypeFont::drawString(const std::string & c, float x, float y) const{ } //----------------------------------------------------------- -void ofTrueTypeFont::drawStringAsShapes(const std::string& str, float x, float y) const{ +void ofTrueTypeFont::drawStringAsShapes(const string& str, float x, float y) const{ if (!bLoadedOk){ ofLogError("ofTrueTypeFont") << "drawStringAsShapes(): font not allocated: line " << __LINE__ << " in " << __FILE__; return; diff --git a/scripts/ci/linux64/build.sh b/scripts/ci/linux64/build.sh index 34e839f00a6..c3e112c1af2 100755 --- a/scripts/ci/linux64/build.sh +++ b/scripts/ci/linux64/build.sh @@ -25,16 +25,16 @@ else echo "PLATFORM_CFLAGS += $CUSTOMFLAGS" >> libs/openFrameworksCompiled/project/linux64/config.linux64.default.mk sed -i "s/PLATFORM_OPTIMIZATION_CFLAGS_DEBUG = .*/PLATFORM_OPTIMIZATION_CFLAGS_DEBUG = -g0/" libs/openFrameworksCompiled/project/makefileCommon/config.linux.common.mk cd libs/openFrameworksCompiled/project - make -j -s + make -j2 echo "**** Building emptyExample ****" cd $ROOT/scripts/templates/linux64 - make -j -s + make -j2 echo "**** Building allAddonsExample ****" cd $ROOT cp scripts/templates/linux64/Makefile examples/templates/allAddonsExample/ cp scripts/templates/linux64/config.make examples/templates/allAddonsExample/ cd examples/templates/allAddonsExample/ - make -j -s + make -j2 fi diff --git a/scripts/ci/linuxarmv6l/build.sh b/scripts/ci/linuxarmv6l/build.sh index 01f50e2d8ed..bd8778623aa 100755 --- a/scripts/ci/linuxarmv6l/build.sh +++ b/scripts/ci/linuxarmv6l/build.sh @@ -25,18 +25,18 @@ export CXX="${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-g++" export CC="${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-gcc" export AR=${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-ar export LD=${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-ld -make Debug -j -s +make Debug -j2 echo "**** Building emptyExample ****" cd $OF_ROOT/scripts/templates/linuxarmv6l -make Debug -j -s +make Debug -j2 echo "**** Building allAddonsExample ****" cd $OF_ROOT cp scripts/templates/linuxarmv6l/Makefile examples/templates/allAddonsExample/ cp scripts/templates/linuxarmv6l/config.make examples/templates/allAddonsExample/ cd examples/templates/allAddonsExample/ -make Debug -j -s +make Debug -j2 git checkout $PROJECTS/makefileCommon/config.linux.common.mk git checkout $PROJECTS/linuxarmv6l/config.linuxarmv6l.default.mk diff --git a/scripts/ci/linuxarmv7l/build_junest.sh b/scripts/ci/linuxarmv7l/build_junest.sh index b35d9378f96..1594c737b8e 100755 --- a/scripts/ci/linuxarmv7l/build_junest.sh +++ b/scripts/ci/linuxarmv7l/build_junest.sh @@ -37,18 +37,18 @@ sed -i "s/PLATFORM_OPTIMIZATION_CFLAGS_DEBUG = .*/PLATFORM_OPTIMIZATION_CFLAGS_D cd $PROJECTS -make Debug PLATFORM_VARIANT=raspberry2 -j -s +make -j2 Debug PLATFORM_VARIANT=raspberry2 -j2 echo "**** Building emptyExample ****" cd $OF_ROOT/scripts/templates/linuxarmv7l -make Debug PLATFORM_VARIANT=raspberry2 -j -s +make -j2 Debug PLATFORM_VARIANT=raspberry2 -j2 echo "**** Building allAddonsExample ****" #cd $OF_ROOT #cp scripts/templates/linuxarmv7l/Makefile examples/addons/allAddonsExample/ #cp scripts/templates/linuxarmv7l/config.make examples/addons/allAddonsExample/ #cd examples/addons/allAddonsExample/ -#make Debug PLATFORM_VARIANT=raspberry2 +#make -j2 Debug PLATFORM_VARIANT=raspberry2 git checkout $PROJECTS/makefileCommon/config.linux.common.mk git checkout $PROJECTS/linuxarmv7l/config.linuxarmv7l.default.mk From f7a66d19f8ece8fd0e519f4e7c4c35b065a059c9 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 19:31:26 -0300 Subject: [PATCH 41/91] updates --- examples/3d/ofNodeExample/addons.make | 0 examples/android/androidAccelerometerExample/addons.make | 0 examples/android/androidAdvanced3DExample/addons.make | 0 examples/android/androidAudioExample/addons.make | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 examples/3d/ofNodeExample/addons.make create mode 100644 examples/android/androidAccelerometerExample/addons.make create mode 100644 examples/android/androidAdvanced3DExample/addons.make create mode 100644 examples/android/androidAudioExample/addons.make diff --git a/examples/3d/ofNodeExample/addons.make b/examples/3d/ofNodeExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidAccelerometerExample/addons.make b/examples/android/androidAccelerometerExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidAdvanced3DExample/addons.make b/examples/android/androidAdvanced3DExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidAudioExample/addons.make b/examples/android/androidAudioExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d From d608ceb6d2b4b19cf9622b2c9ea2c55432b0db6b Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 19:34:04 -0300 Subject: [PATCH 42/91] revert files --- examples/android/androidFontExample/addons.make | 0 examples/android/androidImageExample/addons.make | 0 examples/android/androidJavaOnlyActivityExample/addons.make | 0 examples/android/androidMultiOFActivitiesExample/addons.make | 0 examples/android/androidPolygonExample/addons.make | 0 examples/android/androidShaderExample/addons.make | 0 examples/android/androidSoundPlayerExample/addons.make | 0 examples/android/androidSwipeExample/addons.make | 0 examples/android/androidTouchExample/addons.make | 0 examples/android/androidVBOExample/addons.make | 0 examples/android/androidVibratorExample/addons.make | 0 examples/android/androidVideoExample/addons.make | 0 examples/events/rpiTouchExample/addons.make | 0 examples/gl/transformFeedbackExample/addons.make | 0 examples/gl/vboMeshDrawInstancedExample/addons.make | 0 examples/graphics/colorsExtendedExample/addons.make | 0 examples/ios/GLKitNativeARCExample/addons.make | 0 examples/ios/iosNativeARCExample/addons.make | 0 18 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 examples/android/androidFontExample/addons.make create mode 100644 examples/android/androidImageExample/addons.make create mode 100644 examples/android/androidJavaOnlyActivityExample/addons.make create mode 100644 examples/android/androidMultiOFActivitiesExample/addons.make create mode 100644 examples/android/androidPolygonExample/addons.make create mode 100644 examples/android/androidShaderExample/addons.make create mode 100644 examples/android/androidSoundPlayerExample/addons.make create mode 100644 examples/android/androidSwipeExample/addons.make create mode 100644 examples/android/androidTouchExample/addons.make create mode 100644 examples/android/androidVBOExample/addons.make create mode 100644 examples/android/androidVibratorExample/addons.make create mode 100644 examples/android/androidVideoExample/addons.make create mode 100644 examples/events/rpiTouchExample/addons.make create mode 100644 examples/gl/transformFeedbackExample/addons.make create mode 100644 examples/gl/vboMeshDrawInstancedExample/addons.make create mode 100644 examples/graphics/colorsExtendedExample/addons.make create mode 100644 examples/ios/GLKitNativeARCExample/addons.make create mode 100644 examples/ios/iosNativeARCExample/addons.make diff --git a/examples/android/androidFontExample/addons.make b/examples/android/androidFontExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidImageExample/addons.make b/examples/android/androidImageExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidJavaOnlyActivityExample/addons.make b/examples/android/androidJavaOnlyActivityExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidMultiOFActivitiesExample/addons.make b/examples/android/androidMultiOFActivitiesExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidPolygonExample/addons.make b/examples/android/androidPolygonExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidShaderExample/addons.make b/examples/android/androidShaderExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidSoundPlayerExample/addons.make b/examples/android/androidSoundPlayerExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidSwipeExample/addons.make b/examples/android/androidSwipeExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidTouchExample/addons.make b/examples/android/androidTouchExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidVBOExample/addons.make b/examples/android/androidVBOExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidVibratorExample/addons.make b/examples/android/androidVibratorExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidVideoExample/addons.make b/examples/android/androidVideoExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/events/rpiTouchExample/addons.make b/examples/events/rpiTouchExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/gl/transformFeedbackExample/addons.make b/examples/gl/transformFeedbackExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/gl/vboMeshDrawInstancedExample/addons.make b/examples/gl/vboMeshDrawInstancedExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/graphics/colorsExtendedExample/addons.make b/examples/graphics/colorsExtendedExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/ios/GLKitNativeARCExample/addons.make b/examples/ios/GLKitNativeARCExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/ios/iosNativeARCExample/addons.make b/examples/ios/iosNativeARCExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d From 89406143513ee8942c03cbafa32a35d7f3e8a2ec Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 19:43:11 -0300 Subject: [PATCH 43/91] more --- examples/android/androidCameraExample/addons.make | 0 examples/android/androidEmptyExample/addons.make | 0 examples/ios/moviePlayerExample/src/ofApp.mm | 10 +++++----- examples/shader/01_simpleColorQuad/addons.make | 0 .../shader/02_simpleVertexDisplacement/addons.make | 0 examples/shader/03_simpleShaderInteraction/addons.make | 0 examples/shader/04_simpleTexturing/addons.make | 0 examples/shader/05_alphaMasking/addons.make | 0 examples/shader/06_multiTexture/addons.make | 0 examples/shader/07_fboAlphaMask/addons.make | 0 10 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 examples/android/androidCameraExample/addons.make create mode 100644 examples/android/androidEmptyExample/addons.make create mode 100644 examples/shader/01_simpleColorQuad/addons.make create mode 100644 examples/shader/02_simpleVertexDisplacement/addons.make create mode 100644 examples/shader/03_simpleShaderInteraction/addons.make create mode 100644 examples/shader/04_simpleTexturing/addons.make create mode 100644 examples/shader/05_alphaMasking/addons.make create mode 100644 examples/shader/06_multiTexture/addons.make create mode 100644 examples/shader/07_fboAlphaMask/addons.make diff --git a/examples/android/androidCameraExample/addons.make b/examples/android/androidCameraExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/android/androidEmptyExample/addons.make b/examples/android/androidEmptyExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/ios/moviePlayerExample/src/ofApp.mm b/examples/ios/moviePlayerExample/src/ofApp.mm index a8323df49f2..c137637a8f2 100644 --- a/examples/ios/moviePlayerExample/src/ofApp.mm +++ b/examples/ios/moviePlayerExample/src/ofApp.mm @@ -22,7 +22,7 @@ [ofxiOSGetGLParentView() addSubview:controls.view]; AVFoundationVideoPlayer * avVideoPlayer; - avVideoPlayer = (__bridge AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer(); + avVideoPlayer = (AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer(); [avVideoPlayer setVideoPosition:CGPointMake(0, 240)]; [ofxiOSGetGLParentView() insertSubview:avVideoPlayer.playerView belowSubview:controls.view]; avVideoPlayer.playerView.hidden = YES; @@ -127,7 +127,7 @@ video.play(); AVFoundationVideoPlayer * avVideoPlayer; - avVideoPlayer = (__bridge AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer(); + avVideoPlayer = (AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer(); [avVideoPlayer setVideoPosition:CGPointMake(0, 240)]; [ofxiOSGetGLParentView() insertSubview:avVideoPlayer.playerView belowSubview:controls.view]; avVideoPlayer.playerView.hidden = YES; @@ -151,12 +151,12 @@ } void ofApp::nativeOnPressed() { - [(__bridge AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer() playerView].hidden = NO; + [(AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer() playerView].hidden = NO; [controls setNative:YES]; } void ofApp::nativeOffPressed() { - [(__bridge AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer() playerView].hidden = YES; + [(AVFoundationVideoPlayer *)video.getAVFoundationVideoPlayer() playerView].hidden = YES; [controls setNative:NO]; } @@ -175,7 +175,7 @@ if(controls) { [controls.view removeFromSuperview]; controls.delegate = nil; -// [controls release]; + [controls release]; controls = nil; } } diff --git a/examples/shader/01_simpleColorQuad/addons.make b/examples/shader/01_simpleColorQuad/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/shader/02_simpleVertexDisplacement/addons.make b/examples/shader/02_simpleVertexDisplacement/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/shader/03_simpleShaderInteraction/addons.make b/examples/shader/03_simpleShaderInteraction/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/shader/04_simpleTexturing/addons.make b/examples/shader/04_simpleTexturing/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/shader/05_alphaMasking/addons.make b/examples/shader/05_alphaMasking/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/shader/06_multiTexture/addons.make b/examples/shader/06_multiTexture/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/shader/07_fboAlphaMask/addons.make b/examples/shader/07_fboAlphaMask/addons.make new file mode 100644 index 00000000000..e69de29bb2d From abe1458fa892b3678db762d62cfbe67a2371813f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 19:44:59 -0300 Subject: [PATCH 44/91] updates --- examples/shader/08_displacementMap/addons.make | 0 examples/shader/09_gaussianBlurFilter/addons.make | 0 examples/windowing/noWindowExample/addons.make | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 examples/shader/08_displacementMap/addons.make create mode 100644 examples/shader/09_gaussianBlurFilter/addons.make create mode 100644 examples/windowing/noWindowExample/addons.make diff --git a/examples/shader/08_displacementMap/addons.make b/examples/shader/08_displacementMap/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/shader/09_gaussianBlurFilter/addons.make b/examples/shader/09_gaussianBlurFilter/addons.make new file mode 100644 index 00000000000..e69de29bb2d diff --git a/examples/windowing/noWindowExample/addons.make b/examples/windowing/noWindowExample/addons.make new file mode 100644 index 00000000000..e69de29bb2d From b12b190eeaf6fcbf1c3ed644c51ab7d1c09d1c68 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 20:24:33 -0300 Subject: [PATCH 45/91] ofdirectoshowplayer --- libs/openFrameworks/video/ofDirectShowPlayer.cpp | 2 +- libs/openFrameworks/video/ofDirectShowPlayer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/video/ofDirectShowPlayer.cpp b/libs/openFrameworks/video/ofDirectShowPlayer.cpp index 2ff3da97d7b..3cfe428b196 100644 --- a/libs/openFrameworks/video/ofDirectShowPlayer.cpp +++ b/libs/openFrameworks/video/ofDirectShowPlayer.cpp @@ -1125,7 +1125,7 @@ ofDirectShowPlayer & ofDirectShowPlayer::operator=(ofDirectShowPlayer&& other) { return *this; } -bool ofDirectShowPlayer::load(std::string path){ +bool ofDirectShowPlayer::load(of::filesystem::path path){ path = ofToDataPath(path); close(); diff --git a/libs/openFrameworks/video/ofDirectShowPlayer.h b/libs/openFrameworks/video/ofDirectShowPlayer.h index 1f8203c79b0..889bdaa3a10 100644 --- a/libs/openFrameworks/video/ofDirectShowPlayer.h +++ b/libs/openFrameworks/video/ofDirectShowPlayer.h @@ -21,7 +21,7 @@ class ofDirectShowPlayer : public ofBaseVideoPlayer{ ofDirectShowPlayer(ofDirectShowPlayer &&); ofDirectShowPlayer & operator=(ofDirectShowPlayer&&); - bool load(std::string path); + bool load(of::filesystem::path path); void update(); void close(); From af277ff869ba909d79b84bbe71377ec476da56dc Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 20:30:37 -0300 Subject: [PATCH 46/91] font --- libs/openFrameworks/graphics/ofTrueTypeFont.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp index 8802cd3340f..b89cd803ffe 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp @@ -375,8 +375,8 @@ static string linuxFontPathByName(const 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 of::filesystem::path& _fontname, FT_Face & face, of::filesystem::path & filename, int index){ + of::filesystem::path fontname = _fontname; filename = ofToDataPath(_fontname,true); ofFile fontFile(filename,ofFile::Reference); int fontID = index; @@ -698,7 +698,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 of::filesystem::path& filename, int fontSize, bool antialiased, bool fullCharacterSet, bool makeContours, float simplifyAmt, int dpi) { ofTrueTypeFontSettings settings(filename,fontSize); settings.antialiased = antialiased; From b0d47650f16f30f03f5c724bc3e9a9756a02e79c Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 20:47:09 -0300 Subject: [PATCH 47/91] fix android --- addons/ofxAndroid/src/ofAppAndroidWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ofxAndroid/src/ofAppAndroidWindow.cpp b/addons/ofxAndroid/src/ofAppAndroidWindow.cpp index 615ea03dc49..84534855b3e 100644 --- a/addons/ofxAndroid/src/ofAppAndroidWindow.cpp +++ b/addons/ofxAndroid/src/ofAppAndroidWindow.cpp @@ -266,7 +266,7 @@ Java_cc_openframeworks_OFAndroid_setAppDataDir( JNIEnv* env, jobject thiz, jst jboolean iscopy; const char *mfile = env->GetStringUTFChars(data_dir, &iscopy); __android_log_print(ANDROID_LOG_INFO,"ofAppAndroidWindow",("setting app dir name to: \"" + string(mfile) + "\"").c_str()); - ofSetDataPathRoot(string(mfile)+"/"); + ofSetDataPathRoot({ string(mfile)+"/" }); env->ReleaseStringUTFChars(data_dir, mfile); } From c5b749c823b9fa68bf3ddf9fe48204d8048db2ef Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 21:09:05 -0300 Subject: [PATCH 48/91] filesystem spaghetti --- libs/openFrameworks/utils/ofConstants.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index 0041dfc7de7..b9f9b288617 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -552,13 +552,21 @@ std::unique_ptr make_unique(Args&&... args) { #endif #else - // Regular C++17 fs support - #include - namespace of { - namespace filesystem = std::filesystem; - } + #if OF_HAS_CPP17 + #pragma message(Reminder "OF_HAS_CPP17") + + // Regular C++17 fs support + #include + namespace of { + namespace filesystem = std::filesystem; + } + #else + namespace of { + namespace filesystem = std::__fs::filesystem; + } + #endif #endif -#else +#else //OF_USING_STD_FS // No experimental or c++17 filesytem support use boost #if !_MSC_VER #define BOOST_NO_CXX11_SCOPED_ENUMS From f4716a5753daeac984389d29eb64fe2532634634 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 21:58:38 -0300 Subject: [PATCH 49/91] update --- libs/openFrameworks/utils/ofConstants.h | 2 +- libs/openFrameworks/utils/ofFileUtils.cpp | 7 +++++++ libs/openFrameworks/utils/ofXml.cpp | 3 +-- libs/openFrameworks/video/ofDirectShowPlayer.cpp | 5 +++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index b9f9b288617..e08a823b91d 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -566,7 +566,7 @@ std::unique_ptr make_unique(Args&&... args) { } #endif #endif -#else //OF_USING_STD_FS +#else //not OF_USING_STD_FS // No experimental or c++17 filesytem support use boost #if !_MSC_VER #define BOOST_NO_CXX11_SCOPED_ENUMS diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 32033f9d5f6..5d524a6c5ba 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -1681,6 +1681,7 @@ string ofFilePath::addLeadingSlash(const of::filesystem::path& _path){ of::filesystem::path ofFilePath::addTrailingSlash(const of::filesystem::path & _path){ #if OF_USING_STD_FS && !OF_USE_EXPERIMENTAL_FS if(_path.string().empty()) return ""; + // FIXME: Remove .string() here and following return (of::filesystem::path(_path).make_preferred() / "").string(); #else auto path = of::filesystem::path(_path).make_preferred().string(); @@ -1714,6 +1715,9 @@ string ofFilePath::getPathForDirectory(const of::filesystem::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 "/" + + // FIXME: Remove .string() here and following + #if OF_USING_STD_FS && !OF_USE_EXPERIMENTAL_FS if(path.string().empty()) return ""; return (path / "").string(); @@ -1728,6 +1732,7 @@ string ofFilePath::getPathForDirectory(const of::filesystem::path& path){ } //------------------------------------------------------------------------------------------------------------ +// FIXME: convert to of::filesystem::path string ofFilePath::removeTrailingSlash(const of::filesystem::path& _path){ auto path = _path.string(); if(path.length() > 0 && (path[path.length() - 1] == '/' || path[path.length() - 1] == '\\')){ @@ -1738,6 +1743,8 @@ string ofFilePath::removeTrailingSlash(const of::filesystem::path& _path){ //------------------------------------------------------------------------------------------------------------ +// FIXME: convert to of::filesystem::path + string ofFilePath::getFileName(const of::filesystem::path& _filePath, bool bRelativeToData){ // std::string filePath = _filePath.string(); // diff --git a/libs/openFrameworks/utils/ofXml.cpp b/libs/openFrameworks/utils/ofXml.cpp index af4675eb837..46b63a96ae5 100644 --- a/libs/openFrameworks/utils/ofXml.cpp +++ b/libs/openFrameworks/utils/ofXml.cpp @@ -18,8 +18,7 @@ ofXml::ofXml(std::shared_ptr doc, const pugi::xml_node & xml bool ofXml::load(const of::filesystem::path & file){ auto auxDoc = std::make_shared(); auto p = ofToDataPath(file); - auto res = auxDoc->load_file( - ofToDataPath(file).string().c_str()); + auto res = auxDoc->load_file(ofToDataPath(file).string().c_str()); if( res ){ doc = auxDoc; xml = doc->root(); diff --git a/libs/openFrameworks/video/ofDirectShowPlayer.cpp b/libs/openFrameworks/video/ofDirectShowPlayer.cpp index 3cfe428b196..a9e029187cb 100644 --- a/libs/openFrameworks/video/ofDirectShowPlayer.cpp +++ b/libs/openFrameworks/video/ofDirectShowPlayer.cpp @@ -427,7 +427,7 @@ class DirectShowVideo : public ISampleGrabberCB{ return E_NOTIMPL; } - bool loadMovie(std::string path, ofPixelFormat format){ + bool loadMovie(of::filesystem::path path, ofPixelFormat format){ tearDown(); this->pixelFormat = format; @@ -530,7 +530,8 @@ class DirectShowVideo : public ISampleGrabberCB{ } //printf("step 6\n"); - std::wstring filePathW = std::wstring(path.begin(), path.end()); + std::string pathString = path.string(); + std::wstring filePathW = std::wstring(pathString.begin(), pathString.end()); //this is the easier way to connect the graph, but we have to remove the video window manually hr = m_pGraph->RenderFile(filePathW.c_str(), NULL); From 7db22f0f0a3cfd47ff501c18a72bfb101e6d0f05 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 22:15:20 -0300 Subject: [PATCH 50/91] constants --- libs/openFrameworks/utils/ofConstants.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index e08a823b91d..e75b2494e6f 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -526,7 +526,7 @@ std::unique_ptr make_unique(Args&&... args) { } // new namespace of { - using std::__fs::filesystem; + namespace filesystem = std::experimental::filesystem; } #else #pragma message(Reminder "no OF_HAS_CPP17") @@ -546,7 +546,7 @@ std::unique_ptr make_unique(Args&&... args) { } // new namespace of { - namespace filesystem = std::__fs::filesystem; + namespace filesystem = std::experimental::filesystem; } #endif @@ -578,9 +578,6 @@ std::unique_ptr make_unique(Args&&... args) { namespace of { namespace filesystem = boost::filesystem; } - - - #endif From 696e8fef20f67e23c6639ef248dc1066578fbc4a Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Sep 2022 22:31:59 -0300 Subject: [PATCH 51/91] ofSetDataPathRoot --- addons/ofxiOS/src/core/ofxiOSAppDelegate.mm | 2 +- libs/openFrameworks/utils/ofFileUtils.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/ofxiOS/src/core/ofxiOSAppDelegate.mm b/addons/ofxiOS/src/core/ofxiOSAppDelegate.mm index 67aab9449f4..cb0f117afd8 100644 --- a/addons/ofxiOS/src/core/ofxiOSAppDelegate.mm +++ b/addons/ofxiOS/src/core/ofxiOSAppDelegate.mm @@ -62,7 +62,7 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application { currentScreenIndex = 0; // set the root application path - ofSetDataPathRoot([[NSString stringWithFormat:@"%@/", [[NSBundle mainBundle] resourcePath]] cStringUsingEncoding:NSUTF8StringEncoding]); + ofSetDataPathRoot(of::filesystem::path([[NSString stringWithFormat:@"%@/", [[NSBundle mainBundle] resourcePath]] cStringUsingEncoding:NSUTF8StringEncoding])); // show or hide status bar depending on OF_WINDOW or OF_FULLSCREEN [[UIApplication sharedApplication] setStatusBarHidden:(ofxiOSGetOFWindow()->getWindowMode() == OF_FULLSCREEN)]; diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index 761579bc18d..22d8aa2f654 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -1227,7 +1227,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(of::filesystem::path& root); +void ofSetDataPathRoot(const of::filesystem::path& root); /*! \cond PRIVATE */ namespace of{ From c62e8545eb2ee61403dafb434fa19cc583b23afc Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 29 Sep 2022 09:41:07 -0300 Subject: [PATCH 52/91] update test --- libs/openFrameworks/utils/ofFileUtils.cpp | 3 ++- libs/openFrameworks/video/ofDirectShowPlayer.cpp | 4 ++-- libs/openFrameworks/video/ofDirectShowPlayer.h | 2 +- tests/utils/fileUtils/src/main.cpp | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 5d524a6c5ba..8640d5412d2 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -997,7 +997,8 @@ bool ofFile::moveTo(const of::filesystem::path& _path, bool bRelativeToData, boo ofFile tmp; tmp.openFromCWD(path,ofFile::Reference); if(tmp.isDirectory()){ - path = ofFilePath::join(path,getFileName()); + path = path / getFileName(); +// path = ofFilePath::join(path,getFileName()); } } if(ofFile::doesFileExist(path, false)){ diff --git a/libs/openFrameworks/video/ofDirectShowPlayer.cpp b/libs/openFrameworks/video/ofDirectShowPlayer.cpp index a9e029187cb..cca890227e3 100644 --- a/libs/openFrameworks/video/ofDirectShowPlayer.cpp +++ b/libs/openFrameworks/video/ofDirectShowPlayer.cpp @@ -1126,8 +1126,8 @@ ofDirectShowPlayer & ofDirectShowPlayer::operator=(ofDirectShowPlayer&& other) { return *this; } -bool ofDirectShowPlayer::load(of::filesystem::path path){ - path = ofToDataPath(path); +bool ofDirectShowPlayer::load(std::string stringPath){ + auto path = ofToDataPath(of::filesystem::path(stringPath)); close(); player.reset(new DirectShowVideo()); diff --git a/libs/openFrameworks/video/ofDirectShowPlayer.h b/libs/openFrameworks/video/ofDirectShowPlayer.h index 889bdaa3a10..1f8203c79b0 100644 --- a/libs/openFrameworks/video/ofDirectShowPlayer.h +++ b/libs/openFrameworks/video/ofDirectShowPlayer.h @@ -21,7 +21,7 @@ class ofDirectShowPlayer : public ofBaseVideoPlayer{ ofDirectShowPlayer(ofDirectShowPlayer &&); ofDirectShowPlayer & operator=(ofDirectShowPlayer&&); - bool load(of::filesystem::path path); + bool load(std::string path); void update(); void close(); diff --git a/tests/utils/fileUtils/src/main.cpp b/tests/utils/fileUtils/src/main.cpp index 0ba2195dcd8..0bf2132e08e 100644 --- a/tests/utils/fileUtils/src/main.cpp +++ b/tests/utils/fileUtils/src/main.cpp @@ -182,7 +182,8 @@ class ofApp: public ofxUnitTestsApp{ #ifdef TARGET_WIN32 ofxTestEq(ofFilePath::join("d1","d2"),"d1\\d2","ofFilePath::join",ofFilePath::join("d1","d2")); #else - ofxTestEq(ofFilePath::join("d1","d2"),"d1/d2","ofFilePath::join",ofFilePath::join("d1","d2")); + // ofxTestEq(ofFilePath::join("d1","d2"),"d1/d2","ofFilePath::join",ofFilePath::join("d1","d2")); + ofxTestEq(ofFilePath::join("d1","d2").string(),"d1/d2","ofFilePath::join",ofFilePath::join("d1","d2").string()); #endif ofxTest(of::filesystem::exists(ofFile("test.txt")), "ofFile cast to filesystem::path"); From aa06269c5b0d8b1da5f4df4a8a737f7005e2d091 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 29 Sep 2022 09:51:34 -0300 Subject: [PATCH 53/91] updates --- addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index ba8ad330b74..d0a4d993d42 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -49,7 +49,7 @@ bool ofxAssimpModelLoader::load(string modelName, bool optimize){ unsigned int flags = initImportProperties(optimize); // loads scene from file - std::string path = file.getAbsolutePath().string(); + std::string path = file.getAbsolutePath(); scene = shared_ptr(aiImportFileExWithProperties(path.c_str(), flags, NULL, store.get()), aiReleaseImport); bool bOk = processScene(); From 9d37db47f6c45765b9424e3a92788c64f3000db6 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 29 Sep 2022 10:06:19 -0300 Subject: [PATCH 54/91] getAbsolutePath --- addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index d0a4d993d42..ba8ad330b74 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -49,7 +49,7 @@ bool ofxAssimpModelLoader::load(string modelName, bool optimize){ unsigned int flags = initImportProperties(optimize); // loads scene from file - std::string path = file.getAbsolutePath(); + std::string path = file.getAbsolutePath().string(); scene = shared_ptr(aiImportFileExWithProperties(path.c_str(), flags, NULL, store.get()), aiReleaseImport); bool bOk = processScene(); From 10740c4c7ee8d7ecd78d667cb3a1f4e86eb5fa78 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 29 Sep 2022 10:45:20 -0300 Subject: [PATCH 55/91] unittest --- addons/ofxUnitTests/src/ofxUnitTests.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/ofxUnitTests/src/ofxUnitTests.h b/addons/ofxUnitTests/src/ofxUnitTests.h index cb521ed451b..def6da0bf90 100644 --- a/addons/ofxUnitTests/src/ofxUnitTests.h +++ b/addons/ofxUnitTests/src/ofxUnitTests.h @@ -228,9 +228,9 @@ class ofxUnitTestsApp: public ofBaseApp{ const std::string APPVEYOR_API_URL = "APPVEYOR_API_URL"; if(ofGetEnv(APPVEYOR_API_URL)!=""){ //ofSystem("appveyor AddTest -Name " + projectName.string() + " -Framework ofxUnitTests -FileName " + exeName.string() + " -Outcome " + (passed?"Passed":"Failed") + " -Duration " + ofToString(now-then)); - auto projectDir = filesystem::canonical(filesystem::path(ofFilePath::getCurrentExeDir()) / ".."); + auto projectDir = of::filesystem::canonical(of::filesystem::path(ofFilePath::getCurrentExeDir()) / ".."); auto projectName = projectDir.stem(); - auto exeName = filesystem::path(ofFilePath::getCurrentExePath()).filename(); + auto exeName = of::filesystem::path(ofFilePath::getCurrentExePath()).filename(); auto stdOut = logger->getStdOut(); ofStringReplace(stdOut, "\\", "\\\\"); ofStringReplace(stdOut, "\"", "\\\""); From ac9478ee2fc9ffb1adcafd6ff013d09f93e1e166 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 29 Sep 2022 11:54:02 -0300 Subject: [PATCH 56/91] assimp --- .../ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index ba8ad330b74..1d997654978 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -260,18 +260,19 @@ void ofxAssimpModelLoader::loadGLResources(){ // FIXME: addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h could accept filesystem::path as a parameter // ofLoadImage accept? - auto realPath = ofFilePath::join(ofFilePath::join(modelFolder, relTexPath), texFile).string(); + // auto realPath = ofFilePath::join(ofFilePath::join(modelFolder, relTexPath), texFile).string(); + of::filesystem::path realPath = (modelFolder / relTexPath / texFile); if(ofFile::doesFileExist(realPath) == false) { ofLogError("ofxAssimpModelLoader") << "loadGLResource(): texture doesn't exist: \"" - << file.getFileName() + "\" in \"" << realPath << "\""; + << file.getFileName() + "\" in \"" << realPath.string() << "\""; } ofxAssimpTexture assimpTexture; bool bTextureAlreadyExists = false; for(size_t j = 0; j < textures.size(); j++) { assimpTexture = textures[j]; - if(assimpTexture.getTexturePath() == realPath) { + if(assimpTexture.getTexturePath() == realPath.string()) { bTextureAlreadyExists = true; break; } @@ -284,14 +285,14 @@ void ofxAssimpModelLoader::loadGLResources(){ ofTexture texture; bool bTextureLoadedOk = ofLoadImage(texture, realPath); if(bTextureLoadedOk) { - textures.push_back(ofxAssimpTexture(texture, realPath)); + textures.push_back(ofxAssimpTexture(texture, realPath.string())); assimpTexture = textures.back(); meshHelper.assimpTexture = assimpTexture; ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource(): texture loaded, dimensions: " << texture.getWidth() << "x" << texture.getHeight(); } else { ofLogError("ofxAssimpModelLoader") << "loadGLResource(): couldn't load texture: \"" - << file.getFileName() + "\" from \"" << realPath << "\""; + << file.getFileName() + "\" from \"" << realPath.string() << "\""; } } } From c9b5f186c65625846fb1b9bb7951c3e361504403 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 29 Sep 2022 19:07:01 -0300 Subject: [PATCH 57/91] fix tests for mingw --- examples/templates/allAddonsExample/addons.make | 1 - tests/utils/fileUtils/src/main.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/templates/allAddonsExample/addons.make b/examples/templates/allAddonsExample/addons.make index 88524ebedb4..350183a1861 100644 --- a/examples/templates/allAddonsExample/addons.make +++ b/examples/templates/allAddonsExample/addons.make @@ -8,4 +8,3 @@ ofxGui ofxKinect ofxSvg ofxPoco - diff --git a/tests/utils/fileUtils/src/main.cpp b/tests/utils/fileUtils/src/main.cpp index 0bf2132e08e..2428b07a1f8 100644 --- a/tests/utils/fileUtils/src/main.cpp +++ b/tests/utils/fileUtils/src/main.cpp @@ -180,7 +180,7 @@ class ofApp: public ofxUnitTestsApp{ ofxTestEq(ofFilePath::getBaseName("test/test.txt"),"test","ofFilePath::getBaseName",ofFilePath::getBaseName("test/test.txt")); ofxTestEq(ofFilePath::getBaseName(ofFilePath::removeTrailingSlash(ofFilePath::getEnclosingDirectory("testdir/test.txt"))),"testdir","ofFilePath::getEnclosingDirectory",ofFilePath::getBaseName(ofFilePath::getEnclosingDirectory("testdir/test.txt"))); #ifdef TARGET_WIN32 - ofxTestEq(ofFilePath::join("d1","d2"),"d1\\d2","ofFilePath::join",ofFilePath::join("d1","d2")); + ofxTestEq(ofFilePath::join("d1","d2").string(),"d1\\d2","ofFilePath::join",ofFilePath::join("d1","d2").string()); #else // ofxTestEq(ofFilePath::join("d1","d2"),"d1/d2","ofFilePath::join",ofFilePath::join("d1","d2")); ofxTestEq(ofFilePath::join("d1","d2").string(),"d1/d2","ofFilePath::join",ofFilePath::join("d1","d2").string()); From 3af37ad1cf7a05ba71ef1db736fb7222c3e950bb Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 1 Oct 2022 19:35:38 -0300 Subject: [PATCH 58/91] update constants --- libs/openFrameworks/utils/ofConstants.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index e75b2494e6f..ad81ef21235 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -1,11 +1,6 @@ #pragma once #include -#define Stringize( L ) #L -#define MakeString( M, L ) M(L) -#define $Line MakeString( Stringize, __LINE__ ) -#define Reminder __FILE__ "(" $Line ") : Reminder: " - //------------------------------- #define OF_VERSION_MAJOR 0 #define OF_VERSION_MINOR 11 @@ -511,8 +506,6 @@ std::unique_ptr make_unique(Args&&... args) { #include #if OF_HAS_CPP17 - #pragma message(Reminder "OF_HAS_CPP17") - namespace std { namespace experimental{ namespace filesystem { @@ -529,7 +522,6 @@ std::unique_ptr make_unique(Args&&... args) { namespace filesystem = std::experimental::filesystem; } #else - #pragma message(Reminder "no OF_HAS_CPP17") namespace std { namespace experimental{ @@ -553,7 +545,6 @@ std::unique_ptr make_unique(Args&&... args) { #else #if OF_HAS_CPP17 - #pragma message(Reminder "OF_HAS_CPP17") // Regular C++17 fs support #include From 6f85521424daa5d4a01b88c484a649dedde075f7 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 1 Oct 2022 19:47:49 -0300 Subject: [PATCH 59/91] reverting more files --- examples/templates/allAddonsExample/addons.make | 1 + .../project/osx/config.osx.default.mk | 7 ------- .../osx/openFrameworksLib.xcodeproj/project.pbxproj | 4 ---- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/examples/templates/allAddonsExample/addons.make b/examples/templates/allAddonsExample/addons.make index 350183a1861..88524ebedb4 100644 --- a/examples/templates/allAddonsExample/addons.make +++ b/examples/templates/allAddonsExample/addons.make @@ -8,3 +8,4 @@ ofxGui ofxKinect ofxSvg ofxPoco + diff --git a/libs/openFrameworksCompiled/project/osx/config.osx.default.mk b/libs/openFrameworksCompiled/project/osx/config.osx.default.mk index 71ba7c33ab1..083ea74476b 100644 --- a/libs/openFrameworksCompiled/project/osx/config.osx.default.mk +++ b/libs/openFrameworksCompiled/project/osx/config.osx.default.mk @@ -69,8 +69,6 @@ PLATFORM_REQUIRED_ADDONS = # Note: Be sure to leave a leading space when using a += operator to add items to the list ########################################################################################## -#MAC_OS_MIN_VERSION = 10.15 - ifndef MAC_OS_MIN_VERSION MAC_OS_MIN_VERSION = 10.9 endif @@ -168,9 +166,6 @@ endif PLATFORM_LDFLAGS = -stdlib=$(MAC_OS_STD_LIB) -#PLATFORM_LDFLAGS += -lstdc++fs - - #PLATFORM_LDFLAGS += -arch i386 PLATFORM_LDFLAGS += -mmacosx-version-min=$(MAC_OS_MIN_VERSION) -v @@ -247,8 +242,6 @@ ifeq ($(USE_FMOD),0) PLATFORM_CFLAGS += -DUSE_FMOD=0 endif - - ########################################################################################## # PLATFORM HEADER SEARCH PATHS # These are header search paths that are platform specific and are specified diff --git a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj index 58cbaaf5f28..21222d9b322 100644 --- a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj +++ b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj @@ -863,8 +863,6 @@ E4B27C1610CBEB8E00536013 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS)"; - CLANG_X86_VECTOR_INSTRUCTIONS = sse3; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/osx/"; COPY_PHASE_STRIP = NO; @@ -892,8 +890,6 @@ E4B27C1710CBEB8E00536013 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS)"; - CLANG_X86_VECTOR_INSTRUCTIONS = sse3; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/osx/"; COPY_PHASE_STRIP = YES; From cafcc3e5bddb1c5a1291f4ca91d72252a30943ec Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 1 Oct 2022 20:07:05 -0300 Subject: [PATCH 60/91] updates --- addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp | 1 + addons/ofxOpenCv/src/ofxCvConstants.h | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index 1d997654978..1c6f39ca7db 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -1,3 +1,4 @@ +#include "ofConstants.h" #include "ofxAssimpModelLoader.h" #include "ofxAssimpUtils.h" #include "ofLight.h" diff --git a/addons/ofxOpenCv/src/ofxCvConstants.h b/addons/ofxOpenCv/src/ofxCvConstants.h index 6f4dadade52..03980fc91ba 100644 --- a/addons/ofxOpenCv/src/ofxCvConstants.h +++ b/addons/ofxOpenCv/src/ofxCvConstants.h @@ -1,6 +1,9 @@ #pragma once -#ifdef MIN +#ifdef NO + #undef NO +#endif +#ifdef MIN #undef MIN #endif #ifdef MAX From 73683595415a98b370be7e9b0c12105df0df8e2a Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 1 Oct 2022 21:58:30 -0300 Subject: [PATCH 61/91] assimp fix? --- addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index 1c6f39ca7db..2f097c940ea 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -255,14 +255,14 @@ void ofxAssimpModelLoader::loadGLResources(){ // TODO: handle other aiTextureTypes if(AI_SUCCESS == mtl->GetTexture(aiTextureType_DIFFUSE, texIndex, &texPath)){ ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource(): loading image from \"" << texPath.data << "\""; - auto modelFolder = file.getEnclosingDirectory(); - auto relTexPath = ofFilePath::getEnclosingDirectory(texPath.data,false); - auto texFile = ofFilePath::getFileName(texPath.data); + of::filesystem::path modelFolder = file.getEnclosingDirectory(); + of::filesystem::path relTexPath = ofFilePath::getEnclosingDirectory(texPath.data,false); + of::filesystem::path texFile = ofFilePath::getFileName(texPath.data); // FIXME: addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h could accept filesystem::path as a parameter // ofLoadImage accept? // auto realPath = ofFilePath::join(ofFilePath::join(modelFolder, relTexPath), texFile).string(); - of::filesystem::path realPath = (modelFolder / relTexPath / texFile); + of::filesystem::path realPath = ((modelFolder / relTexPath) / texFile); if(ofFile::doesFileExist(realPath) == false) { ofLogError("ofxAssimpModelLoader") << "loadGLResource(): texture doesn't exist: \"" From 34a7a6b2d354665b8d2707ceb58205c42d8f9a9e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 1 Oct 2022 22:58:35 -0300 Subject: [PATCH 62/91] constants --- libs/openFrameworks/utils/ofConstants.h | 27 +++++++++++-------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index ad81ef21235..a995aadc5f6 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -515,14 +515,8 @@ std::unique_ptr make_unique(Args&&... args) { using v1::path; } } -// namespace filesystem = experimental::filesystem; } - // new - namespace of { - namespace filesystem = std::experimental::filesystem; - } #else - namespace std { namespace experimental{ namespace filesystem { @@ -534,24 +528,26 @@ std::unique_ptr make_unique(Args&&... args) { using v1::__cxx11::path; } } -// namespace filesystem = experimental::filesystem; } - // new - namespace of { - namespace filesystem = std::experimental::filesystem; - } - #endif + using fs = std::experimental::filesystem; + // new + namespace of { + namespace filesystem = std::experimental::filesystem; + } #else + #include #if OF_HAS_CPP17 +// using fs = std::filesystem; // Regular C++17 fs support - #include namespace of { - namespace filesystem = std::filesystem; + namespace filesystem = std::filesystem; } #else + using fs = std::__fs::filesystem; + namespace of { namespace filesystem = std::__fs::filesystem; } @@ -569,7 +565,8 @@ std::unique_ptr make_unique(Args&&... args) { namespace of { namespace filesystem = boost::filesystem; } - +// using fs = boost::filesystem; + #endif #if defined __has_include From a0d62885581ab7cc1036edc30306d6ce5a43f874 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 1 Oct 2022 23:25:12 -0300 Subject: [PATCH 63/91] namespace fix --- .../src/ofxAssimpAnimation.cpp | 2 +- .../src/ofxAssimpTexture.cpp | 2 +- .../ofxAssimpModelLoader/src/ofxAssimpUtils.h | 1 - addons/ofxGui/src/ofxBaseGui.cpp | 6 ++--- addons/ofxGui/src/ofxButton.cpp | 3 ++- addons/ofxGui/src/ofxGuiGroup.cpp | 25 ++++++++++--------- addons/ofxGui/src/ofxInputField.cpp | 2 +- addons/ofxGui/src/ofxLabel.cpp | 3 ++- addons/ofxGui/src/ofxPanel.cpp | 1 - addons/ofxGui/src/ofxSlider.cpp | 3 ++- addons/ofxGui/src/ofxSliderGroup.cpp | 3 ++- addons/ofxGui/src/ofxToggle.cpp | 1 - addons/ofxNetwork/src/ofxTCPClient.cpp | 2 +- addons/ofxNetwork/src/ofxUDPManager.cpp | 2 +- addons/ofxOsc/src/ofxOscReceiver.cpp | 2 +- addons/ofxOsc/src/ofxOscSender.cpp | 2 +- addons/ofxPoco/src/ofxXmlPoco.cpp | 9 ++++--- addons/ofxSvg/src/ofxSvg.cpp | 3 ++- .../src/ofxThreadedImageLoader.cpp | 3 +++ .../src/ofxThreadedImageLoader.h | 7 +++--- addons/ofxXmlSettings/src/ofxXmlSettings.h | 2 +- .../openFrameworks/types/ofParameterGroup.cpp | 1 - libs/openFrameworks/utils/ofFileUtils.h | 5 ---- libs/openFrameworks/utils/ofSystemUtils.cpp | 2 -- 24 files changed, 46 insertions(+), 46 deletions(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpAnimation.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpAnimation.cpp index 7d6263d9867..9556cee495e 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpAnimation.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpAnimation.cpp @@ -7,7 +7,7 @@ #include "ofAppRunner.h" #include "ofMath.h" -using namespace std; +using std::shared_ptr; ofxAssimpAnimation::ofxAssimpAnimation(shared_ptr scene, aiAnimation * animation) { this->scene = scene; diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp index 0559da5cfe7..2b02d8a8b2a 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp @@ -8,7 +8,7 @@ #include "ofxAssimpTexture.h" #include "ofConstants.h" -using namespace std; +using std::string; ofxAssimpTexture::ofxAssimpTexture() { texturePath = ""; diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpUtils.h b/addons/ofxAssimpModelLoader/src/ofxAssimpUtils.h index 44f1ccdf6a0..e2ba726c19c 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpUtils.h +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpUtils.h @@ -12,7 +12,6 @@ #include #include -using namespace std; //-------------------------------------------------------------- inline ofFloatColor aiColorToOfColor(const aiColor4D& c){ diff --git a/addons/ofxGui/src/ofxBaseGui.cpp b/addons/ofxGui/src/ofxBaseGui.cpp index 1d6cb525464..dd8879e4943 100644 --- a/addons/ofxGui/src/ofxBaseGui.cpp +++ b/addons/ofxGui/src/ofxBaseGui.cpp @@ -3,8 +3,8 @@ #include "ofBitmapFont.h" #include "ofXml.h" #include "ofJson.h" -using namespace std; +using std::string; void ofxGuiSetFont(const string & fontPath, int fontsize, bool _bAntiAliased, bool _bFullCharacterSet, int dpi){ ofxBaseGui::loadFont(fontPath, fontsize, _bAntiAliased, _bFullCharacterSet, dpi); @@ -414,7 +414,7 @@ void ofxBaseGui::setNeedsRedraw(){ } string ofxBaseGui::saveStencilToHex(const ofImage & img){ - stringstream strm; + std::stringstream strm; int width = img.getWidth(); int height = img.getHeight(); int n = width * height; @@ -427,7 +427,7 @@ string ofxBaseGui::saveStencilToHex(const ofImage & img){ } i++; if(i % 8 == 0){ - strm << "0x" << hex << (unsigned int)cur; + strm << "0x" << std::hex << (unsigned int)cur; cur = 0; shift = 0; if(i < n){ diff --git a/addons/ofxGui/src/ofxButton.cpp b/addons/ofxGui/src/ofxButton.cpp index fbbeb2b6d85..bc561fd60c0 100644 --- a/addons/ofxGui/src/ofxButton.cpp +++ b/addons/ofxGui/src/ofxButton.cpp @@ -1,5 +1,6 @@ #include "ofxButton.h" -using namespace std; + +//using namespace std; ofxButton::ofxButton(){ value.setSerializable(false); diff --git a/addons/ofxGui/src/ofxGuiGroup.cpp b/addons/ofxGui/src/ofxGuiGroup.cpp index 82b99acc0e8..b2eed036405 100644 --- a/addons/ofxGui/src/ofxGuiGroup.cpp +++ b/addons/ofxGui/src/ofxGuiGroup.cpp @@ -5,7 +5,8 @@ #include "ofxLabel.h" #include "ofxInputField.h" -using namespace std; +using std::string; +using std::vector; float ofxGuiGroup::elementSpacing = 1; float ofxGuiGroup::groupSpacing = 1; @@ -17,18 +18,18 @@ ofxGuiGroup::ofxGuiGroup(){ bGuiActive = false; } -ofxGuiGroup::ofxGuiGroup(const ofParameterGroup & parameters, const std::string& filename, float x, float y){ +ofxGuiGroup::ofxGuiGroup(const ofParameterGroup & parameters, const string& filename, float x, float y){ minimized = false; parent = nullptr; setup(parameters, filename, x, y); } -ofxGuiGroup * ofxGuiGroup::setup(const std::string& collectionName, const std::string& filename, float x, float y){ +ofxGuiGroup * ofxGuiGroup::setup(const string& collectionName, const string& filename, float x, float y){ ofParameterGroup parameters(collectionName); return setup(parameters, filename, x, y); } -ofxGuiGroup * ofxGuiGroup::setup(const ofParameterGroup & _parameters, const std::string& _filename, float x, float y){ +ofxGuiGroup * ofxGuiGroup::setup(const ofParameterGroup & _parameters, const string& _filename, float x, float y){ b.x = x; b.y = y; headerRect.height = defaultHeight; @@ -114,7 +115,7 @@ ofxGuiGroup * ofxGuiGroup::setup(const ofParameterGroup & _parameters, const std add(p); }else if(_parameters[i].valueType() == typeid(string).name()){ if(_parameters[i].isReadOnly()){ - auto p = _parameters.get(i).castReadOnly(); + auto p = _parameters.get(i).castReadOnly(); add(p); }else{ auto p = _parameters.getString(i); @@ -169,7 +170,7 @@ void ofxGuiGroup::add(ofParameter & parameter){ } void ofxGuiGroup::add(ofParameter & parameter){ - add(createGuiElement >(parameter)); + add(createGuiElement >(parameter)); } void ofxGuiGroup::add(ofParameter & parameter){ @@ -372,27 +373,27 @@ vector ofxGuiGroup::getControlNames() const{ return names; } -ofxIntSlider & ofxGuiGroup::getIntSlider(const std::string& name){ +ofxIntSlider & ofxGuiGroup::getIntSlider(const string& name){ return getControlType (name); } -ofxFloatSlider & ofxGuiGroup::getFloatSlider(const std::string& name){ +ofxFloatSlider & ofxGuiGroup::getFloatSlider(const string& name){ return getControlType (name); } -ofxToggle & ofxGuiGroup::getToggle(const std::string& name){ +ofxToggle & ofxGuiGroup::getToggle(const string& name){ return getControlType (name); } -ofxButton & ofxGuiGroup::getButton(const std::string& name){ +ofxButton & ofxGuiGroup::getButton(const string& name){ return getControlType (name); } -ofxGuiGroup & ofxGuiGroup::getGroup(const std::string& name){ +ofxGuiGroup & ofxGuiGroup::getGroup(const string& name){ return getControlType (name); } -ofxBaseGui * ofxGuiGroup::getControl(const std::string& name){ +ofxBaseGui * ofxGuiGroup::getControl(const string& name){ for(std::size_t i = 0; i < collection.size(); i++){ if(collection[i]->getName() == name){ return collection[i]; diff --git a/addons/ofxGui/src/ofxInputField.cpp b/addons/ofxGui/src/ofxInputField.cpp index 6d217c7eb34..812d479fe39 100644 --- a/addons/ofxGui/src/ofxInputField.cpp +++ b/addons/ofxGui/src/ofxInputField.cpp @@ -10,7 +10,7 @@ #include "ofGraphics.h" -using namespace std; +using std::string; namespace{ template diff --git a/addons/ofxGui/src/ofxLabel.cpp b/addons/ofxGui/src/ofxLabel.cpp index f07b026aca2..bcb56658cf1 100644 --- a/addons/ofxGui/src/ofxLabel.cpp +++ b/addons/ofxGui/src/ofxLabel.cpp @@ -1,6 +1,7 @@ #include "ofxLabel.h" #include "ofGraphics.h" -using namespace std; + +using std::string; ofxLabel::ofxLabel(ofParameter _label, float width, float height){ setup(_label,width,height); diff --git a/addons/ofxGui/src/ofxPanel.cpp b/addons/ofxGui/src/ofxPanel.cpp index af098a83f91..a422eef3314 100644 --- a/addons/ofxGui/src/ofxPanel.cpp +++ b/addons/ofxGui/src/ofxPanel.cpp @@ -8,7 +8,6 @@ #include "ofxPanel.h" #include "ofGraphics.h" #include "ofImage.h" -using namespace std; ofxPanel::ofxPanel() :bGrabbed(false){} diff --git a/addons/ofxGui/src/ofxSlider.cpp b/addons/ofxGui/src/ofxSlider.cpp index de217ec9659..3d13f1b1ad2 100644 --- a/addons/ofxGui/src/ofxSlider.cpp +++ b/addons/ofxGui/src/ofxSlider.cpp @@ -1,6 +1,7 @@ #include "ofxSlider.h" #include "ofGraphics.h" -using namespace std; + +using std::string; namespace{ template diff --git a/addons/ofxGui/src/ofxSliderGroup.cpp b/addons/ofxGui/src/ofxSliderGroup.cpp index 19897fd9324..480729c4b04 100644 --- a/addons/ofxGui/src/ofxSliderGroup.cpp +++ b/addons/ofxGui/src/ofxSliderGroup.cpp @@ -1,5 +1,6 @@ #include "ofxSliderGroup.h" -using namespace std; + +using std::string; template ofxVecSlider_::ofxVecSlider_(ofParameter value, float width, float height){ diff --git a/addons/ofxGui/src/ofxToggle.cpp b/addons/ofxGui/src/ofxToggle.cpp index 2d25bc23c12..8a351988c1f 100644 --- a/addons/ofxGui/src/ofxToggle.cpp +++ b/addons/ofxGui/src/ofxToggle.cpp @@ -1,6 +1,5 @@ #include "ofxToggle.h" #include "ofGraphics.h" -using namespace std; ofxToggle::ofxToggle(ofParameter _bVal, float width, float height){ setup(_bVal,width,height); diff --git a/addons/ofxNetwork/src/ofxTCPClient.cpp b/addons/ofxNetwork/src/ofxTCPClient.cpp index 6db5c519452..9d5ff8244e0 100644 --- a/addons/ofxNetwork/src/ofxTCPClient.cpp +++ b/addons/ofxNetwork/src/ofxTCPClient.cpp @@ -3,7 +3,7 @@ #include "ofxNetworkUtils.h" #include "ofLog.h" -using namespace std; +using std::string; //-------------------------- ofxTCPClient::ofxTCPClient(){ diff --git a/addons/ofxNetwork/src/ofxUDPManager.cpp b/addons/ofxNetwork/src/ofxUDPManager.cpp index cefb2d50e5d..1b137fb4484 100644 --- a/addons/ofxNetwork/src/ofxUDPManager.cpp +++ b/addons/ofxNetwork/src/ofxUDPManager.cpp @@ -6,7 +6,7 @@ #include "ofLog.h" #include "ofUtils.h" -using namespace std; +using std::string; //-------------------------------------------------------------------------------- bool ofxUDPManager::m_bWinsockInit= false; diff --git a/addons/ofxOsc/src/ofxOscReceiver.cpp b/addons/ofxOsc/src/ofxOscReceiver.cpp index 7bce27d824b..06d625eefca 100644 --- a/addons/ofxOsc/src/ofxOscReceiver.cpp +++ b/addons/ofxOsc/src/ofxOscReceiver.cpp @@ -2,7 +2,7 @@ // copyright (c) Damian Stewart 2007-2009 #include "ofxOscReceiver.h" -using namespace std; +using std::string; //-------------------------------------------------------------- ofxOscReceiver::~ofxOscReceiver(){ diff --git a/addons/ofxOsc/src/ofxOscSender.cpp b/addons/ofxOsc/src/ofxOscSender.cpp index 56206bf6a1f..00c30d01329 100644 --- a/addons/ofxOsc/src/ofxOscSender.cpp +++ b/addons/ofxOsc/src/ofxOscSender.cpp @@ -6,7 +6,7 @@ #include "UdpSocket.h" -using namespace std; +using std::string; //-------------------------------------------------------------- ofxOscSender::~ofxOscSender() { diff --git a/addons/ofxPoco/src/ofxXmlPoco.cpp b/addons/ofxPoco/src/ofxXmlPoco.cpp index 0702888d528..e634c9fd2b9 100644 --- a/addons/ofxPoco/src/ofxXmlPoco.cpp +++ b/addons/ofxPoco/src/ofxXmlPoco.cpp @@ -2,7 +2,10 @@ #include "ofxXmlPoco.h" #include "Poco/AutoPtr.h" -using namespace std; +using std::string; +using std::vector; +using std::ostringstream; +using std::map; ofxXmlPoco::~ofxXmlPoco(){ releaseAll(); @@ -104,7 +107,7 @@ string ofxXmlPoco::toString() const{ if(document){ try{ writer.writeNode( stream, getPocoDocument() ); - }catch( exception & e ){ + }catch( std::exception & e ){ ofLogError("ofxXmlPoco") << "toString(): " << e.what(); } } else if(element){ @@ -724,7 +727,7 @@ bool ofxXmlPoco::loadFromBuffer(const string & buffer){ element = document->documentElement(); return false; } - catch(const exception & e){ + catch(const std::exception & e){ short msg = atoi(e.what()); ofLogError("ofxXmlPoco") << "parse error: " << DOMErrorMessage(msg); document = new Poco::XML::Document; diff --git a/addons/ofxSvg/src/ofxSvg.cpp b/addons/ofxSvg/src/ofxSvg.cpp index 7d629cd680c..ee6e8348acb 100644 --- a/addons/ofxSvg/src/ofxSvg.cpp +++ b/addons/ofxSvg/src/ofxSvg.cpp @@ -2,7 +2,8 @@ #include "ofConstants.h" #include -using namespace std; +using std::string; +using std::vector; extern "C"{ #include "svgtiny.h" diff --git a/addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.cpp b/addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.cpp index a6c118bfad2..a37675ca3e3 100644 --- a/addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.cpp +++ b/addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.cpp @@ -1,5 +1,8 @@ #include "ofxThreadedImageLoader.h" #include + +using std::string; + ofxThreadedImageLoader::ofxThreadedImageLoader(){ nextID = 0; ofAddListener(ofEvents().update, this, &ofxThreadedImageLoader::update); diff --git a/addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.h b/addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.h index 8bd918123b3..ea7888e5026 100644 --- a/addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.h +++ b/addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.h @@ -6,8 +6,7 @@ #include "ofTypes.h" #include "ofThreadChannel.h" - -using namespace std; +using std::string; class ofxThreadedImageLoader : public ofThread { public: @@ -40,12 +39,12 @@ class ofxThreadedImageLoader : public ofThread { }; - typedef map::iterator entry_iterator; + typedef std::map::iterator entry_iterator; int nextID; int lastUpdate; - map images_async_loading; // keeps track of images which are loading async + std::map images_async_loading; // keeps track of images which are loading async ofThreadChannel images_to_load_from_disk; ofThreadChannel images_to_update; }; diff --git a/addons/ofxXmlSettings/src/ofxXmlSettings.h b/addons/ofxXmlSettings/src/ofxXmlSettings.h index 091fbe1a669..4458ad0cc5d 100644 --- a/addons/ofxXmlSettings/src/ofxXmlSettings.h +++ b/addons/ofxXmlSettings/src/ofxXmlSettings.h @@ -8,7 +8,7 @@ #include "tinyxml.h" #endif -using namespace std; +//using namespace std; /* Q: what is the which = 0 argument? diff --git a/libs/openFrameworks/types/ofParameterGroup.cpp b/libs/openFrameworks/types/ofParameterGroup.cpp index a39932322b9..d21952771cd 100644 --- a/libs/openFrameworks/types/ofParameterGroup.cpp +++ b/libs/openFrameworks/types/ofParameterGroup.cpp @@ -1,7 +1,6 @@ #include "ofUtils.h" #include "ofParameter.h" -// using namespace std; using std::string; using std::endl; using std::setw; diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index 22d8aa2f654..be99d316a9d 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -3,11 +3,6 @@ #include "ofConstants.h" #include -// #include - -// using std::filesystem; -// using std::fs; -// using namespace std::filesystem; //---------------------------------------------------------- // ofBuffer //---------------------------------------------------------- diff --git a/libs/openFrameworks/utils/ofSystemUtils.cpp b/libs/openFrameworks/utils/ofSystemUtils.cpp index 4aa9b20a9de..62859ffcdde 100644 --- a/libs/openFrameworks/utils/ofSystemUtils.cpp +++ b/libs/openFrameworks/utils/ofSystemUtils.cpp @@ -92,7 +92,6 @@ static void restoreAppWindowFocus(){ #define CANCEL_BUTTON GTK_STOCK_CANCEL #endif -// using namespace std; gboolean init_gtk(gpointer userdata){ int argc=0; char **argv = nullptr; @@ -252,7 +251,6 @@ void resetLocale(std::locale locale){ #include #endif -// using namespace std; //------------------------------------------------------------------------------ ofFileDialogResult::ofFileDialogResult(){ From bca09a05365a4b282f963e184df1b1503d1c057b Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 1 Oct 2022 23:46:00 -0300 Subject: [PATCH 64/91] actions --- .github/workflows/build-macos.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 8fd01b04d6f..f4516959bc0 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -24,17 +24,6 @@ jobs: OPT: ${{matrix.cfg.opt}} steps: - uses: actions/checkout@v2 - - name: Cache compile - id: cache-compile - uses: actions/cache@v3 - env: - cache-name: cache-keep-compile - with: - path: libs/openFrameworksCompiled/lib/osx/**/ - key: ${{ runner.os }}-${{matrix.cfg.opt}}-${{ env.cache-name }}-${{ hashFiles('**/*.cpp') }} - restore-keys: | - ${{ runner.os }}-${{matrix.cfg.opt}}-${{ env.cache-name }}- - - name: Cache libs id: cache-libs From 5e7134aeff786d52cbc6b47a7c03acc7b1d4c525 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 1 Oct 2022 23:57:19 -0300 Subject: [PATCH 65/91] filePath --- addons/ofxGui/src/ofxButton.cpp | 2 -- addons/ofxPoco/src/ofxXmlPoco.cpp | 8 ++++---- addons/ofxPoco/src/ofxXmlPoco.h | 4 ++-- addons/ofxXmlSettings/src/ofxXmlSettings.h | 1 - 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/addons/ofxGui/src/ofxButton.cpp b/addons/ofxGui/src/ofxButton.cpp index bc561fd60c0..3ec150e90c4 100644 --- a/addons/ofxGui/src/ofxButton.cpp +++ b/addons/ofxGui/src/ofxButton.cpp @@ -1,7 +1,5 @@ #include "ofxButton.h" -//using namespace std; - ofxButton::ofxButton(){ value.setSerializable(false); } diff --git a/addons/ofxPoco/src/ofxXmlPoco.cpp b/addons/ofxPoco/src/ofxXmlPoco.cpp index e634c9fd2b9..70a4f337bad 100644 --- a/addons/ofxPoco/src/ofxXmlPoco.cpp +++ b/addons/ofxPoco/src/ofxXmlPoco.cpp @@ -45,8 +45,8 @@ ofxXmlPoco::ofxXmlPoco(){ } -bool ofxXmlPoco::load(const of::filesystem::path & path){ - ofFile file(path, ofFile::ReadOnly); +bool ofxXmlPoco::load(const of::filesystem::path & filePath){ + ofFile file(filePath, ofFile::ReadOnly); if(!file.exists()){ ofLogError("ofxXmlPoco") << "couldn't load, \"" << file.getFileName() << "\" not found"; return false; @@ -56,10 +56,10 @@ bool ofxXmlPoco::load(const of::filesystem::path & path){ } -bool ofxXmlPoco::save(const of::filesystem::path & path){ +bool ofxXmlPoco::save(const of::filesystem::path & filePath){ ofBuffer buffer; buffer.set(toString()); - ofFile file(path, ofFile::WriteOnly); + ofFile file(filePath, ofFile::WriteOnly); return file.writeFromBuffer(buffer); } diff --git a/addons/ofxPoco/src/ofxXmlPoco.h b/addons/ofxPoco/src/ofxXmlPoco.h index fce42c9a66a..6998b39a5bf 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 of::filesystem::path & path); - bool save(const of::filesystem::path & path); + bool load(const of::filesystem::path & filePath); + bool save(const of::filesystem::path & filePath); bool addChild( const std::string& path ); void addXml( ofxXmlPoco& xml, bool copyAll = false); diff --git a/addons/ofxXmlSettings/src/ofxXmlSettings.h b/addons/ofxXmlSettings/src/ofxXmlSettings.h index 4458ad0cc5d..0afc2d53d62 100644 --- a/addons/ofxXmlSettings/src/ofxXmlSettings.h +++ b/addons/ofxXmlSettings/src/ofxXmlSettings.h @@ -8,7 +8,6 @@ #include "tinyxml.h" #endif -//using namespace std; /* Q: what is the which = 0 argument? From 162663d05b71691877e3df38163dfea4d24d702f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 2 Oct 2022 00:18:17 -0300 Subject: [PATCH 66/91] updates --- libs/openFrameworks/utils/ofConstants.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index a995aadc5f6..28d064b5c97 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -509,10 +509,10 @@ std::unique_ptr make_unique(Args&&... args) { namespace std { namespace experimental{ namespace filesystem { - namespace v1 { - class path; - } - using v1::path; +// namespace v1 { +// class path; +// } + using path = v1::path; } } } @@ -520,12 +520,12 @@ std::unique_ptr make_unique(Args&&... args) { namespace std { namespace experimental{ namespace filesystem { - namespace v1 { - namespace __cxx11 { - class path; - } - } - using v1::__cxx11::path; +// namespace v1 { +// namespace __cxx11 { +// class path; +// } +// } + using path = v1::__cxx11::path; } } } @@ -546,10 +546,11 @@ std::unique_ptr make_unique(Args&&... args) { namespace filesystem = std::filesystem; } #else - using fs = std::__fs::filesystem; +// using fs = std::__fs::filesystem; namespace of { - namespace filesystem = std::__fs::filesystem; +// namespace filesystem = std::__fs::filesystem; + namespace filesystem = std::filesystem; } #endif #endif From 269f768e48ba09bb507c7b4690624ad4dceaacb4 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 5 Oct 2022 04:36:29 -0300 Subject: [PATCH 67/91] rm removed files --- libs/openFrameworks/video/ofQTKitGrabber.mm | 975 ------------------ libs/openFrameworks/video/ofQTKitPlayer.mm | 465 --------- .../video/ofQuickTimePlayer.cpp | 887 ---------------- 3 files changed, 2327 deletions(-) delete mode 100644 libs/openFrameworks/video/ofQTKitGrabber.mm delete mode 100644 libs/openFrameworks/video/ofQTKitPlayer.mm delete mode 100644 libs/openFrameworks/video/ofQuickTimePlayer.cpp diff --git a/libs/openFrameworks/video/ofQTKitGrabber.mm b/libs/openFrameworks/video/ofQTKitGrabber.mm deleted file mode 100644 index b5b0a8100ab..00000000000 --- a/libs/openFrameworks/video/ofQTKitGrabber.mm +++ /dev/null @@ -1,975 +0,0 @@ - -#include "ofQTKitGrabber.h" -#include "ofLog.h" -#include "ofVideoBaseTypes.h" -#include "ofSystemUtils.h" - -#ifdef OF_VIDEO_CAPTURE_QTKIT - -#if !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 -#if defined(MAC_OS_X_VERSION_10_9) - #warning Using QTKit, which is deprecated in OSX 10.9 -#endif - -#import -#import -#import - -//This Objective-C class contains all the OS specific -//Stuff we need for pulling images from a video camera feed -//the QTCaptureVideoPreviewOutput is a non-blocking frame receiver delegate -//for a QTCaptureSession -//All you wanted to know and more about QTKit Capture can be found here: -// http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/QTKitApplicationProgrammingGuide/UsingQTKit/UsingQTKit.html - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - - -@interface QTKitVideoGrabber : QTCaptureVideoPreviewOutput -{ - QTCaptureSession *session; - QTCaptureDeviceInput *videoDeviceInput; - QTCaptureDeviceInput *audioDeviceInput; - QTCaptureDevice* selectedVideoDevice; - QTCaptureDevice* selectedAudioDevice; - QTCaptureMovieFileOutput *captureMovieFileOutput; - NSInteger width, height; - NSInteger videoDeviceID, audioDeviceID; - - CVImageBufferRef cvFrame; - ofPixels* pixels; - ofQTKitGrabber* grabber; - - BOOL hasNewFrame; - BOOL isFrameNew; - BOOL isRecording; - BOOL isRecordReady; - BOOL useAudio; -} - -@property(nonatomic, readonly) NSInteger height; -@property(nonatomic, readonly) NSInteger width; -@property(nonatomic, readwrite) NSInteger videoDeviceID; -@property(nonatomic, readwrite) NSInteger audioDeviceID; -@property(retain) QTCaptureSession* session; -@property(nonatomic, retain) QTCaptureDeviceInput* videoDeviceInput; -@property(nonatomic, retain) QTCaptureDeviceInput* audioDeviceInput; -@property(nonatomic, retain) QTCaptureMovieFileOutput *captureMovieFileOutput; -@property(nonatomic, readonly) BOOL isRunning; -@property(readonly) BOOL isFrameNew; -@property(readonly) BOOL isRecording; -@property(readonly) BOOL isRecordReady; -@property(nonatomic, readwrite) BOOL useAudio; -@property(nonatomic, readwrite) ofQTKitGrabber* grabber; //for event reference setting - -//Static list helpsers -+ (NSArray*) listVideoDevices; -+ (NSArray*) listAudioDevices; -+ (NSArray*) listVideoCodecs; -+ (NSArray*) listAudioCodecs; - -+ (void) enumerateArray:(NSArray*)someArray; -+ (NSInteger) getIndexofStringInArray:(NSArray*)someArray stringToFind:(NSString*)someStringDescription; - -//initialization -- (void) setVideoDeviceID:(NSInteger)_videoDeviceID; -- (void) setAudioDeviceID:(NSInteger)_audioDeviceID; //audio device is only used for recording - -//Create the recorder, flexible to be previewless and -// -- (id) initWithWidth:(NSInteger)_width - height:(NSInteger)_height - videodevice:(NSInteger)_videoDeviceID - audiodevice:(NSInteger)_audioDeviceID - usingAudio:(BOOL)_useAudio - capturePixels:(BOOL)_shouldCapturePixels - pixelsRef:(ofPixelsRef)_pixels; - - -//life cycle -- (void) startSession; -- (void) update; -- (void) stop; - -//delegate method for getting pixels -- (void) outputVideoFrame:(CVImageBufferRef)videoFrame - withSampleBuffer:(QTSampleBuffer *)sampleBuffer - fromConnection:(QTCaptureConnection *)connection; - -//Recording -- (BOOL) initRecording:(NSString*)_selectedVideoCodec audioCodec:(NSString*)_selectedAudioCodec; -- (void) setVideoCodec:(NSString*)_selectedVideoCodec; -- (void) setAudioCodec:(NSString*)_selectedAudioCodec; -- (void) startRecording:(NSString*)filePath; -- (void) stopRecording; -- (void) captureOutput:(QTCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL forConnections:(NSArray *)connections dueToError:(NSError *)error; - -//internal methods -- (BOOL) setSelectedVideoDevice:(QTCaptureDevice *)selectedVideoDevice; -- (BOOL) setSelectedAudioDevice:(QTCaptureDevice *)selectedAudioDevice; - - -@end - -@implementation QTKitVideoGrabber -@synthesize width, height; -@synthesize session; -@synthesize videoDeviceID; -@synthesize audioDeviceID; -@synthesize videoDeviceInput; -@synthesize audioDeviceInput; -@synthesize captureMovieFileOutput; -@synthesize isFrameNew; -@synthesize isRecording; -@synthesize isRecordReady; -@synthesize useAudio; -@synthesize grabber; - -+ (void) enumerateArray:(NSArray*)someArray -{ - NSInteger count = 0; - for (id object in someArray) { - ofLogVerbose("ofQtKitGrabber") << count << " - " << [[object description] UTF8String]; - count++; - } -} - -+ (NSInteger) getIndexofStringInArray:(NSArray*)someArray stringToFind:(NSString*)someStringDescription -{ - NSInteger index = -1; - - for (id object in someArray) { - if ([[object description] isEqualToString:someStringDescription]) { - return index; - } - } - return -1; -} - -+ (NSArray*) listVideoDevices -{ - //create a session for enumerating devices - NSArray* videoDevices = [[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo] - arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]]; - - ofLogVerbose("ofQTKitGrabber") << "listing video devices:"; - [self enumerateArray:videoDevices]; - - return videoDevices; - -} - -+ (NSArray*) listAudioDevices -{ - //create a session for enumerating devices - NSArray* audioDevices = [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeSound]; - - ofLogVerbose("ofQTKitGrabber") << "listing audio devices:"; - [self enumerateArray:audioDevices]; - - return audioDevices; -} - -- (id) initWithWidth:(NSInteger)_width - height:(NSInteger)_height - videodevice:(NSInteger)_videoDeviceID - audiodevice:(NSInteger)_audioDeviceID - usingAudio:(BOOL)_useAudio - capturePixels:(BOOL)_shouldCapturePixels - pixelsRef:(ofPixelsRef)_pixels -{ - if((self = [super init])){ - //configure self - width = _width; - height = _height; - - //instance variables - cvFrame = NULL; - hasNewFrame = NO; - self.useAudio = _useAudio; - isRecordReady = NO; - isRecording = NO; - - NSMutableDictionary* pixelBufferAttributes = [NSMutableDictionary dictionary]; - //we can turn capture pixels off if we just want to use this object for recording - if(_shouldCapturePixels){ - [pixelBufferAttributes setValue:[NSNumber numberWithInt: kCVPixelFormatType_32BGRA] - forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; - [pixelBufferAttributes setValue:[NSNumber numberWithBool:YES] - forKey:(NSString*)kCVPixelBufferOpenGLCompatibilityKey]; - } - if(width != -1 && height != -1){ - [pixelBufferAttributes setValue:[NSNumber numberWithInt:width] - forKey:(NSString*)kCVPixelBufferWidthKey]; - [pixelBufferAttributes setValue:[NSNumber numberWithInt:height] - forKey:(NSString*)kCVPixelBufferHeightKey]; - } - - if(pixelBufferAttributes.count > 0){ - [self setPixelBufferAttributes: pixelBufferAttributes ]; - } - //init the session - self.session = [[[QTCaptureSession alloc] init] autorelease]; - - if(_shouldCapturePixels){ - pixels = &_pixels; - if(width != -1 && height != -1){ - pixels->allocate(width, height, OF_IMAGE_COLOR); - } - - NSError* error; - bool success = [self.session addOutput:self error:&error]; - if( !success ){ - ofLogError("ofQTKitGrabber") << "failed to add delegate to capture session: " << [[error description] UTF8String]; - return nil; - } - } - - videoDeviceID = -1; - [self setVideoDeviceID:_videoDeviceID]; - - // if we're using audio add an audio device - if (self.useAudio) { - audioDeviceID = -1; - [self setAudioDeviceID:_audioDeviceID]; - } - - [self startSession]; - } - return self; -} - - -- (void) startSession -{ - //start the session - ofLogVerbose("ofQTKitGrabber") << "starting video session"; - [session startRunning]; - -} - -- (void) setVideoDeviceID:(NSInteger)_videoDeviceID -{ - if(videoDeviceID != _videoDeviceID){ - - //get video device - NSArray* videoDevices = [[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo] - arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]]; - - // Try to open the new device - if(_videoDeviceID < 0 || _videoDeviceID >= videoDevices.count){ - ofLogError("ofQTKitGrabber") << "selected video device id " << _videoDeviceID << " out of range for number of devices: " << videoDevices.count; - return; - } - selectedVideoDevice = [videoDevices objectAtIndex:_videoDeviceID]; - if([self setSelectedVideoDevice:selectedVideoDevice]){ - videoDeviceID = _videoDeviceID; - } - } -} - -- (void) setAudioDeviceID:(NSInteger)_audioDeviceID -{ - if(audioDeviceID != _audioDeviceID){ - - //get audio device - NSArray* audioDevices = [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeSound]; - - // Try to open the new device - if(_audioDeviceID < 0 || _audioDeviceID >= audioDevices.count){ - ofLogError("ofQTKitGrabber") << "selected video device id " << _audioDeviceID << " is out of range for number of devices: " << audioDevices.count; - return; - } - - selectedAudioDevice = [audioDevices objectAtIndex:_audioDeviceID]; - if(selectedAudioDevice == nil){ - ofLogError("ofQTKitGrabber") << "audio device is NULL for id " << _audioDeviceID << endl; - } - if([self setSelectedAudioDevice:selectedAudioDevice]){ - audioDeviceID = _audioDeviceID; - } - } -} - -- (BOOL) setSelectedVideoDevice:(QTCaptureDevice *)_selectedVideoDevice -{ - BOOL success = YES; - if (self.videoDeviceInput != nil) { - ofLogVerbose("ofQTKitGrabber") << "removing existing video device " << [self.videoDeviceInput.description UTF8String]; - // Remove the old device input from the session and close the device - [self.session removeInput:videoDeviceInput]; - [[self.videoDeviceInput device] close]; - self.videoDeviceInput = nil; - } - - if (_selectedVideoDevice != nil) { - NSError *error = nil; - - // Try to open the new device - success = [_selectedVideoDevice open:&error]; - if(success){ - // Create a device input for the device and add it to the session - self.videoDeviceInput = [QTCaptureDeviceInput deviceInputWithDevice:_selectedVideoDevice]; - - success = [self.session addInput:self.videoDeviceInput error:&error]; - if(!success || error != nil){ - ofLogError("ofQTKitGrabber") << "failed to add the video device input: " << [[error localizedDescription] UTF8String]; - } - else{ - ofLogVerbose("ofQTKitGrabber") << "attached video device: " << [_selectedVideoDevice.description UTF8String]; - } - } - else { - ofLogError("ofQTKitGrabber") << "failed to open the video device input: " << [[error localizedDescription] UTF8String]; - } - } - - return success; -} - -- (BOOL) setSelectedAudioDevice:(QTCaptureDevice *)_selectedAudioDevice -{ - BOOL success = YES; - if (self.audioDeviceInput != nil) { - ofLogVerbose("ofQTKitGrabber") << "removing existing audio device " << [self.audioDeviceInput.description UTF8String]; - // Remove the old device input from the session and close the device - [self.session removeInput:audioDeviceInput]; - [[self.audioDeviceInput device] close]; - self.audioDeviceInput = nil; - } - - if (_selectedAudioDevice != nil) { - NSError *error = nil; - - // Try to open the new device - success = [_selectedAudioDevice open:&error]; - if(success){ - // Create a device input for the device and add it to the session - self.audioDeviceInput = [QTCaptureDeviceInput deviceInputWithDevice:_selectedAudioDevice]; - - success = [self.session addInput:self.audioDeviceInput error:&error]; - if(!success && error != nil){ - ofLogError("ofQTKitGrabber") << "failed to add the audio device input: " << [[error localizedDescription] UTF8String]; - } - else{ - ofLogVerbose("ofQTKitGrabber") << "attached audio device: " << [_selectedAudioDevice.description UTF8String]; - } - } - else { - ofLogError("ofQTKitGrabber") << "failed to open the audio device: " << [[error localizedDescription] UTF8String]; - } - } - - return success; -} - -- (BOOL) initRecording:(NSString*)_selectedVideoCodec audioCodec:(NSString*)_selectedAudioCodec -{ - BOOL success = YES; - NSError *error = nil; - - // Create the movie file output and add it to the session - self.captureMovieFileOutput = [[[QTCaptureMovieFileOutput alloc] init] autorelease]; - [self.captureMovieFileOutput setDelegate:self]; - - success = [self.session addOutput:captureMovieFileOutput error:&error]; - if (!success) { - ofLogError("ofQTKitGrabber") << "failed to initialize recording: " << [[error localizedDescription] UTF8String]; - isRecordReady = NO; - } - else { - [self setVideoCodec:_selectedVideoCodec]; - [self setAudioCodec:_selectedAudioCodec]; - ofLogVerbose("ofQTKitGrabber") << "video codec is " << [[_selectedVideoCodec description] UTF8String]; - ofLogVerbose("ofQTKitGrabber") << "audio codec is " << [[_selectedAudioCodec description] UTF8String]; - isRecordReady = YES; - } - return success; -} - -+ (NSArray*) listVideoCodecs -{ - NSArray* videoCodecs = [QTCompressionOptions compressionOptionsIdentifiersForMediaType:QTMediaTypeVideo]; - - ofLogVerbose("ofQTKitGrabber") << "listing available video codecs:"; - [self enumerateArray:videoCodecs]; - - return videoCodecs; -} - -+ (NSArray*) listAudioCodecs -{ - NSArray* audioCodecs = [QTCompressionOptions compressionOptionsIdentifiersForMediaType:QTMediaTypeSound]; - - ofLogVerbose("ofQTKitGrabber") << "listing available audio codecs:"; - [self enumerateArray:audioCodecs]; - - return audioCodecs; -} - -- (void) setVideoCodec:(NSString*)_selectedVideoCodec -{ - // set codec on connection for type Video - NSArray *outputConnections = [captureMovieFileOutput connections]; - QTCaptureConnection *connection; - for (connection in outputConnections) { - if ([[connection mediaType] isEqualToString:QTMediaTypeVideo]){ - [captureMovieFileOutput setCompressionOptions:[QTCompressionOptions compressionOptionsWithIdentifier:_selectedVideoCodec] - forConnection:connection]; - } - } -} - -- (void) setAudioCodec:(NSString*)_selectedAudioCodec -{ - // set codec on connection for type Sound - NSArray *outputConnections = [captureMovieFileOutput connections]; - QTCaptureConnection *connection; - for (connection in outputConnections) { - if ([[connection mediaType] isEqualToString:QTMediaTypeSound]){ - [self.captureMovieFileOutput setCompressionOptions:[QTCompressionOptions compressionOptionsWithIdentifier:_selectedAudioCodec] - forConnection:connection]; - } - } -} - -- (void) startRecording:(NSString*)filePath -{ - if (isRecordReady) { - - // make sure last movie has stopped - if (isRecording){ - [self stopRecording]; - } - - // set url for recording - [self.captureMovieFileOutput recordToOutputFileURL:[NSURL fileURLWithPath:filePath]]; - - ofLogVerbose("ofQTKitGrabber") << "started recording movie to: \"" << [filePath UTF8String] << "\""; - - isRecording = YES; - - } - else { - ofLogError("ofQTKitGrabber") << "not set up to record, call initRecording() first"; - } -} - -- (void) stopRecording -{ - if (isRecordReady && isRecording){ - - // set url to nil to stop recording - [self.captureMovieFileOutput recordToOutputFileURL:nil]; - - ofLogVerbose("ofQTKitGrabber") << "stopped recording movie"; - - isRecording = NO; - - } - else { - ofLogError("ofQTKitGrabber") << "cannot stop recording, call initRecording() then record() first"; - } -} - -- (void) captureOutput:(QTCaptureFileOutput *)captureOutput -didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL - forConnections:(NSArray *)connections - dueToError:(NSError *)error -{ - - ofVideoSavedEventArgs savedEvent; - savedEvent.grabber = grabber; - savedEvent.videoPath = [[outputFileURL path] UTF8String]; - if(error != nil){ - savedEvent.error = [[error localizedDescription] UTF8String]; - } - ofNotifyEvent(grabber->videoSavedEvent, savedEvent, grabber); -} - -//Frame from the camera -//this tends to be fired on a different thread, so keep the work really minimal and don't perform copies here -//That way if the frames are really big we will appropriately drop frames rather than lagging behind -- (void) outputVideoFrame:(CVImageBufferRef)videoFrame - withSampleBuffer:(QTSampleBuffer *)sampleBuffer - fromConnection:(QTCaptureConnection *)connection -{ - @autoreleasepool { - @synchronized(self){ - if(cvFrame != NULL){ - CVBufferRelease(cvFrame); - } - cvFrame = videoFrame; - CVBufferRetain(cvFrame); - hasNewFrame = YES; - } - } -} - -- (void) update -{ - @synchronized(self){ - if(hasNewFrame){ - if(pixels == NULL){ - ofLogError("ofQTKitGrabber") << "pixels not set on Obj-C Class from C++ wrapper"; - return; - } - - //pixels won't be allocated if we didn't force the video width and height - //allocate upon receving the first frame - if(!pixels->isAllocated()){ - pixels->allocate(CVPixelBufferGetWidth(cvFrame), - CVPixelBufferGetHeight(cvFrame), OF_IMAGE_COLOR); - width = CVPixelBufferGetWidth(cvFrame); - height = CVPixelBufferGetHeight(cvFrame); - } - - CVPixelBufferLockBaseAddress(cvFrame, kCVPixelBufferLock_ReadOnly); -#if( MAC_OS_X_VERSION_10_8 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8) - //fast conversion of BGRA -> RGB introduced in 10.8 - vImage_Buffer src; - src.height = CVPixelBufferGetHeight(cvFrame); - src.width = CVPixelBufferGetWidth(cvFrame); - src.data = CVPixelBufferGetBaseAddress(cvFrame); - src.rowBytes = CVPixelBufferGetBytesPerRow(cvFrame); - - vImage_Buffer dest; - dest.height = height; - dest.width = width; - dest.rowBytes = width*3; - dest.data = pixels->getPixels(); - - vImage_Error err = vImageConvert_BGRA8888toRGB888(&src, &dest, kvImageNoFlags); - if(err != kvImageNoError){ - NSLog(@"[error] ofxQTKitGrabber: update(): pixel copy vImage_error %ld", err); - } -#else - //manually convert BGRA -> RGB - int dstBpp = 3; - int srcBpp = 4; - int dstRowBytes = width*dstBpp; - int srcRowBytes = CVPixelBufferGetBytesPerRow(cvFrame); - for(int y = 0; y < height; y++){ - unsigned char* src = ((unsigned char*)CVPixelBufferGetBaseAddress(cvFrame)) + y*srcRowBytes; - unsigned char* dst = pixels->getPixels() + y*dstRowBytes; - for(int x = 0; x < width; x++){ - dst[0] = src[2]; - dst[1] = src[1]; - dst[2] = src[0]; - dst+=dstBpp; - src+=srcBpp; - } - } -#endif - CVPixelBufferUnlockBaseAddress(cvFrame, kCVPixelBufferLock_ReadOnly); - - hasNewFrame = NO; - isFrameNew = YES; - } - else{ - isFrameNew = NO; - } - } -} - -- (void) stop -{ - if (isRecording){ - [self stopRecording]; - } - if(self.isRunning){ - [self.session stopRunning]; - } - if ([[self.videoDeviceInput device] isOpen]) [[videoDeviceInput device] close]; - if ([[self.audioDeviceInput device] isOpen]) [[audioDeviceInput device] close]; - - //setting NIL releases memory because these properties are synthesized as retain - self.videoDeviceInput = nil; - self.audioDeviceInput = nil; - self.captureMovieFileOutput = nil; - self.session = nil; -} - -- (BOOL) isRunning -{ - return self.session && self.session.isRunning; -} - -- (void) dealloc -{ - if(self.isRunning){ - [self stop]; - } - - if(cvFrame != NULL){ - CVPixelBufferRelease(cvFrame); - cvFrame = NULL; - } - - [super dealloc]; -} - -@end - -//C++ Wrapper class: -ofQTKitGrabber::ofQTKitGrabber(){ - videoDeviceID = 0; - audioDeviceID = 0; - videoCodecIDString = "QTCompressionOptionsJPEGVideo"; // setting default video codec - audioCodecIDString = "QTCompressionOptionsHighQualityAACAudio"; // setting audio video codec - grabber = NULL; - isInited = false; - bUseAudio = false; - bPreview = true; -} - -ofQTKitGrabber::~ofQTKitGrabber(){ - if(isInited){ - close(); - } -} - -void ofQTKitGrabber::setDeviceID(int _videoDeviceID){ - setVideoDeviceID(_videoDeviceID); -} - -void ofQTKitGrabber::setVideoDeviceID(int _videoDeviceID){ - videoDeviceID = _videoDeviceID; - if(isInited){ - @autoreleasepool { - [grabber setVideoDeviceID:videoDeviceID]; - } - } -} - -void ofQTKitGrabber::setAudioDeviceID(int _audioDeviceID){ - audioDeviceID = _audioDeviceID; - if(isInited){ - @autoreleasepool { - [grabber setAudioDeviceID:audioDeviceID]; - } - } -} - -void ofQTKitGrabber::setDeviceID(string _videoDeviceIDString){ - setVideoDeviceID(_videoDeviceIDString); -} - -void ofQTKitGrabber::setVideoDeviceID(string _videoDeviceIDString){ - @autoreleasepool { - // set array filled with devices - NSArray* deviceArray = [[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo] - arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]]; - - // convert device string to NSString - NSString* deviceIDString = [NSString stringWithUTF8String: _videoDeviceIDString.c_str()]; - - // find the index of the device name in the array of devices - videoDeviceID = (NSInteger)[QTKitVideoGrabber getIndexofStringInArray:deviceArray - stringToFind:deviceIDString]; - - if(isInited){ - [grabber setVideoDeviceID:videoDeviceID]; - } - } -} - -void ofQTKitGrabber::setAudioDeviceID(string _audioDeviceIDString){ - @autoreleasepool { - // set array filled with devices - NSArray* deviceArray = [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeSound]; - - // convert device string to NSString - NSString* deviceIDString = [NSString stringWithUTF8String: _audioDeviceIDString.c_str()]; - - // find the index of the device name in the array of devices - audioDeviceID = (NSInteger)[QTKitVideoGrabber getIndexofStringInArray:deviceArray - stringToFind:deviceIDString]; - - if(isInited){ - [grabber setAudioDeviceID:audioDeviceID]; - } - } -} - -bool ofQTKitGrabber::initGrabberWithoutPreview(){ - bPreview = false; - return setup(-1,-1); //supplying -1 allows CoreVideo to choose the dimensions -} - -bool ofQTKitGrabber::setup(int w, int h){ - - if(grabber != NULL){ - close(); - } - - @autoreleasepool { - grabber = [[QTKitVideoGrabber alloc] initWithWidth:w //wxh can be -1 to specify do not force - height:h - videodevice:videoDeviceID - audiodevice:audioDeviceID - usingAudio:bUseAudio - capturePixels:bPreview - pixelsRef:pixels]; - - isInited = (grabber != nil); - if(isInited){ - grabber.grabber = this; //for events - } - } - return isInited; -} - -bool ofQTKitGrabber::initRecording(){ - bool success = false; - if(confirmInit()){ - @autoreleasepool { - NSString * videoCodec = [NSString stringWithUTF8String: videoCodecIDString.c_str()]; - NSString * audioCodec = [NSString stringWithUTF8String: audioCodecIDString.c_str()]; - - success = [grabber initRecording:videoCodec audioCodec:audioCodec]; - } - } - return success; -} - -const vector& ofQTKitGrabber::listVideoCodecs() const{ - @autoreleasepool { - NSArray* videoCodecs = [QTKitVideoGrabber listVideoCodecs]; - videoCodecsVec.clear(); - for (id object in videoCodecs){ - string str = [[object description] UTF8String]; - videoCodecsVec.push_back(str); - } - } - return videoCodecsVec; -} - -const vector& ofQTKitGrabber::listAudioCodecs() const{ - @autoreleasepool { - NSArray* audioCodecs = [QTKitVideoGrabber listAudioCodecs]; - audioCodecsVec.clear(); - for (id object in audioCodecs){ - string str = [[object description] UTF8String]; - audioCodecsVec.push_back(str); - } - } - return audioCodecsVec; -} - -void ofQTKitGrabber::setVideoCodec(string _videoCodec){ - videoCodecIDString = _videoCodec; - if(confirmInit()){ - @autoreleasepool { - NSString * NSvideoCodec = [NSString stringWithUTF8String: videoCodecIDString.c_str()]; - [grabber setVideoCodec:NSvideoCodec]; - } - } -} - -void ofQTKitGrabber::setAudioCodec(string _audioCodec){ - if(confirmInit()){ - audioCodecIDString = _audioCodec; - @autoreleasepool { - NSString * NSaudioCodec = [NSString stringWithUTF8String: audioCodecIDString.c_str()]; - [grabber setAudioCodec:NSaudioCodec]; - } - } -} - -void ofQTKitGrabber::startRecording(string filePath){ - if(confirmInit()){ - @autoreleasepool { - NSString * NSfilePath = [NSString stringWithUTF8String: ofToDataPath(filePath).string().c_str()]; - [grabber startRecording:NSfilePath]; - } - } -} - -void ofQTKitGrabber::stopRecording(){ - if(confirmInit()){ - @autoreleasepool { - [grabber stopRecording]; - } - } -} - -void ofQTKitGrabber::update(){ - if(confirmInit()){ - @autoreleasepool { - [grabber update]; - } - } -} - -bool ofQTKitGrabber::isFrameNew() const { - return isInited && [grabber isFrameNew]; -} - -bool ofQTKitGrabber::isReady() const { - return isInited; -} - -bool ofQTKitGrabber::isInitialized() const{ - return isInited; -} - -bool ofQTKitGrabber::isRecordingReady() const { - return isInited && [grabber isRecordReady]; -} - -bool ofQTKitGrabber::isRecording() const { - return isReady() && [grabber isRecording]; -} - -bool ofQTKitGrabber::hasPreview() const { - return bPreview; -} - -vector ofQTKitGrabber::listDevices() const { - vector devList = listVideoDevices(); - - vector devices; - for(int i = 0; i < devList.size(); i++){ - ofVideoDevice vd; - vd.deviceName = devList[i]; - vd.id = i; - vd.bAvailable = true; - devices.push_back(vd); - } - - return devices; -} - -//--------------------------------------------------------------------------- -bool ofQTKitGrabber::setPixelFormat(ofPixelFormat pixelFormat){ - //note as we only support RGB we are just confirming that this pixel format is supported - if( pixelFormat == OF_PIXELS_RGB ){ - return true; - } - ofLogWarning("ofQTKitGrabber") << "setPixelFormat(): requested pixel format " - << ofToString(pixelFormat) << " not supported"; - return false; -} - -//--------------------------------------------------------------------------- -ofPixelFormat ofQTKitGrabber::getPixelFormat() const{ - //note if you support more than one pixel format you will need to return a ofPixelFormat variable. - return OF_PIXELS_RGB; -} - -//--------------------------------------------------------------------------- -const vector& ofQTKitGrabber::listVideoDevices() const{ - @autoreleasepool { - NSArray* videoDevices = [QTKitVideoGrabber listVideoDevices]; - videoDeviceVec.clear(); - for (id object in videoDevices){ - string str = [[object description] UTF8String]; - videoDeviceVec.push_back(str); - } - } - return videoDeviceVec; -} - -const vector& ofQTKitGrabber::listAudioDevices() const{ - @autoreleasepool { - NSArray* audioDevices = [QTKitVideoGrabber listAudioDevices]; - audioDeviceVec.clear(); - for (id object in audioDevices){ - string str = [[object description] UTF8String]; - audioDeviceVec.push_back(str); - } - } - return audioDeviceVec; -} - -void ofQTKitGrabber::close(){ - if(grabber != NULL){ - @autoreleasepool { - [grabber stop]; - [grabber release]; - grabber = NULL; - isInited = false; - } - } -} - -ofPixels& ofQTKitGrabber::getPixels(){ - if(!confirmInit() || !pixels.isAllocated()){ - ofLogError("ofQTKitGrabber") << "getPixels(): asking for pixels on unitialized grabber"; - } - return pixels; -} - -const ofPixels& ofQTKitGrabber::getPixels() const { - if(!confirmInit() || !pixels.isAllocated()){ - ofLogError("ofQTKitGrabber") << "getPixels(): asking for pixels on unitialized grabber"; - } - return pixels; -} - -void ofQTKitGrabber::setUseAudio(bool _bUseAudio){ - if(_bUseAudio != bUseAudio){ - if(isInited){ - ofLogError("ofQTKitGrabber") << "setUseAudio(): requesting to use audio after grabber is already initialized, try calling setUseAudio() first"; - } - bUseAudio = _bUseAudio; - } -} - -void ofQTKitGrabber::setVerbose(bool bTalkToMe){ - //Now handled by ofLogVerbose() -} - -void ofQTKitGrabber::videoSettings(){ - ofSystemAlertDialog("ofQTKitGrabber: Video Settings is not supported in 10.7+. Please compile against the 10.6 SDK for this feature."); -} - -int ofQTKitGrabber::getDeviceID() const { - return getVideoDeviceID(); -} - -int ofQTKitGrabber::getVideoDeviceID() const { - if(confirmInit()){ - return grabber.videoDeviceID; - } - return -1; -} - -int ofQTKitGrabber::getAudioDeviceID() const { - if(confirmInit()){ - return grabber.audioDeviceID; - } - return -1; -} - -float ofQTKitGrabber::getHeight() const { - if(confirmInit()){ - return float(grabber.height); - } - return 0; -} - -float ofQTKitGrabber::getWidth() const { - if(confirmInit()){ - return float(grabber.width); - } - return 0; -} - -bool ofQTKitGrabber::confirmInit() const { - if(!isInited){ - ofLogError("ofQTKitGrabber") << "confirmInit(): calling method on unintialized video grabber"; - } - return isInited; -} - -void ofQTKitGrabber::setDesiredFrameRate(int framerate){ - ofLogWarning("ofQTKitGrabber") << "setDesiredFrameRate(): cannot set framerate for QTKitGrabber"; -} - -#pragma clang diagnostic pop - -#endif -#endif diff --git a/libs/openFrameworks/video/ofQTKitPlayer.mm b/libs/openFrameworks/video/ofQTKitPlayer.mm deleted file mode 100644 index 864839baa21..00000000000 --- a/libs/openFrameworks/video/ofQTKitPlayer.mm +++ /dev/null @@ -1,465 +0,0 @@ -#if !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 -#ifdef OF_VIDEO_PLAYER_QTKIT - -#include "ofQTKitPlayer.h" - -//-------------------------------------------------------------------- -ofQTKitPlayer::ofQTKitPlayer() { - moviePlayer = NULL; - bNewFrame = false; - bPaused = true; - duration = 0.0f; - speed = 1.0f; - // default this to true so the player update behavior matches ofQuicktimePlayer - bSynchronousSeek = true; - - pixelFormat = OF_PIXELS_RGB; - currentLoopState = OF_LOOP_NORMAL; -} - -//-------------------------------------------------------------------- -ofQTKitPlayer::~ofQTKitPlayer() { - close(); -} - -//-------------------------------------------------------------------- -bool ofQTKitPlayer::load(string path){ - return load(path, OF_QTKIT_DECODE_PIXELS_ONLY); -} - -//-------------------------------------------------------------------- -bool ofQTKitPlayer::load(string movieFilePath, ofQTKitDecodeMode mode) { - if(mode != OF_QTKIT_DECODE_PIXELS_ONLY && mode != OF_QTKIT_DECODE_TEXTURE_ONLY && mode != OF_QTKIT_DECODE_PIXELS_AND_TEXTURE){ - ofLogError("ofQTKitPlayer") << "loadMovie(): unknown ofQTKitDecodeMode mode"; - return false; - } - - if(isLoaded()){ - close(); //auto released - } - - BOOL success = NO; - @autoreleasepool { - decodeMode = mode; - bool useTexture = (mode == OF_QTKIT_DECODE_TEXTURE_ONLY || mode == OF_QTKIT_DECODE_PIXELS_AND_TEXTURE); - bool usePixels = (mode == OF_QTKIT_DECODE_PIXELS_ONLY || mode == OF_QTKIT_DECODE_PIXELS_AND_TEXTURE); - bool useAlpha = (pixelFormat == OF_PIXELS_RGBA); - - bool isURL = false; - - if (movieFilePath.substr(0,7) == "http://" || - movieFilePath.substr(0,8) == "https://" || - movieFilePath.substr(0,7) == "rtsp://") { - isURL = true; - } - else { - movieFilePath = ofToDataPath(movieFilePath, false).string(); - } - - moviePlayer = [[QTKitMovieRenderer alloc] init]; - success = [moviePlayer loadMovie:[NSString stringWithCString:movieFilePath.c_str() encoding:NSUTF8StringEncoding] - pathIsURL:isURL - allowTexture:useTexture - allowPixels:usePixels - allowAlpha:useAlpha]; - - if(success){ - moviePlayer.synchronousSeek = bSynchronousSeek; - reallocatePixels(); - moviePath = movieFilePath; - duration = moviePlayer.duration; - - setLoopState(currentLoopState); - setSpeed(1.0f); - firstFrame(); //will load the first frame - } - else { - ofLogError("ofQTKitPlayer") << "loadMovie(): couldn't load \"" << movieFilePath << "\""; - [moviePlayer release]; - moviePlayer = NULL; - } - } - - return success; -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::closeMovie() { - close(); -} - -//-------------------------------------------------------------------- -bool ofQTKitPlayer::isLoaded() const { - return moviePlayer != NULL; -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::close() { - - if(isLoaded()){ - @autoreleasepool { - [moviePlayer release]; - moviePlayer = NULL; - } - } - - pixels.clear(); - duration = 0; -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::setPaused(bool _bPaused){ - if(!isLoaded()) return; - - bPaused = _bPaused; - - @autoreleasepool { - if (bPaused) { - [moviePlayer setRate:0.0f]; - } else { - [moviePlayer setRate:speed]; - } - } -} - -//-------------------------------------------------------------------- -bool ofQTKitPlayer::isPaused() const { - return bPaused; -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::stop() { - setPaused(true); -} - -//-------------------------------------------------------------------- -bool ofQTKitPlayer::isPlaying() const { - if(!isLoaded()) return false; - - return !moviePlayer.isFinished && !isPaused(); -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::firstFrame(){ - if(!isLoaded()) return; - - @autoreleasepool { - [moviePlayer gotoBeginning]; - bHavePixelsChanged = bNewFrame = bSynchronousSeek; - } -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::nextFrame(){ - if(!isLoaded()) return; - - @autoreleasepool { - [moviePlayer stepForward]; - bHavePixelsChanged = bNewFrame = bSynchronousSeek; - } -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::previousFrame(){ - if(!isLoaded()) return; - - @autoreleasepool { - [moviePlayer stepBackward]; - bHavePixelsChanged = bNewFrame = bSynchronousSeek; - } -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::setSpeed(float rate){ - if(!isLoaded()) return; - - speed = rate; - - if(isPlaying()) { - @autoreleasepool { - [moviePlayer setRate:rate]; - } - } -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::play(){ - if(!isLoaded()) return; - - bPaused = false; - - @autoreleasepool { - [moviePlayer setRate:speed]; - } -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::idleMovie() { - update(); -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::update() { - if(!isLoaded()) return; - - @autoreleasepool { - bNewFrame = [moviePlayer update]; - if (bNewFrame) { - bHavePixelsChanged = true; - } - } -} - -//-------------------------------------------------------------------- -bool ofQTKitPlayer::isFrameNew() const { - return bNewFrame; -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::draw(float x, float y) { - draw(x,y, moviePlayer.movieSize.width, moviePlayer.movieSize.height); -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::draw(float x, float y, float w, float h) { - updateTexture(); - tex.draw(x,y,w,h); -} - -//-------------------------------------------------------------------- -ofPixels& ofQTKitPlayer::getPixels(){ - @autoreleasepool { - if(isLoaded() && moviePlayer.usePixels) { - //don't get the pixels every frame if it hasn't updated - if(bHavePixelsChanged){ - [moviePlayer pixels:pixels.getPixels()]; - bHavePixelsChanged = false; - } - } - else{ - ofLogError("ofQTKitPlayer") << "getPixels(): returning pixels that may be unallocated, make sure to initialize the video player before calling this function"; - } - } - return pixels; -} - -const ofPixels& ofQTKitPlayer::getPixels() const { - return pixels; -} - -//-------------------------------------------------------------------- -ofTexture* ofQTKitPlayer::getTexturePtr() { - ofTexture* texPtr = NULL; - if(moviePlayer.textureAllocated){ - updateTexture(); - return &tex; - } else { - return NULL; - } -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::setPosition(float pct) { - if(!isLoaded()) return; - - @autoreleasepool { - [moviePlayer setPosition:pct]; - } - - bHavePixelsChanged = bNewFrame = bSynchronousSeek; -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::setVolume(float volume) { - if(!isLoaded()) return; - - @autoreleasepool { - [moviePlayer setVolume:volume]; - } -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::setBalance(float balance) { - if(!isLoaded()) return; - - @autoreleasepool { - [moviePlayer setBalance:balance]; - } -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::setFrame(int frame) { - if(!isLoaded()) return; - - frame %= [moviePlayer frameCount]; - - @autoreleasepool { - [moviePlayer setFrame:frame]; - } - - bHavePixelsChanged = bNewFrame = bSynchronousSeek; -} - -//-------------------------------------------------------------------- -int ofQTKitPlayer::getCurrentFrame() const { - if(!isLoaded()) return 0; - return [moviePlayer frame]; -} - -//-------------------------------------------------------------------- -int ofQTKitPlayer::getTotalNumFrames() const { - if(!isLoaded()) return 0; - return [moviePlayer frameCount]; -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::setLoopState(ofLoopType state) { - if(!isLoaded()) return; - - @autoreleasepool { - currentLoopState = state; - - if(state == OF_LOOP_NONE){ - [moviePlayer setLoops:false]; - [moviePlayer setPalindrome:false]; - } - else if(state == OF_LOOP_NORMAL){ - [moviePlayer setLoops:true]; - [moviePlayer setPalindrome:false]; - } - else if(state == OF_LOOP_PALINDROME) { - [moviePlayer setLoops:false]; - [moviePlayer setPalindrome:true]; - } - } -} - -//-------------------------------------------------------------------- -ofLoopType ofQTKitPlayer::getLoopState() const { - if(!isLoaded()) return OF_LOOP_NONE; - - ofLoopType state = OF_LOOP_NONE; - - if(![moviePlayer loops] && ![moviePlayer palindrome]){ - state = OF_LOOP_NONE; - } - else if([moviePlayer loops] && ![moviePlayer palindrome]){ - state = OF_LOOP_NORMAL; - } - else if([moviePlayer loops] && [moviePlayer palindrome]) { - state = OF_LOOP_PALINDROME; - } - else{ - ofLogError("ofQTKitPlayer") << "unknown loop state"; - } - - return state; -} - -//-------------------------------------------------------------------- -float ofQTKitPlayer::getSpeed() const { - return speed; -} - -//-------------------------------------------------------------------- -float ofQTKitPlayer::getDuration() const { - return duration; -} - -//-------------------------------------------------------------------- -float ofQTKitPlayer::getPositionInSeconds() const { - return getPosition() * duration; -} - -//-------------------------------------------------------------------- -float ofQTKitPlayer::getPosition() const { - if(!isLoaded()) return 0; - return [moviePlayer position]; -} - -//-------------------------------------------------------------------- -bool ofQTKitPlayer::getIsMovieDone() const { - if(!isLoaded()) return false; - return [moviePlayer isFinished]; -} - -//-------------------------------------------------------------------- -float ofQTKitPlayer::getWidth() const { - return [moviePlayer movieSize].width; -} - -//-------------------------------------------------------------------- -float ofQTKitPlayer::getHeight() const { - return [moviePlayer movieSize].height; -} - -//-------------------------------------------------------------------- -bool ofQTKitPlayer::setPixelFormat(ofPixelFormat newPixelFormat){ - if(newPixelFormat != OF_PIXELS_RGB && newPixelFormat != OF_PIXELS_RGBA) { - ofLogWarning("ofQTKitPlayer") << "setPixelFormat(): pixel format " - << ofToString(newPixelFormat) << " is not supported"; - return false; - } - - if(newPixelFormat != pixelFormat){ - pixelFormat = newPixelFormat; - // If we already have a movie loaded we need to reload - // the movie with the new settings correctly allocated. - if(isLoaded()){ - load(moviePath, decodeMode); - } - } - return true; -} - -//-------------------------------------------------------------------- -ofPixelFormat ofQTKitPlayer::getPixelFormat() const { - return pixelFormat; -} - -//-------------------------------------------------------------------- -ofQTKitDecodeMode ofQTKitPlayer::getDecodeMode() const { - return decodeMode; -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::setSynchronousSeeking(bool synchronous){ - bSynchronousSeek = synchronous; - if(isLoaded()){ - moviePlayer.synchronousSeek = synchronous; - } -} - -//-------------------------------------------------------------------- -bool ofQTKitPlayer::getSynchronousSeeking() const { - return bSynchronousSeek; -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::reallocatePixels(){ - if(pixelFormat == OF_PIXELS_RGBA){ - pixels.allocate(getWidth(), getHeight(), OF_IMAGE_COLOR_ALPHA); - } else { - pixels.allocate(getWidth(), getHeight(), OF_IMAGE_COLOR); - } -} - -//-------------------------------------------------------------------- -void ofQTKitPlayer::updateTexture(){ - if(moviePlayer.textureAllocated){ - - tex.setUseExternalTextureID(moviePlayer.textureID); - - ofTextureData& data = tex.getTextureData(); - data.textureTarget = moviePlayer.textureTarget; - data.width = getWidth(); - data.height = getHeight(); - data.tex_w = getWidth(); - data.tex_h = getHeight(); - data.tex_t = getWidth(); - data.tex_u = getHeight(); - } -} - -#endif -#endif diff --git a/libs/openFrameworks/video/ofQuickTimePlayer.cpp b/libs/openFrameworks/video/ofQuickTimePlayer.cpp deleted file mode 100644 index dcf41c59ceb..00000000000 --- a/libs/openFrameworks/video/ofQuickTimePlayer.cpp +++ /dev/null @@ -1,887 +0,0 @@ -#include "ofQuickTimePlayer.h" -#include "ofUtils.h" - -#if !defined(TARGET_LINUX) && (!defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12) -#ifdef OF_VIDEO_PLAYER_QUICKTIME - -bool createMovieFromPath(char * path, Movie &movie); -bool createMovieFromPath(char * path, Movie &movie){ - - Boolean isdir = false; - OSErr result = 0; - FSSpec theFSSpec; - - short actualResId = DoTheRightThing; - - #ifdef TARGET_WIN32 - result = NativePathNameToFSSpec (path, &theFSSpec, 0); - if (result != noErr) { - ofLogError("ofQuickTimePlayer") << "createMovieFromPath(): couldn't load movie, NativePathNameToFSSpec failed: OSErr " << result; - return false; - } - - #endif - - #ifdef TARGET_OSX - FSRef fsref; - result = FSPathMakeRef((const UInt8*)path, &fsref, &isdir); - if (result) { - ofLogError("ofQuickTimePlayer") << "createMovieFromPath(): couldn't load movie, FSPathMakeRef failed: OSErr " << result; - return false; - } - result = FSGetCatalogInfo(&fsref, kFSCatInfoNone, nullptr, nullptr, &theFSSpec, nullptr); - if (result) { - ofLogError("ofQuickTimePlayer") << "createMovieFromPath(): couldn't load movie, FSGetCatalogInfo failed: OSErr ", result; - return false; - } - #endif - - short movieResFile; - result = OpenMovieFile (&theFSSpec, &movieResFile, fsRdPerm); - if (result == noErr) { - - short movieResID = 0; - result = NewMovieFromFile(&movie, movieResFile, &movieResID, (unsigned char *) 0, newMovieActive, (Boolean *) 0); - if (result == noErr){ - CloseMovieFile (movieResFile); - } else { - ofLogError("ofQuickTimePlayer") << "createMovieFromPath(): couldn't load movie, NewMovieFromFile failed: OSErr " << result; - return false; - } - } else { - ofLogError("ofQuickTimePlayer") << "createMovieFromPath(): couldn't load movie, OpenMovieFile failed: OSErr " << result; - return false; - } - - return true; -} - -//-------------------------------------------------------------- -bool createMovieFromURL(string urlIn, Movie &movie){ - char * url = (char *)urlIn.c_str(); - Handle urlDataRef; - - OSErr err; - - urlDataRef = NewHandle(strlen(url) + 1); - if ( ( err = MemError()) != noErr){ - ofLogError("ofQuickTimePlayer") << "createMovieFromURL(): couldn't create url handle from \"" << urlIn << "\": OSErr " << err; - return false; - } - - BlockMoveData(url, *urlDataRef, strlen(url) + 1); - - err = NewMovieFromDataRef(&movie, newMovieActive,nil, urlDataRef, URLDataHandlerSubType); - DisposeHandle(urlDataRef); - - if(err != noErr){ - ofLogError("ofQuickTimePlayer") << "createMovieFromURL(): couldn't load url \"" << urlIn << "\": OSErr " << err; - return false; - }else{ - return true; - } - - return false; -} - - -//-------------------------------------------------------------- -OSErr DrawCompleteProc(Movie theMovie, long refCon); -OSErr DrawCompleteProc(Movie theMovie, long refCon){ - - ofQuickTimePlayer * ofvp = (ofQuickTimePlayer *)refCon; - - #if defined(TARGET_OSX) && defined(__BIG_ENDIAN__) - convertPixels(ofvp->offscreenGWorldPixels, ofvp->pixels.getPixels(), ofvp->width, ofvp->height); - #endif - - ofvp->bHavePixelsChanged = true; - return noErr; -} - -//--------------------------------------------------------------------------- -ofQuickTimePlayer::ofQuickTimePlayer (){ - - //-------------------------------------------------------------- - #if defined(TARGET_WIN32) || defined(TARGET_OSX) - //-------------------------------------------------------------- - moviePtr = nullptr; - allocated = false; - offscreenGWorld = nullptr; - //-------------------------------------------------------------- - #endif - //-------------------------------------------------------------- - - bLoaded = false; - width = 0; - height = 0; - speed = 1; - bStarted = false; - nFrames = 0; - bPaused = true; - currentLoopState = OF_LOOP_NORMAL; -} - - -//--------------------------------------------------------------------------- -ofQuickTimePlayer::~ofQuickTimePlayer(){ - - closeMovie(); - clearMemory(); - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - if(allocated) delete[] offscreenGWorldPixels; - if ((offscreenGWorld)) DisposeGWorld((offscreenGWorld)); - //-------------------------------------- - #endif - //-------------------------------------- - -} - -//--------------------------------------------------------------------------- -ofPixels& ofQuickTimePlayer::getPixels(){ - return pixels; -} - -//--------------------------------------------------------------------------- -const ofPixels& ofQuickTimePlayer::getPixels() const { - return pixels; -} - -//--------------------------------------------------------------------------- -void ofQuickTimePlayer::update(){ - - if (bLoaded == true){ - - //-------------------------------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------------------------------- - - // is this necessary on windows with quicktime? - #ifdef TARGET_OSX - // call MoviesTask if we're not on the main thread - if ( CFRunLoopGetCurrent() != CFRunLoopGetMain() ) - { - //ofLog( OF_LOG_NOTICE, "not on the main loop, calling MoviesTask") ; - MoviesTask(moviePtr,0); - } - #else - // on windows we always call MoviesTask - MoviesTask(moviePtr,0); - #endif - - //-------------------------------------------------------------- - #endif - //-------------------------------------------------------------- - } - - // --------------------------------------------------- - // on all platforms, - // do "new"ness ever time we idle... - // before "isFrameNew" was clearning, - // people had issues with that... - // and it was badly named so now, newness happens - // per-idle not per isNew call - // --------------------------------------------------- - - if (bLoaded == true){ - - bIsFrameNew = bHavePixelsChanged; - if (bHavePixelsChanged == true) { - bHavePixelsChanged = false; - } - } - -} - -//--------------------------------------------------------------------------- -bool ofQuickTimePlayer::isFrameNew() const{ - return bIsFrameNew; -} -//--------------------------------------------------------------------------- -void ofQuickTimePlayer::close(){ - closeMovie(); -} - -//--------------------------------------------------------------------------- -void ofQuickTimePlayer::closeMovie(){ - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - if (bLoaded == true){ - - DisposeMovie (moviePtr); - DisposeMovieDrawingCompleteUPP(myDrawCompleteProc); - - moviePtr = nullptr; - - } - - //-------------------------------------- - #endif - //-------------------------------------- - - bLoaded = false; - -} - - -//-------------------------------------- -#ifdef OF_VIDEO_PLAYER_QUICKTIME -//-------------------------------------- - -void ofQuickTimePlayer::createImgMemAndGWorld(){ - Rect movieRect; - movieRect.top = 0; - movieRect.left = 0; - movieRect.bottom = height; - movieRect.right = width; - offscreenGWorldPixels = new unsigned char[4 * width * height + 32]; - allocated = true; - pixels.allocate(width,height,OF_IMAGE_COLOR); - - #if defined(TARGET_OSX) && defined(__BIG_ENDIAN__) - QTNewGWorldFromPtr (&(offscreenGWorld), k32ARGBPixelFormat, &(movieRect), nullptr, nullptr, 0, (offscreenGWorldPixels), 4 * width); - #else - QTNewGWorldFromPtr (&(offscreenGWorld), k24RGBPixelFormat, &(movieRect), nullptr, nullptr, 0, (pixels.getPixels()), 3 * width); - #endif - - LockPixels(GetGWorldPixMap(offscreenGWorld)); - - // from : https://github.com/openframeworks/openFrameworks/issues/244 - // SetGWorld do not seems to be necessary for offscreen rendering of the movie - // only SetMovieGWorld should be called - // if both are called, the app will crash after a few ofVideoPlayer object have been deleted - - #ifndef TARGET_WIN32 - SetGWorld (offscreenGWorld, nullptr); - #endif - SetMovieGWorld (moviePtr, offscreenGWorld, nil); - -} - -//-------------------------------------- -#endif -//-------------------------------------- - - -//--------------------------------------------------------------------------- -bool ofQuickTimePlayer::load(string name){ - - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - initializeQuicktime(); // init quicktime - closeMovie(); // if we have a movie open, close it - bLoaded = false; // try to load now - - - // from : https://github.com/openframeworks/openFrameworks/issues/244 - // http://developer.apple.com/library/mac/#documentation/QuickTime/RM/QTforWindows/QTforWindows/C-Chapter/3BuildingQuickTimeCa.html - // Apple's documentation *seems* to state that a Gworld should have been set prior to calling NewMovieFromFile - // So I set a dummy Gworld (1x1 pixel) before calling createMovieFromPath - // it avoids crash at the creation of objet ofVideoPlayer after a previous ofVideoPlayer have been deleted - - #ifdef TARGET_WIN32 - if (width != 0 && height != 0){ - pixels.clear(); - delete [] offscreenGWorldPixels; - } - width = 1; - height = 1; - createImgMemAndGWorld(); - #endif - - - if( name.substr(0, 7) == "http://" || name.substr(0,7) == "rtsp://" ){ - if(! createMovieFromURL(name, moviePtr) ) return false; - }else{ - name = ofToDataPath(name).string(); - if( !createMovieFromPath((char *)name.c_str(), moviePtr) ) return false; - } - - bool bDoWeAlreadyHaveAGworld = false; - if (width != 0 && height != 0){ - bDoWeAlreadyHaveAGworld = true; - } - Rect movieRect; - GetMovieBox(moviePtr, &(movieRect)); - if (bDoWeAlreadyHaveAGworld){ - // is the gworld the same size, then lets *not* de-allocate and reallocate: - if (width == movieRect.right && - height == movieRect.bottom){ - SetMovieGWorld (moviePtr, offscreenGWorld, nil); - } else { - width = movieRect.right; - height = movieRect.bottom; - pixels.clear(); - delete [] offscreenGWorldPixels; - if ((offscreenGWorld)) DisposeGWorld((offscreenGWorld)); - createImgMemAndGWorld(); - } - } else { - width = movieRect.right; - height = movieRect.bottom; - createImgMemAndGWorld(); - } - - if (moviePtr == nullptr){ - return false; - } - - //----------------- callback method - myDrawCompleteProc = NewMovieDrawingCompleteUPP (DrawCompleteProc); - SetMovieDrawingCompleteProc (moviePtr, movieDrawingCallWhenChanged, myDrawCompleteProc, (long)this); - - // ------------- get the total # of frames: - nFrames = 0; - TimeValue curMovieTime; - curMovieTime = 0; - TimeValue duration; - - //OSType whichMediaType = VIDEO_TYPE; // mingw chokes on this - OSType whichMediaType = FOUR_CHAR_CODE('vide'); - - short flags = nextTimeMediaSample + nextTimeEdgeOK; - - while( curMovieTime >= 0 ) { - nFrames++; - GetMovieNextInterestingTime(moviePtr,flags,1,&whichMediaType,curMovieTime,0,&curMovieTime,&duration); - flags = nextTimeMediaSample; - } - nFrames--; // there's an extra time step at the end of themovie - - - - - // ------------- get some pixels in there ------ - GoToBeginningOfMovie(moviePtr); - SetMovieActiveSegment(moviePtr, -1,-1); - MoviesTask(moviePtr,0); - - #if defined(TARGET_OSX) && defined(__BIG_ENDIAN__) - convertPixels(offscreenGWorldPixels, pixels.getPixels(), width, height); - #endif - - bStarted = false; - bLoaded = true; - bPlaying = false; - bHavePixelsChanged = false; - speed = 1; - - return true; - - //-------------------------------------- - #endif - //-------------------------------------- - - - -} - - - -//-------------------------------------------------------- -void ofQuickTimePlayer::start(){ - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - if (bLoaded == true && bStarted == false){ - SetMovieActive(moviePtr, true); - - //------------------ set the movie rate to default - //------------------ and preroll, so the first frames come correct - - TimeValue timeNow = GetMovieTime(moviePtr, 0); - Fixed playRate = GetMoviePreferredRate(moviePtr); //Not being used! - - PrerollMovie(moviePtr, timeNow, X2Fix(speed)); - SetMovieRate(moviePtr, X2Fix(speed)); - setLoopState(currentLoopState); - - // get some pixels in there right away: - MoviesTask(moviePtr,0); - #if defined(TARGET_OSX) && defined(__BIG_ENDIAN__) - convertPixels(offscreenGWorldPixels, pixels.getPixels(), width, height); - #endif - bHavePixelsChanged = true; - - bStarted = true; - bPlaying = true; - } - - //-------------------------------------- - #endif - //-------------------------------------- -} - -//-------------------------------------------------------- -void ofQuickTimePlayer::play(){ - if( !isLoaded() ){ - ofLogError("ofQuickTimePlayer") << "play(): movie not loaded"; - return; - } - - bPlaying = true; - bPaused = false; - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - if (!bStarted){ - start(); - }else { - // ------------ lower level "startMovie" - // ------------ use desired speed & time (-1,1,etc) to Preroll... - TimeValue timeNow; - timeNow = GetMovieTime(moviePtr, nil); - PrerollMovie(moviePtr, timeNow, X2Fix(speed)); - SetMovieRate(moviePtr, X2Fix(speed)); - MoviesTask(moviePtr, 0); - } - - //-------------------------------------- - #endif - //-------------------------------------- - - //this is if we set the speed first but it only can be set when we are playing. - setSpeed(speed); - -} - -//-------------------------------------------------------- -void ofQuickTimePlayer::stop(){ - if( !isLoaded() ){ - ofLogError("ofQuickTimePlayer") << "stop(): movie not loaded"; - return; - } - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - StopMovie (moviePtr); - SetMovieActive (moviePtr, false); - bStarted = false; - - //-------------------------------------- - #endif - //-------------------------------------- - - bPlaying = false; -} - -//-------------------------------------------------------- -void ofQuickTimePlayer::setVolume(float volume){ - if( !isLoaded() ){ - ofLogError("ofQuickTimePlayer") << "setVolume(): movie not loaded"; - return; - } - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - SetMovieVolume(moviePtr, volume*255); - - //-------------------------------------- - #endif - //-------------------------------------- - -} - - -//-------------------------------------------------------- -void ofQuickTimePlayer::setLoopState(ofLoopType state){ - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - if( isLoaded() ){ - - TimeBase myTimeBase; - long myFlags = 0L; - myTimeBase = GetMovieTimeBase(moviePtr); - myFlags = GetTimeBaseFlags(myTimeBase); - switch (state) { - case OF_LOOP_NORMAL: - myFlags |= loopTimeBase; - myFlags &= ~palindromeLoopTimeBase; - SetMoviePlayHints(moviePtr, hintsLoop, hintsLoop); - SetMoviePlayHints(moviePtr, 0L, hintsPalindrome); - break; - case OF_LOOP_PALINDROME: - myFlags |= loopTimeBase; - myFlags |= palindromeLoopTimeBase; - SetMoviePlayHints(moviePtr, hintsLoop, hintsLoop); - SetMoviePlayHints(moviePtr, hintsPalindrome, hintsPalindrome); - break; - case OF_LOOP_NONE: - default: - myFlags &= ~loopTimeBase; - myFlags &= ~palindromeLoopTimeBase; - SetMoviePlayHints(moviePtr, 0L, hintsLoop | - hintsPalindrome); - break; - } - SetTimeBaseFlags(myTimeBase, myFlags); - - } - - //-------------------------------------- - #endif - //-------------------------------------- - - //store the current loop state; - currentLoopState = state; - -} - -//--------------------------------------------------------------------------- -ofLoopType ofQuickTimePlayer::getLoopState() const{ - return currentLoopState; -} - -//--------------------------------------------------------------------------- -void ofQuickTimePlayer::setPosition(float pct){ - if( !isLoaded() ){ - ofLogError("ofQuickTimePlayer") << "setPosition(): movie not loaded"; - return; - } - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - TimeRecord tr; - tr.base = GetMovieTimeBase(moviePtr); - long total = GetMovieDuration(moviePtr ); - long newPos = (long)((float)total * pct); - SetMovieTimeValue(moviePtr, newPos); - MoviesTask(moviePtr,0); - - //-------------------------------------- - #endif - //-------------------------------------- - - -} - -//--------------------------------------------------------------------------- -void ofQuickTimePlayer::setFrame(int frame){ - if( !isLoaded() ){ - ofLogError("ofQuickTimePlayer") << "setFrame(): movie not loaded"; - return; - } - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - // frame 0 = first frame... - - // this is the simple way... - //float durationPerFrame = getDuration() / getTotalNumFrames(); - - // seems that freezing, doing this and unfreezing seems to work alot - // better then just SetMovieTimeValue() ; - - if (!bPaused) SetMovieRate(moviePtr, X2Fix(0)); - - // this is better with mpeg, etc: - double frameRate = 0; - double movieTimeScale = 0; - MovieGetStaticFrameRate(moviePtr, &frameRate); - movieTimeScale = GetMovieTimeScale(moviePtr); - - if (frameRate > 0){ - double frameDuration = 1 / frameRate; - TimeValue t = (TimeValue)(frame * frameDuration * movieTimeScale); - SetMovieTimeValue(moviePtr, t); - MoviesTask(moviePtr, 0); - } - - if (!bPaused) SetMovieRate(moviePtr, X2Fix(speed)); - - //-------------------------------------- - #endif - //-------------------------------------- - -} - - -//--------------------------------------------------------------------------- -float ofQuickTimePlayer::getDuration() const{ - if( !isLoaded() ){ - ofLogError("ofQuickTimePlayer") << "getDuration(): movie not loaded"; - return 0.0; - } - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - return (float) (GetMovieDuration (moviePtr) / (double) GetMovieTimeScale (moviePtr)); - - //-------------------------------------- - #endif - //-------------------------------------- - -} - -//--------------------------------------------------------------------------- -float ofQuickTimePlayer::getPosition() const{ - if( !isLoaded() ){ - ofLogError("ofQuickTimePlayer") << "getPosition(): movie not loaded"; - return 0.0; - } - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - long total = GetMovieDuration(moviePtr); - long current = GetMovieTime(moviePtr, nil); - float pct = ((float)current/(float)total); - return pct; - - //-------------------------------------- - #endif - //-------------------------------------- - - -} - -//--------------------------------------------------------------------------- -int ofQuickTimePlayer::getCurrentFrame() const{ - if( !isLoaded() ){ - ofLogError("ofQuickTimePlayer") << "getCurrentFrame(): movie not loaded"; - return 0; - } - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - int frame = 0; - - // zach I think this may fail on variable length frames... - float pos = getPosition(); - - float framePosInFloat = ((float)getTotalNumFrames() * pos); - int framePosInInt = (int)framePosInFloat; - float floatRemainder = (framePosInFloat - framePosInInt); - if (floatRemainder > 0.5f) framePosInInt = framePosInInt + 1; - //frame = (int)ceil((getTotalNumFrames() * getPosition())); - frame = framePosInInt; - - return frame; - - //-------------------------------------- - #endif - //-------------------------------------- - -} - -//--------------------------------------------------------------------------- -bool ofQuickTimePlayer::setPixelFormat(ofPixelFormat pixelFormat){ - //note as we only support RGB we are just confirming that this pixel format is supported - if( pixelFormat == OF_PIXELS_RGB ){ - return true; - } - ofLogWarning("ofQuickTimePlayer") << "setPixelFormat(): requested pixel format " << pixelFormat << " not supported, expecting OF_PIXELS_RGB"; - return false; -} - -//--------------------------------------------------------------------------- -ofPixelFormat ofQuickTimePlayer::getPixelFormat() const{ - //note if you support more than one pixel format you will need to return a ofPixelFormat variable. - return OF_PIXELS_RGB; -} - - -//--------------------------------------------------------------------------- -bool ofQuickTimePlayer::getIsMovieDone() const{ - if( !isLoaded() ){ - ofLogError("ofQuickTimePlayer") << "getIsMovieDone(): movie not loaded"; - return false; - } - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - bool bIsMovieDone = (bool)IsMovieDone(moviePtr); - return bIsMovieDone; - - //-------------------------------------- - #endif - //-------------------------------------- - -} - -//--------------------------------------------------------------------------- -void ofQuickTimePlayer::firstFrame(){ - if( !isLoaded() ){ - ofLogError("ofQuickTimePlayer") << "firstFrame(): movie not loaded"; - return; - } - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - setFrame(0); - - //-------------------------------------- - #endif - //-------------------------------------- - -} - -//--------------------------------------------------------------------------- -void ofQuickTimePlayer::nextFrame(){ - if( !isLoaded() ){ - ofLogError("ofQuickTimePlayer") << "nextFrame(): movie not loaded"; - return; - } - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - setFrame(getCurrentFrame() + 1); - - //-------------------------------------- - #endif - //-------------------------------------- -} - -//--------------------------------------------------------------------------- -void ofQuickTimePlayer::previousFrame(){ - if( !isLoaded() ){ - ofLogError("ofQuickTimePlayer") << "previousFrame(): movie not loaded"; - return; - } - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - setFrame(getCurrentFrame() - 1); - - //-------------------------------------- - #endif - //-------------------------------------- -} - - - -//--------------------------------------------------------------------------- -void ofQuickTimePlayer::setSpeed(float _speed){ - - speed = _speed; - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - if (bPlaying == true){ - //setMovieRate actually plays, so let's call it only when we are playing - SetMovieRate(moviePtr, X2Fix(speed)); - } - - //-------------------------------------- - #endif - //-------------------------------------- -} - -//--------------------------------------------------------------------------- -void ofQuickTimePlayer::setPaused(bool _bPause){ - - bPaused = _bPause; - - //-------------------------------------- - #ifdef OF_VIDEO_PLAYER_QUICKTIME - //-------------------------------------- - - // there might be a more "quicktime-ish" way (or smarter way) - // to do this for now, to pause, just set the movie's speed to zero, - // on un-pause, set the movie's speed to "speed" - // (and hope that speed != 0...) - if (bPlaying == true){ - if (bPaused == true) SetMovieRate(moviePtr, X2Fix(0)); - else SetMovieRate(moviePtr, X2Fix(speed)); - } - - //-------------------------------------- - #endif - //-------------------------------------- - -} - - - - - - - - - -//--------------------------------------------------------------------------- -void ofQuickTimePlayer::clearMemory(){ - - pixels.clear(); - -} - -//--------------------------------------------------------------------------- -float ofQuickTimePlayer::getSpeed() const{ - return speed; -} - -//------------------------------------ -int ofQuickTimePlayer::getTotalNumFrames() const{ - return nFrames; -} - -//---------------------------------------------------------- -float ofQuickTimePlayer::getWidth() const{ - return (float)width; -} - -//---------------------------------------------------------- -float ofQuickTimePlayer::getHeight() const{ - return (float)height; -} - -//---------------------------------------------------------- -bool ofQuickTimePlayer::isPaused() const{ - return bPaused; -} - -//---------------------------------------------------------- -bool ofQuickTimePlayer::isLoaded() const{ - return bLoaded; -} - -//---------------------------------------------------------- -bool ofQuickTimePlayer::isPlaying() const{ - return bPlaying; -} - -#endif - -#endif - - From b386f80a6b58fb4e9861a319f31d04eed9d8dfd9 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 12 Feb 2023 13:08:07 -0300 Subject: [PATCH 68/91] assimp --- addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index 6df5aafd99c..b3bcd3bb4c2 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -80,7 +80,7 @@ bool ofxAssimpModelLoader::load(string modelName, int assimpOptimizeFlags){ // } // loads scene from file - std::string path = file.getAbsolutePath(); + std::string path = file.getAbsolutePath().string(); const aiScene * scenePtr = importer.ReadFile(path.c_str(), flags); //this is funky but the scenePtr is managed by assimp and so we can't put it in our shared_ptr without disabling the deleter with: [](const aiScene*){} From d647ccf49254cda12c6e3382a07659cb9d25ef73 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 12 Feb 2023 13:37:48 -0300 Subject: [PATCH 69/91] update filesystem::path --- .../src/ofxAssimpModelLoader.cpp | 14 ++++++++------ .../src/ofxAssimpModelLoader.h | 7 ++++++- .../ofxAssimpModelLoader/src/ofxAssimpTexture.cpp | 6 +++--- addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h | 7 ++++--- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index b3bcd3bb4c2..00e9c27627a 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -388,10 +388,12 @@ void ofxAssimpModelLoader::loadGLResources(){ auto ogPath = texPathStr; bool bHasEmbeddedTexture = false; - string modelFolder = ofFilePath::getEnclosingDirectory( file.path() ); - string relTexPath = ofFilePath::getEnclosingDirectory(texPathStr,false); + // FIXME: Convert everything possible to fs. remove .string() in the end + auto modelFolder = ofFilePath::getEnclosingDirectory( file.path() ); + auto relTexPath = ofFilePath::getEnclosingDirectory(texPathStr,false); string texFile = ofFilePath::getFileName(texPathStr); - string realPath = ofFilePath::join(ofFilePath::join(modelFolder, relTexPath), texFile); + + auto realPath = modelFolder / relTexPath; #ifndef TARGET_LINUX_ARM if(bTryEmbed || ofFile::doesFileExist(realPath) == false) { @@ -401,7 +403,7 @@ void ofxAssimpModelLoader::loadGLResources(){ ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource() texture " << texFile << " is embedded "; }else{ ofLogError("ofxAssimpModelLoader") << "loadGLResource(): texture doesn't exist: \"" - << file.getFileName() + "\" in \"" << realPath << "\""; + << file.getFileName() + "\" in \"" << realPath.string() << "\""; } } #endif @@ -419,7 +421,7 @@ void ofxAssimpModelLoader::loadGLResources(){ meshHelper.addTexture(assimpTexture); ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource(): texture already loaded: \"" - << file.getFileName() + "\" from \"" << realPath << "\"" << " adding texture as " << assimpTexture.getTextureTypeAsString() ; + << file.getFileName() + "\" from \"" << realPath.string() << "\"" << " adding texture as " << assimpTexture.getTextureTypeAsString() ; } else { shared_ptr texture = std::make_shared(); @@ -463,7 +465,7 @@ void ofxAssimpModelLoader::loadGLResources(){ ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource(): texture " << tmpTex.getTextureTypeAsString() << " loaded, dimensions: " << texture->getWidth() << "x" << texture->getHeight(); }else{ ofLogError("ofxAssimpModelLoader") << "loadGLResource(): couldn't load texture: \"" - << file.getFileName() + "\" from \"" << realPath << "\""; + << file.getFileName() + "\" from \"" << realPath.string() << "\""; } } } diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h index 37f34847adf..9c4ff2af3bf 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h @@ -19,6 +19,7 @@ #include "ofxAssimpTexture.h" #include "ofMesh.h" #include "ofMath.h" +#include "ofConstants.h" #include @@ -177,7 +178,11 @@ class ofxAssimpModelLoader{ glm::mat4 modelMatrix; std::vector lights; - std::map> textures; + // std::map> textures; + std::map< + of::filesystem::path, + std::shared_ptr + > textures; std::vector modelMeshes; std::vector animations; int currentAnimation; // DEPRECATED - to be removed with deprecated animation functions. diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp index 676b92f72f2..939cbfffca9 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp @@ -6,10 +6,10 @@ // #include "ofxAssimpTexture.h" -#include "ofConstants.h" +//#include "ofConstants.h" #include "ofLog.h" -void ofxAssimpTexture::setup(const ofTexture & texture, std::string texturePath, bool bTexRepeat) { +void ofxAssimpTexture::setup(const ofTexture & texture, const of::filesystem::path & texturePath, bool bTexRepeat) { this->texture = texture; if( bTexRepeat ){ this->texture.setTextureWrap(GL_REPEAT, GL_REPEAT); @@ -43,7 +43,7 @@ ofTexture & ofxAssimpTexture::getTextureRef() { return texture; } -std::string ofxAssimpTexture::getTexturePath() { +of::filesystem::path ofxAssimpTexture::getTexturePath() { return texturePath; } diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h b/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h index 0c215481abc..1a4de95fa13 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h @@ -9,15 +9,16 @@ #include "ofTexture.h" #include +#include "ofConstants.h" class ofxAssimpTexture { public: - void setup(const ofTexture & texture, std::string texturePath, bool bTexRepeat = true); + void setup(const ofTexture & texture, const of::filesystem::path & texturePath, bool bTexRepeat = true); ofTexture & getTextureRef(); - std::string getTexturePath(); + of::filesystem::path getTexturePath(); bool hasTexture(); void setTextureType(aiTextureType aTexType); @@ -27,7 +28,7 @@ class ofxAssimpTexture { private: ofTexture texture; - std::string texturePath; + of::filesystem::path texturePath; aiTextureType textureType; std::string mTexTypeStr; }; From 2b04fe7838bad2841a1ceb9c3d76ea2dd912eec2 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 12 Feb 2023 14:19:22 -0300 Subject: [PATCH 70/91] fix assimp textures load, still needs some cleanup --- .../src/ofxAssimpModelLoader.cpp | 21 ++++++++++++++++++- libs/openFrameworks/utils/ofFileUtils.h | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index 00e9c27627a..b8815a09656 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -373,6 +373,7 @@ void ofxAssimpModelLoader::loadGLResources(){ std::string texPathStr = texPath.C_Str(); +// std::cout << "first texPathStr: " << texPathStr << std::endl; //deal with Blender putting "//" in front of local file paths if( texPathStr.size() > 2 && texPathStr.substr(0, 2) == "//" ){ texPathStr = texPathStr.substr(2, texPathStr.size()-2); @@ -391,9 +392,27 @@ void ofxAssimpModelLoader::loadGLResources(){ // FIXME: Convert everything possible to fs. remove .string() in the end auto modelFolder = ofFilePath::getEnclosingDirectory( file.path() ); auto relTexPath = ofFilePath::getEnclosingDirectory(texPathStr,false); + string texFile = ofFilePath::getFileName(texPathStr); - auto realPath = modelFolder / relTexPath; + auto realPath = modelFolder / of::filesystem::path{ texPathStr }; + + using std::cout; + using std::endl; + cout << "modelFolder : " << modelFolder << endl; + cout << "texPathStr : " << texPathStr << endl; + cout << "texFile : " << texFile << endl; + cout << "relTexPath : " << relTexPath.string() << endl; + cout << "realPath : " << realPath.string() << endl; + + +// modelFolder : "../MacOS/../../../data/FlightHelmet/" +// texPathStr : FlightHelmet_Materials_LeatherPartsMat_Normal.png +// texFile : FlightHelmet_Materials_LeatherPartsMat_Normal.png +// relTexPath : +// realPath : ../MacOS/../../../data/FlightHelmet/ + + #ifndef TARGET_LINUX_ARM if(bTryEmbed || ofFile::doesFileExist(realPath) == false) { diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index be99d316a9d..cbdf245f527 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -357,6 +357,8 @@ class ofFilePath{ /// are *not* in the data folder and want the direct path without relative /// "../../" /// \returns filename + /// + // FIXME: Deprecate / Remove this. static std::string getFileName(const of::filesystem::path& filePath, bool bRelativeToData = true); /// Get a file name without its extension, From 464f9fb18f6cb610c8a7e680954c8d80ebc9e6d5 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 12 Feb 2023 15:17:50 -0300 Subject: [PATCH 71/91] update --- addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index b8815a09656..b7c140d1896 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -392,23 +392,18 @@ void ofxAssimpModelLoader::loadGLResources(){ // FIXME: Convert everything possible to fs. remove .string() in the end auto modelFolder = ofFilePath::getEnclosingDirectory( file.path() ); auto relTexPath = ofFilePath::getEnclosingDirectory(texPathStr,false); - - string texFile = ofFilePath::getFileName(texPathStr); - auto realPath = modelFolder / of::filesystem::path{ texPathStr }; using std::cout; using std::endl; cout << "modelFolder : " << modelFolder << endl; cout << "texPathStr : " << texPathStr << endl; - cout << "texFile : " << texFile << endl; cout << "relTexPath : " << relTexPath.string() << endl; cout << "realPath : " << realPath.string() << endl; // modelFolder : "../MacOS/../../../data/FlightHelmet/" // texPathStr : FlightHelmet_Materials_LeatherPartsMat_Normal.png -// texFile : FlightHelmet_Materials_LeatherPartsMat_Normal.png // relTexPath : // realPath : ../MacOS/../../../data/FlightHelmet/ @@ -419,7 +414,7 @@ void ofxAssimpModelLoader::loadGLResources(){ auto embeddedTexture = scene->GetEmbeddedTexture(ogPath.c_str()); if( embeddedTexture ){ bHasEmbeddedTexture = true; - ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource() texture " << texFile << " is embedded "; + ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource() texture " << realPath.filename() << " is embedded "; }else{ ofLogError("ofxAssimpModelLoader") << "loadGLResource(): texture doesn't exist: \"" << file.getFileName() + "\" in \"" << realPath.string() << "\""; From a5f428509824921e12189cc0b0d14be6d62f239d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 17 Feb 2023 15:39:48 -0300 Subject: [PATCH 72/91] updates --- addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h | 1 - .../ofxThreadedImageLoader/src/ofxThreadedImageLoader.cpp | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h b/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h index 1a4de95fa13..f4c0539b344 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h @@ -9,7 +9,6 @@ #include "ofTexture.h" #include -#include "ofConstants.h" class ofxAssimpTexture { diff --git a/addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.cpp b/addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.cpp index a37675ca3e3..055951665a9 100644 --- a/addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.cpp +++ b/addons/ofxThreadedImageLoader/src/ofxThreadedImageLoader.cpp @@ -1,8 +1,5 @@ #include "ofxThreadedImageLoader.h" #include - -using std::string; - ofxThreadedImageLoader::ofxThreadedImageLoader(){ nextID = 0; ofAddListener(ofEvents().update, this, &ofxThreadedImageLoader::update); @@ -22,7 +19,7 @@ ofxThreadedImageLoader::~ofxThreadedImageLoader(){ // Load an image from disk. //-------------------------------------------------------------- -void ofxThreadedImageLoader::loadFromDisk(ofImage& image, string filename) { +void ofxThreadedImageLoader::loadFromDisk(ofImage& image, std::string filename) { nextID++; ofImageLoaderEntry entry(image); entry.filename = filename; @@ -35,7 +32,7 @@ void ofxThreadedImageLoader::loadFromDisk(ofImage& image, string filename) { // Load an url asynchronously from an url. //-------------------------------------------------------------- -void ofxThreadedImageLoader::loadFromURL(ofImage& image, string url) { +void ofxThreadedImageLoader::loadFromURL(ofImage& image, std::string url) { nextID++; ofImageLoaderEntry entry(image); entry.url = url; From 74ac3c0c665a65134a6882bd04a970d98786dc02 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 17 Feb 2023 15:41:09 -0300 Subject: [PATCH 73/91] remove constants --- addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp index 939cbfffca9..a733444bec7 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp @@ -6,7 +6,6 @@ // #include "ofxAssimpTexture.h" -//#include "ofConstants.h" #include "ofLog.h" void ofxAssimpTexture::setup(const ofTexture & texture, const of::filesystem::path & texturePath, bool bTexRepeat) { From a27999929fb0b54d79c78dbb8bda646dc8f9726f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 17 Feb 2023 16:23:30 -0300 Subject: [PATCH 74/91] comment cleanup --- .../src/ofxAssimpModelLoader.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index b7c140d1896..f561977de0e 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -389,25 +389,10 @@ void ofxAssimpModelLoader::loadGLResources(){ auto ogPath = texPathStr; bool bHasEmbeddedTexture = false; - // FIXME: Convert everything possible to fs. remove .string() in the end auto modelFolder = ofFilePath::getEnclosingDirectory( file.path() ); auto relTexPath = ofFilePath::getEnclosingDirectory(texPathStr,false); auto realPath = modelFolder / of::filesystem::path{ texPathStr }; - using std::cout; - using std::endl; - cout << "modelFolder : " << modelFolder << endl; - cout << "texPathStr : " << texPathStr << endl; - cout << "relTexPath : " << relTexPath.string() << endl; - cout << "realPath : " << realPath.string() << endl; - - -// modelFolder : "../MacOS/../../../data/FlightHelmet/" -// texPathStr : FlightHelmet_Materials_LeatherPartsMat_Normal.png -// relTexPath : -// realPath : ../MacOS/../../../data/FlightHelmet/ - - #ifndef TARGET_LINUX_ARM if(bTryEmbed || ofFile::doesFileExist(realPath) == false) { From 5d1adf43e2c68339d17d7a6d16a065df57b2b2da Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 17 Feb 2023 17:05:36 -0300 Subject: [PATCH 75/91] remove .string() --- addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp | 2 +- libs/openFrameworks/utils/ofFileUtils.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index f561977de0e..06801ce8152 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -80,7 +80,7 @@ bool ofxAssimpModelLoader::load(string modelName, int assimpOptimizeFlags){ // } // loads scene from file - std::string path = file.getAbsolutePath().string(); + std::string path = file.getAbsolutePath(); const aiScene * scenePtr = importer.ReadFile(path.c_str(), flags); //this is funky but the scenePtr is managed by assimp and so we can't put it in our shared_ptr without disabling the deleter with: [](const aiScene*){} diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index cbdf245f527..1b94302ac55 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -338,7 +338,7 @@ class ofFilePath{ /// are *not* in the data folder and want the direct path without relative /// "../../" /// \returns absolute path - static of::filesystem::path getAbsolutePath(const of::filesystem::path& path, bool bRelativeToData = true); + static of::filesystem::path getAbsolutePath(const of::filesystem::path& path, bool bRelativeToData = true); /// Check if a path is an absolute (aka a full path), /// ie. "images" -> false, From 381013b681eaebcd4e24d59b46405e96ba06f3ee Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 24 Feb 2023 23:38:33 -0300 Subject: [PATCH 76/91] cubemap fix --- libs/openFrameworks/gl/ofCubeMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/gl/ofCubeMap.cpp b/libs/openFrameworks/gl/ofCubeMap.cpp index daa27cf547f..69f6da97bdc 100644 --- a/libs/openFrameworks/gl/ofCubeMap.cpp +++ b/libs/openFrameworks/gl/ofCubeMap.cpp @@ -394,7 +394,7 @@ bool ofCubeMap::load( ofCubeMapSettings aSettings ) { } else { } - encFolder = ofFilePath::addTrailingSlash( data->settings.cacheDirectory ); + encFolder = ofFilePath::addTrailingSlash( data->settings.cacheDirectory ).string(); } std::string baseName = ofFilePath::getBaseName( data->settings.filePath ); std::string cacheIrrName = baseName+"_irr_"+ofToString(data->settings.irradianceRes,0)+".exr"; From ee78c03ad689e61e3dcbd66ebb71d376813290e5 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 24 Feb 2023 23:46:56 -0300 Subject: [PATCH 77/91] fix assimp --- addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index 06801ce8152..f561977de0e 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -80,7 +80,7 @@ bool ofxAssimpModelLoader::load(string modelName, int assimpOptimizeFlags){ // } // loads scene from file - std::string path = file.getAbsolutePath(); + std::string path = file.getAbsolutePath().string(); const aiScene * scenePtr = importer.ReadFile(path.c_str(), flags); //this is funky but the scenePtr is managed by assimp and so we can't put it in our shared_ptr without disabling the deleter with: [](const aiScene*){} From 2f0d9d413607974f4a505d0c295fc830eeebb724 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 24 Feb 2023 23:50:03 -0300 Subject: [PATCH 78/91] cleanup comment --- addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h index 9c4ff2af3bf..ee189c821d4 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h @@ -178,7 +178,6 @@ class ofxAssimpModelLoader{ glm::mat4 modelMatrix; std::vector lights; - // std::map> textures; std::map< of::filesystem::path, std::shared_ptr From 252a8a6a38d46418f84060c440a49750ddfaf932 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 24 Feb 2023 23:51:13 -0300 Subject: [PATCH 79/91] uniformity in spaces --- addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp b/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp index 7b8045a346e..b888e0fb302 100644 --- a/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp +++ b/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp @@ -22,7 +22,7 @@ ofHttpResponse ofxEmscriptenURLFileLoader::get(const string & url){ return ofHttpResponse(); } -int ofxEmscriptenURLFileLoader::getAsync(const string & url, const string & name){ +int ofxEmscriptenURLFileLoader::getAsync(const string & url, const string & name){ ofHttpRequest * req = new ofHttpRequest(url,name,false); #if __EMSCRIPTEN_major__>1 || (__EMSCRIPTEN_major__==1 && __EMSCRIPTEN_minor__>22) emscripten_async_wget2_data(url.c_str(), "GET", "", req, true, &onload_cb, &onerror_cb, NULL); @@ -30,12 +30,12 @@ int ofxEmscriptenURLFileLoader::getAsync(const string & url, const string & na return req->getId(); } -ofHttpResponse ofxEmscriptenURLFileLoader::saveTo(const string & url, const of::filesystem::path & path){ +ofHttpResponse ofxEmscriptenURLFileLoader::saveTo(const string & url, const of::filesystem::path & path){ saveAsync(url,path); return ofHttpResponse(); } -int ofxEmscriptenURLFileLoader::saveAsync(const string & url, const of::filesystem::path & path){ +int ofxEmscriptenURLFileLoader::saveAsync(const string & url, const of::filesystem::path & path){ ofHttpRequest * req = new ofHttpRequest(url,url,true); #if __EMSCRIPTEN_major__>1 || (__EMSCRIPTEN_major__==1 && __EMSCRIPTEN_minor__>22) emscripten_async_wget2(url.c_str(), path.c_str(), "GET", "", req, &onload_file_cb, &onerror_file_cb, NULL); From 5113cf0729106eedcb3e677bcda8c2dc9dc900da Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 24 Feb 2023 23:51:48 -0300 Subject: [PATCH 80/91] uniformity in spaces --- addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h b/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h index 7e9d55ab97b..aa40a7aa282 100644 --- a/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h +++ b/addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h @@ -11,10 +11,10 @@ class ofxEmscriptenURLFileLoader: public ofBaseURLFileLoader { public: ofxEmscriptenURLFileLoader(); virtual ~ofxEmscriptenURLFileLoader(); - ofHttpResponse get(const std::string & url); - int getAsync(const std::string & url, const std::string & name=""); // returns id - ofHttpResponse saveTo(const std::string & url, const of::filesystem::path & path); - int saveAsync(const std::string & url, const of::filesystem::path & path); + ofHttpResponse get(const std::string & url); + int getAsync(const std::string & url, const std::string & name=""); // returns id + ofHttpResponse saveTo(const std::string & url, const of::filesystem::path & path); + int saveAsync(const std::string & url, const of::filesystem::path & path); ofHttpResponse handleRequest(const ofHttpRequest & request); int handleRequestAsync(const ofHttpRequest & request); void remove(int id); From 5d47d838187a5bc0d5443fabc9ec6a1219b0795c Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 24 Feb 2023 23:59:36 -0300 Subject: [PATCH 81/91] cleanup comments --- libs/openFrameworks/gl/ofShader.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index 5175949b63f..5aa5c98e5d0 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -505,7 +505,6 @@ string ofShader::parseForIncludes( const string& source, vector& include // we store the absolute paths so as have (more) unique file identifiers. include = ofFile( -// ofFilePath::join(sourceDirectoryPath, include) sourceDirectoryPath / include ).getAbsolutePath().string(); included.push_back( include ); From 8cdf5776317415632d87ade3ac95960fbc88240f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 25 Feb 2023 19:50:17 -0300 Subject: [PATCH 82/91] comments cleanup --- .../src/ofxAssimpModelLoader.cpp | 1 - libs/openFrameworks/3d/ofMesh.inl | 3 - libs/openFrameworks/gl/ofShader.cpp | 7 ++- libs/openFrameworks/utils/ofConstants.h | 49 --------------- libs/openFrameworks/utils/ofFileUtils.cpp | 59 +++---------------- libs/openFrameworks/utils/ofFileUtils.h | 2 - .../video/ofDirectShowPlayer.cpp | 1 + tests/utils/fileUtils/src/main.cpp | 1 - 8 files changed, 13 insertions(+), 110 deletions(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index f561977de0e..6d2eb72d582 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -373,7 +373,6 @@ void ofxAssimpModelLoader::loadGLResources(){ std::string texPathStr = texPath.C_Str(); -// std::cout << "first texPathStr: " << texPathStr << std::endl; //deal with Blender putting "//" in front of local file paths if( texPathStr.size() > 2 && texPathStr.substr(0, 2) == "//" ){ texPathStr = texPathStr.substr(2, texPathStr.size()-2); diff --git a/libs/openFrameworks/3d/ofMesh.inl b/libs/openFrameworks/3d/ofMesh.inl index 96ed11bc6e9..10c451c8bf2 100644 --- a/libs/openFrameworks/3d/ofMesh.inl +++ b/libs/openFrameworks/3d/ofMesh.inl @@ -1088,11 +1088,8 @@ void ofMesh_::append(const ofMesh_ & mesh){ template void ofMesh_::load(const of::filesystem::path& path){ ofFile is = {path, ofFile::ReadOnly}; -// ofFile is(path, ofFile::ReadOnly); -// ofFile is(path); auto & data = *this; - std::string error; ofBuffer buffer(is); auto backup = data; diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index 5aa5c98e5d0..be16a117eb0 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -503,10 +503,11 @@ string ofShader::parseForIncludes( const string& source, vector& include } // we store the absolute paths so as have (more) unique file identifiers. - + // FIXME: Included can be a vector of of::filesystem::path in near future include = ofFile( - sourceDirectoryPath / include - ).getAbsolutePath().string(); + sourceDirectoryPath / include + ).getAbsolutePath().string(); + included.push_back( include ); ofBuffer buffer = ofBufferFromFile( include ); diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index 033a2e88816..0b5fa781594 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -515,9 +515,6 @@ std::unique_ptr make_unique(Args&&... args) { namespace std { namespace experimental{ namespace filesystem { -// namespace v1 { -// class path; -// } using path = v1::path; } } @@ -526,36 +523,24 @@ std::unique_ptr make_unique(Args&&... args) { namespace std { namespace experimental{ namespace filesystem { -// namespace v1 { -// namespace __cxx11 { -// class path; -// } -// } using path = v1::__cxx11::path; } } } #endif - using fs = std::experimental::filesystem; - // new namespace of { namespace filesystem = std::experimental::filesystem; } #else #include #if OF_HAS_CPP17 -// using fs = std::filesystem; - // Regular C++17 fs support namespace of { namespace filesystem = std::filesystem; } #else -// using fs = std::__fs::filesystem; - namespace of { -// namespace filesystem = std::__fs::filesystem; namespace filesystem = std::filesystem; } #endif @@ -566,44 +551,10 @@ std::unique_ptr make_unique(Args&&... args) { #define BOOST_NO_CXX11_SCOPED_ENUMS #define BOOST_NO_SCOPED_ENUMS #endif -// #pragma message(Reminder "using boost") #include namespace of { namespace filesystem = boost::filesystem; } -// using fs = boost::filesystem; - -#endif -#if defined __has_include -// #pragma message(Reminder "HAS include") - -// #if __has_include() -//// #define OF_USING_STD_FS 1 -// #include -// #include -// -// #pragma message(Reminder "filesystem") -//namespace of{ -// namespace filesystem = std::__fs::filesystem; -//// namespace filesystem = std::__fs::filesystem; -//} -// #elif __has_include() -// #include -// #pragma message(Reminder "experimental filesystem") -//namespace of{ -//// namespace filesystem = std::experimental::filesystem; -//} -// -// #elif __has_include() -// #include -// #pragma message(Reminder "boost filesystem") -//namespace of{ -//// namespace filesystem = boost::filesystem; -//} -// -// #endif #endif - - diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index ccbb221e502..8d1370dbc10 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -29,23 +29,10 @@ namespace{ of::filesystem::path defaultDataPath(){ #if defined TARGET_OSX return (ofFilePath::getCurrentExeDir() / "../../../data/").string(); -// try{ -// return ofFilePath::getCurrentExeDir() / "../../../data/"; -//// return of::filesystem::canonical(ofFilePath::getCurrentExeDir() / "../../../data/"); -//// return of::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../data/")).string(); -// }catch(...){ -// return ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../data/"); -// } #elif defined TARGET_ANDROID return string("sdcard/"); #else return (ofFilePath::getCurrentExeDir() / of::filesystem::path("data/")).string(); - // FIXME: Cleanup comments -// try{ -// return of::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); -// }catch(...){ -// return ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/"); -// } #endif } @@ -525,9 +512,7 @@ bool ofFile::openStream(Mode _mode, bool _binary){ case WriteOnly: case ReadWrite: case Append: - if(!ofDirectory( - ofFilePath::getEnclosingDirectory(path()) - ).exists()){ + if(!ofDirectory(ofFilePath::getEnclosingDirectory(path())).exists()){ ofFilePath::createEnclosingDirectory(path()); } break; @@ -571,7 +556,6 @@ bool ofFile::open(const of::filesystem::path & _path, Mode _mode, bool binary){ //------------------------------------------------------------------------------------------------------------ bool ofFile::openFromCWD(const of::filesystem::path & _path, Mode _mode, bool binary){ close(); -// myFile = of::filesystem::path(_path.string()); myFile = _path; return openStream(_mode, binary); } @@ -582,7 +566,6 @@ bool ofFile::changeMode(Mode _mode, bool binary){ auto _path = path(); close(); myFile = _path; -// myFile = of::filesystem::path(_path); return openStream(_mode, binary); } else{ @@ -650,16 +633,9 @@ std::filebuf *ofFile::getFileBuffer() const { //------------------------------------------------------------------------------------------------------------ bool ofFile::exists() const { -// FIXME: remove comments -// using std::cout, std::endl; -// cout << "ofFile::exists()" << endl; if(path().empty()){ -// cout << "path empty" << path() << endl; return false; } - -// cout << "path " << path() << endl; -// cout << (of::filesystem::exists(myFile) ? "exist" : "dont exist") << endl; return of::filesystem::exists(myFile); } @@ -947,7 +923,6 @@ bool ofFile::copyTo(const of::filesystem::path& _path, bool bRelativeToData, boo tmp.openFromCWD(path,ofFile::Reference); if(tmp.isDirectory()){ path = path / getFileName(); -// path = ofFilePath::join(path,getFileName()); } } if(ofFile::doesFileExist(path, false)){ @@ -998,7 +973,6 @@ bool ofFile::moveTo(const of::filesystem::path& _path, bool bRelativeToData, boo tmp.openFromCWD(path,ofFile::Reference); if(tmp.isDirectory()){ path = path / getFileName(); -// path = ofFilePath::join(path,getFileName()); } } if(ofFile::doesFileExist(path, false)){ @@ -1225,10 +1199,8 @@ of::filesystem::path ofDirectory::path() const { //------------------------------------------------------------------------------------------------------------ of::filesystem::path ofDirectory::getAbsolutePath() const { try{ -// return of::filesystem::canonical(of::filesystem::absolute(myDir)).string(); return of::filesystem::canonical(of::filesystem::absolute(myDir)); }catch(...){ -// return of::filesystem::absolute(myDir).string(); return of::filesystem::absolute(myDir); } } @@ -1707,10 +1679,8 @@ string ofFilePath::getFileExt(const of::filesystem::path& filename){ of::filesystem::path ofFilePath::removeExt(const of::filesystem::path& _filename){ auto filename = _filename; return filename.replace_extension(); -// return ofFilePath::join(getEnclosingDirectory(filename,false), ofFile(filename,ofFile::Reference).getBaseName()); } - //------------------------------------------------------------------------------------------------------------ string ofFilePath::getPathForDirectory(const of::filesystem::path& path){ // if a trailing slash is missing from a path, this will clean it up @@ -1718,6 +1688,7 @@ string ofFilePath::getPathForDirectory(const of::filesystem::path& path){ // if it's a unix-style "/" path it will add a "/" // FIXME: Remove .string() here and following + // FIXME: this seems over complicated and not useful anymore, using filesystem #if OF_USING_STD_FS && !OF_USE_EXPERIMENTAL_FS if(path.string().empty()) return ""; @@ -1745,16 +1716,8 @@ string ofFilePath::removeTrailingSlash(const of::filesystem::path& _path){ //------------------------------------------------------------------------------------------------------------ // FIXME: convert to of::filesystem::path - +// FIXME: is this still useful? string ofFilePath::getFileName(const of::filesystem::path& _filePath, bool bRelativeToData){ -// std::string filePath = _filePath.string(); -// -// if(bRelativeToData){ -// filePath = ofToDataPath(_filePath); -// } -// -// return of::filesystem::path(filePath).filename().string(); - auto filePath = _filePath; if(bRelativeToData){ @@ -1762,18 +1725,17 @@ string ofFilePath::getFileName(const of::filesystem::path& _filePath, bool bRela } return of::filesystem::path(filePath).filename().string(); - } //------------------------------------------------------------------------------------------------------------ string ofFilePath::getBaseName(const of::filesystem::path& filePath){ + // FIXME: is this still useful? return ofFile(filePath,ofFile::Reference).getBaseName(); } //------------------------------------------------------------------------------------------------------------ of::filesystem::path ofFilePath::getEnclosingDirectory(const of::filesystem::path & _filePath, bool bRelativeToData){ -// std::string filePath = _filePath.string(); - of::filesystem::path fp = _filePath; + auto fp = _filePath; if(bRelativeToData){ fp = ofToDataPath(fp); } @@ -1810,12 +1772,9 @@ string ofFilePath::getCurrentWorkingDirectory(){ } //------------------------------------------------------------------------------------------------------------ -//string ofFilePath::join(const of::filesystem::path& path1, const of::filesystem::path& path2){ -// return (of::filesystem::path(path1) / of::filesystem::path(path2)).string(); -//} - of::filesystem::path ofFilePath::join(const of::filesystem::path& path1, const of::filesystem::path& path2){ - return (of::filesystem::path(path1) / of::filesystem::path(path2)); + // FIXME: remove when possible. helper function more complex than actual solution + return (path1 / path2); } //------------------------------------------------------------------------------------------------------------ @@ -1963,7 +1922,6 @@ of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool makeAb // here we check whether path already refers to the data folder by looking for common elements // if the path begins with the full contents of dataPathRoot then the data path has already been added // we compare inputPath.toString() rather that the input var path to ensure common formatting against dataPath.toString() -// auto dirDataPath = dataPath.string(); auto dirDataPath = dataPath; // 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(dataPath); @@ -2001,5 +1959,4 @@ of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool makeAb // or output the relative path return outputPath.string(); } -} - +} \ No newline at end of file diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index 1b94302ac55..b7252b617cf 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -410,7 +410,6 @@ 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 of::filesystem::path& path1, const of::filesystem::path& path2); static of::filesystem::path join(const of::filesystem::path& path1, const of::filesystem::path& path2); /// Get the full path to the application's executable file. @@ -484,7 +483,6 @@ 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(of::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); ofFile(const of::filesystem::path & path, Mode mode=ReadOnly, bool binary=true); /// Create a new file path using the same path & settings of another diff --git a/libs/openFrameworks/video/ofDirectShowPlayer.cpp b/libs/openFrameworks/video/ofDirectShowPlayer.cpp index cca890227e3..e42fb51f0cc 100644 --- a/libs/openFrameworks/video/ofDirectShowPlayer.cpp +++ b/libs/openFrameworks/video/ofDirectShowPlayer.cpp @@ -1126,6 +1126,7 @@ ofDirectShowPlayer & ofDirectShowPlayer::operator=(ofDirectShowPlayer&& other) { return *this; } +// FIXME: convert to filesystem::path in near future bool ofDirectShowPlayer::load(std::string stringPath){ auto path = ofToDataPath(of::filesystem::path(stringPath)); diff --git a/tests/utils/fileUtils/src/main.cpp b/tests/utils/fileUtils/src/main.cpp index 2428b07a1f8..6f27ca022ec 100644 --- a/tests/utils/fileUtils/src/main.cpp +++ b/tests/utils/fileUtils/src/main.cpp @@ -182,7 +182,6 @@ class ofApp: public ofxUnitTestsApp{ #ifdef TARGET_WIN32 ofxTestEq(ofFilePath::join("d1","d2").string(),"d1\\d2","ofFilePath::join",ofFilePath::join("d1","d2").string()); #else - // ofxTestEq(ofFilePath::join("d1","d2"),"d1/d2","ofFilePath::join",ofFilePath::join("d1","d2")); ofxTestEq(ofFilePath::join("d1","d2").string(),"d1/d2","ofFilePath::join",ofFilePath::join("d1","d2").string()); #endif From c36e856017772d5eac65201bca1ae46f47903cf6 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 3 Mar 2023 23:35:27 -0300 Subject: [PATCH 83/91] string alongside path --- addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp | 2 +- libs/openFrameworks/utils/ofFileUtils.cpp | 5 +++++ libs/openFrameworks/utils/ofFileUtils.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index 6d2eb72d582..f5c3effc0ba 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -80,7 +80,7 @@ bool ofxAssimpModelLoader::load(string modelName, int assimpOptimizeFlags){ // } // loads scene from file - std::string path = file.getAbsolutePath().string(); + std::string path = file.getAbsolutePath(); const aiScene * scenePtr = importer.ReadFile(path.c_str(), flags); //this is funky but the scenePtr is managed by assimp and so we can't put it in our shared_ptr without disabling the deleter with: [](const aiScene*){} diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 8d1370dbc10..1f1989009b5 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -674,6 +674,11 @@ of::filesystem::path ofFile::getAbsolutePath() const { return ofFilePath::getAbsolutePath(path()); } +//------------------------------------------------------------------------------------------------------------ +std::string ofFile::getAbsolutePath() const { + return ofFilePath::getAbsolutePath(path()).string(); +} + //------------------------------------------------------------------------------------------------------------ bool ofFile::canRead() const { auto perm = of::filesystem::status(myFile).permissions(); diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index b7252b617cf..73411ba5212 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -339,6 +339,7 @@ class ofFilePath{ /// "../../" /// \returns absolute path static of::filesystem::path getAbsolutePath(const of::filesystem::path& path, bool bRelativeToData = true); + static std::string getAbsolutePath(const of::filesystem::path& path, bool bRelativeToData = true); /// Check if a path is an absolute (aka a full path), /// ie. "images" -> false, From a89cd812d5280ad9b5b82996c2b7b1b1d7f31b8e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 4 Mar 2023 17:33:47 -0300 Subject: [PATCH 84/91] back to string on return types --- addons/ofxOpenCv/src/ofxCvHaarFinder.cpp | 3 +- addons/ofxSvg/src/ofxSvg.cpp | 14 +- addons/ofxSvg/src/ofxSvg.h | 2 +- addons/ofxXmlSettings/src/ofxXmlSettings.cpp | 4 +- libs/openFrameworks/gl/ofCubeMap.cpp | 3 +- libs/openFrameworks/gl/ofShader.cpp | 12 +- libs/openFrameworks/gl/ofShader.h | 1 + .../graphics/ofCairoRenderer.cpp | 4 +- libs/openFrameworks/graphics/ofImage.cpp | 4 +- .../graphics/ofTrueTypeFont.cpp | 3 +- .../sound/ofFmodSoundPlayer.cpp | 2 +- .../sound/ofOpenALSoundPlayer.cpp | 8 +- libs/openFrameworks/utils/ofFileUtils.cpp | 152 ++++++++++++------ libs/openFrameworks/utils/ofFileUtils.h | 59 +++++-- libs/openFrameworks/utils/ofSystemUtils.cpp | 4 +- libs/openFrameworks/utils/ofXml.cpp | 6 +- .../video/ofAVFoundationPlayer.mm | 2 +- 17 files changed, 184 insertions(+), 99 deletions(-) diff --git a/addons/ofxOpenCv/src/ofxCvHaarFinder.cpp b/addons/ofxOpenCv/src/ofxCvHaarFinder.cpp index 0ba430ab794..c8f353605d4 100644 --- a/addons/ofxOpenCv/src/ofxCvHaarFinder.cpp +++ b/addons/ofxOpenCv/src/ofxCvHaarFinder.cpp @@ -49,11 +49,12 @@ void ofxCvHaarFinder::setNeighbors(unsigned neighbors) { this->neighbors = neighbors; } +// FIXME: convert to of::filesystem::path void ofxCvHaarFinder::setup(std::string haarFile) { this->haarFile = haarFile; - haarFile = ofToDataPath(haarFile).string(); + haarFile = ofToDataPath(haarFile); #ifdef USE_OLD_CV if(cascade != NULL) cvReleaseHaarClassifierCascade(&cascade); diff --git a/addons/ofxSvg/src/ofxSvg.cpp b/addons/ofxSvg/src/ofxSvg.cpp index ee6e8348acb..d34d62ff6c3 100644 --- a/addons/ofxSvg/src/ofxSvg.cpp +++ b/addons/ofxSvg/src/ofxSvg.cpp @@ -27,17 +27,19 @@ ofPath & ofxSvg::getPathAt(int n){ return paths[n]; } -void ofxSvg::load(std::string path){ - path = ofToDataPath(path).string(); +void ofxSvg::load(of::filesystem::path fileName){ + fileName = ofToDataPath(fileName); - if(path.compare("") == 0){ - ofLogError("ofxSVG") << "load(): path does not exist: \"" << path << "\""; + // FIXME: I think this is the equivalent of .empty() which is simpler. + // maybe use file exists to check instead? + if(fileName.compare("") == 0){ + ofLogError("ofxSVG") << "load(): path does not exist: \"" << fileName << "\""; return; } - ofBuffer buffer = ofBufferFromFile(path); + ofBuffer buffer = ofBufferFromFile(fileName); - loadFromString(buffer.getText(), path); + loadFromString(buffer.getText(), fileName); } diff --git a/addons/ofxSvg/src/ofxSvg.h b/addons/ofxSvg/src/ofxSvg.h index 3e79151493d..1c839c38468 100644 --- a/addons/ofxSvg/src/ofxSvg.h +++ b/addons/ofxSvg/src/ofxSvg.h @@ -25,7 +25,7 @@ class ofxSvg { /// \brief Loads an SVG file from the provided filename. /// /// ~~~~ - void load(std::string path); + void load(of::filesystem::path fileName); /// \brief Loads an SVG from a text string. /// diff --git a/addons/ofxXmlSettings/src/ofxXmlSettings.cpp b/addons/ofxXmlSettings/src/ofxXmlSettings.cpp index 2dc484e777a..1a545f17105 100644 --- a/addons/ofxXmlSettings/src/ofxXmlSettings.cpp +++ b/addons/ofxXmlSettings/src/ofxXmlSettings.cpp @@ -73,7 +73,7 @@ void ofxXmlSettings::clear(){ //--------------------------------------------------------- bool ofxXmlSettings::load(const string& xmlFile){ auto fullXmlFile = ofToDataPath(xmlFile); - bool loadOkay = doc.LoadFile(fullXmlFile.string()); + bool loadOkay = doc.LoadFile(fullXmlFile.c_str()); //theo removed bool check as it would //return false if the file exists but was @@ -89,7 +89,7 @@ bool ofxXmlSettings::load(const string& xmlFile){ //--------------------------------------------------------- bool ofxXmlSettings::save(const string& xmlFile){ auto fullXmlFile = ofToDataPath(xmlFile); - return doc.SaveFile(fullXmlFile.string()); + return doc.SaveFile(fullXmlFile.c_str()); } //--------------------------------------------------------- diff --git a/libs/openFrameworks/gl/ofCubeMap.cpp b/libs/openFrameworks/gl/ofCubeMap.cpp index 69f6da97bdc..34335867d99 100644 --- a/libs/openFrameworks/gl/ofCubeMap.cpp +++ b/libs/openFrameworks/gl/ofCubeMap.cpp @@ -394,7 +394,8 @@ bool ofCubeMap::load( ofCubeMapSettings aSettings ) { } else { } - encFolder = ofFilePath::addTrailingSlash( data->settings.cacheDirectory ).string(); + // encFolder = ofFilePath::addTrailingSlash( data->settings.cacheDirectory ).string(); + encFolder = ofFilePath::addTrailingSlash( data->settings.cacheDirectory ); } std::string baseName = ofFilePath::getBaseName( data->settings.filePath ); std::string cacheIrrName = baseName+"_irr_"+ofToString(data->settings.irradianceRes,0)+".exr"; diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index be16a117eb0..6e838786539 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -302,7 +302,7 @@ bool ofShader::setupShaderFromFile(GLenum type, const of::filesystem::path & fil auto absoluteFilePath = ofFilePath::getAbsolutePath(filename, true); auto sourceDirectoryPath = ofFilePath::getEnclosingDirectory(absoluteFilePath,false); if(buffer.size()) { - return setupShaderFromSource(type, buffer.getText(), sourceDirectoryPath.string()); + return setupShaderFromSource(type, buffer.getText(), sourceDirectoryPath); } else { ofLogError("ofShader") << "setupShaderFromFile(): couldn't load " << nameForType(type) << " shader " << " from \"" << absoluteFilePath << "\""; return false; @@ -317,7 +317,8 @@ ofShader::Source ofShader::sourceFromFile(GLenum type, const of::filesystem::pat auto absoluteFilePath = ofFilePath::getAbsolutePath(filename, true); auto sourceDirectoryPath = ofFilePath::getEnclosingDirectory(absoluteFilePath,false); if(buffer.size()) { - return Source{type, buffer.getText(), sourceDirectoryPath.string() }; + // return Source{type, buffer.getText(), sourceDirectoryPath.string() }; + return Source{type, buffer.getText(), sourceDirectoryPath }; } else { ofLogError("ofShader") << "setupShaderFromFile(): couldn't load " << nameForType(type) << " shader " << " from \"" << absoluteFilePath << "\""; return Source{}; @@ -325,6 +326,7 @@ ofShader::Source ofShader::sourceFromFile(GLenum type, const of::filesystem::pat } //-------------------------------------------------------------- +// FIXME: change to of::filesystem bool ofShader::setupShaderFromSource(GLenum type, string source, string sourceDirectoryPath) { return setupShaderFromSource({type, source, sourceDirectoryPath}); } @@ -429,6 +431,7 @@ string ofShader::parseForIncludes( const string& source, const of::filesystem::p } //-------------------------------------------------------------- +// FIXME: update to use fs::path in vector and source string ofShader::parseForIncludes( const string& source, vector& included, int level, const of::filesystem::path& sourceDirectoryPath) { if ( level > 32 ) { @@ -506,7 +509,8 @@ string ofShader::parseForIncludes( const string& source, vector& include // FIXME: Included can be a vector of of::filesystem::path in near future include = ofFile( sourceDirectoryPath / include - ).getAbsolutePath().string(); + // ).getAbsolutePath().string(); + ).getAbsolutePath(); included.push_back( include ); @@ -516,7 +520,7 @@ string ofShader::parseForIncludes( const string& source, vector& include continue; } - string currentDir = ofFile(include).getEnclosingDirectory().string(); + auto currentDir = ofFile(include).getEnclosingDirectory(); output << parseForIncludes( buffer.getText(), included, level + 1, currentDir ) << endl; } diff --git a/libs/openFrameworks/gl/ofShader.h b/libs/openFrameworks/gl/ofShader.h index 99fc75cbe66..3b0854f8138 100644 --- a/libs/openFrameworks/gl/ofShader.h +++ b/libs/openFrameworks/gl/ofShader.h @@ -37,6 +37,7 @@ struct ofShaderSettings { class ofShader { struct Source{ + // FIXME: change source to of::filesystem::path Source(GLuint type, const std::string & source, const of::filesystem::path & directoryPath) :type(type) ,source(source) diff --git a/libs/openFrameworks/graphics/ofCairoRenderer.cpp b/libs/openFrameworks/graphics/ofCairoRenderer.cpp index 34b6c42d5e5..0e94081a0b8 100644 --- a/libs/openFrameworks/graphics/ofCairoRenderer.cpp +++ b/libs/openFrameworks/graphics/ofCairoRenderer.cpp @@ -73,14 +73,14 @@ void ofCairoRenderer::setup(const std::string & _filename, Type _type, bool mult if(filename==""){ surface = cairo_pdf_surface_create_for_stream(&ofCairoRenderer::stream_function,this,outputsize.width, outputsize.height); }else{ - surface = cairo_pdf_surface_create(ofToDataPath(filename).string().c_str(),outputsize.width, outputsize.height); + surface = cairo_pdf_surface_create(ofToDataPath(filename).c_str(),outputsize.width, outputsize.height); } break; case SVG: if(filename==""){ surface = cairo_svg_surface_create_for_stream(&ofCairoRenderer::stream_function,this,outputsize.width, outputsize.height); }else{ - surface = cairo_svg_surface_create(ofToDataPath(filename).string().c_str(),outputsize.width, outputsize.height); + surface = cairo_svg_surface_create(ofToDataPath(filename).c_str(),outputsize.width, outputsize.height); } break; case IMAGE: diff --git a/libs/openFrameworks/graphics/ofImage.cpp b/libs/openFrameworks/graphics/ofImage.cpp index e7483468b2a..3eaac432043 100644 --- a/libs/openFrameworks/graphics/ofImage.cpp +++ b/libs/openFrameworks/graphics/ofImage.cpp @@ -209,7 +209,7 @@ static bool loadImage(ofPixels_ & pix, const of::filesystem::path& _f return ofLoadImage(pix, ofLoadURL(_fileName.string()).data); } - std::string fileName = ofToDataPath(_fileName, true).string(); + auto fileName = ofToDataPath(_fileName, true); bool bLoaded = false; FIBITMAP * bmp = nullptr; @@ -358,7 +358,7 @@ static bool saveImage(const ofPixels_ & _pix, const of::filesystem::p } ofFilePath::createEnclosingDirectory(_fileName); - std::string fileName = ofToDataPath(_fileName).string(); + auto fileName = ofToDataPath(_fileName); FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; fif = FreeImage_GetFileType(fileName.c_str(), 0); if(fif == FIF_UNKNOWN) { diff --git a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp index b89cd803ffe..baa9d58ea7c 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp @@ -382,6 +382,7 @@ static bool loadFontFace(const of::filesystem::path& _fontname, FT_Face & face, int fontID = index; if(!fontFile.exists()){ #ifdef TARGET_LINUX + // FIXME: update function linuxFontPathByName to use path instead of string filename = linuxFontPathByName(fontname.string()); #elif defined(TARGET_OSX) if(fontname==OF_TTF_SANS){ @@ -414,7 +415,7 @@ static bool loadFontFace(const of::filesystem::path& _fontname, FT_Face & face, ofLogVerbose("ofTrueTypeFont") << "loadFontFace(): \"" << fontname << "\" not a file in data loading system font from \"" << filename << "\""; } FT_Error err; - err = FT_New_Face( library, filename.string().c_str(), fontID, &face ); + err = FT_New_Face( library, filename.c_str(), fontID, &face ); if (err) { // simple error table in lieu of full table (see fterrors.h) string errorString = "unknown freetype"; diff --git a/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp b/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp index d36148f6cc0..797acf132ab 100644 --- a/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp @@ -206,7 +206,7 @@ bool ofFmodSoundPlayer::load(const of::filesystem::path& _fileName, bool stream) int fmodFlags = FMOD_DEFAULT; if(stream)fmodFlags = FMOD_DEFAULT | FMOD_CREATESTREAM; - result = FMOD_System_CreateSound(sys, fileName.string().data(), fmodFlags, nullptr, &sound); + result = FMOD_System_CreateSound(sys, fileName.c_str(), fmodFlags, nullptr, &sound); if (result != FMOD_OK){ bLoadedOk = false; diff --git a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp index 8dca8913cbb..7589b334802 100644 --- a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp @@ -231,7 +231,7 @@ void ofOpenALSoundPlayer::close(){ // ---------------------------------------------------------------------------- bool ofOpenALSoundPlayer::sfReadFile(const of::filesystem::path& path, std::vector & buffer, std::vector & fftAuxBuffer){ SF_INFO sfInfo; - SNDFILE* f = sf_open(path.string().c_str(),SFM_READ,&sfInfo); + SNDFILE* f = sf_open(path.c_str(),SFM_READ,&sfInfo); if(!f){ ofLogError("ofOpenALSoundPlayer") << "sfReadFile(): couldn't read \"" << path << "\""; return false; @@ -286,7 +286,7 @@ bool ofOpenALSoundPlayer::sfReadFile(const of::filesystem::path& path, std::vect bool ofOpenALSoundPlayer::mpg123ReadFile(const of::filesystem::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){ + if(mpg123_open(f,path.c_str())!=MPG123_OK){ ofLogError("ofOpenALSoundPlayer") << "mpg123ReadFile(): couldn't read \"" << path << "\""; return false; } @@ -324,7 +324,7 @@ bool ofOpenALSoundPlayer::mpg123ReadFile(const of::filesystem::path& path,std::v bool ofOpenALSoundPlayer::sfStream(const of::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer){ if(!streamf){ SF_INFO sfInfo; - streamf = sf_open(path.string().c_str(),SFM_READ,&sfInfo); + streamf = sf_open(path.c_str(),SFM_READ,&sfInfo); if(!streamf){ ofLogError("ofOpenALSoundPlayer") << "sfStream(): couldn't read \"" << path << "\""; return false; @@ -388,7 +388,7 @@ bool ofOpenALSoundPlayer::mpg123Stream(const of::filesystem::path& path,std::vec if(!mp3streamf){ int err = MPG123_OK; mp3streamf = mpg123_new(nullptr,&err); - if(mpg123_open(mp3streamf,path.string().c_str())!=MPG123_OK){ + if(mpg123_open(mp3streamf,path.c_str())!=MPG123_OK){ mpg123_close(mp3streamf); mpg123_delete(mp3streamf); ofLogError("ofOpenALSoundPlayer") << "mpg123Stream(): couldn't read \"" << path << "\""; diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 1f1989009b5..d82cdff220c 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -26,9 +26,11 @@ namespace{ bool enableDataPath = true; //-------------------------------------------------- - of::filesystem::path defaultDataPath(){ +// MARK: - near future +// of::filesystem::path defaultDataPath(){ + std::string defaultDataPath(){ #if defined TARGET_OSX - return (ofFilePath::getCurrentExeDir() / "../../../data/").string(); + return (ofFilePath::getCurrentExeDir() / of::filesystem::path("../../../data/")).string(); #elif defined TARGET_ANDROID return string("sdcard/"); #else @@ -598,8 +600,7 @@ bool ofFile::create(const of::filesystem::path & path){ success = open(path,ofFile::WriteOnly,binary); close(); - // FIXME: why length? - if( oldpath.string().length() ){ + if( !oldpath.empty() ){ open(oldpath,oldmode,binary); } @@ -640,13 +641,17 @@ bool ofFile::exists() const { } //------------------------------------------------------------------------------------------------------------ -of::filesystem::path ofFile::path() const { - return myFile; +// MARK: - near future +//of::filesystem::path ofFile::path() const { +//return myFile; +std::string ofFile::path() const { + return myFile.string(); } //------------------------------------------------------------------------------------------------------------ string ofFile::getExtension() const { auto dotext = myFile.extension().string(); + // FIXME: probably not needed; if(!dotext.empty() && dotext.front()=='.'){ return std::string(dotext.begin()+1,dotext.end()); }else{ @@ -665,18 +670,17 @@ string ofFile::getBaseName() const { } //------------------------------------------------------------------------------------------------------------ -of::filesystem::path ofFile::getEnclosingDirectory() const { +// MARK: - near future +//of::filesystem::path ofFile::getEnclosingDirectory() const { +std::string ofFile::getEnclosingDirectory() const { return ofFilePath::getEnclosingDirectory(path()); } //------------------------------------------------------------------------------------------------------------ -of::filesystem::path ofFile::getAbsolutePath() const { - return ofFilePath::getAbsolutePath(path()); -} - -//------------------------------------------------------------------------------------------------------------ +// MARK: - near future +//of::filesystem::path ofFile::getAbsolutePath() const { std::string ofFile::getAbsolutePath() const { - return ofFilePath::getAbsolutePath(path()).string(); + return ofFilePath::getAbsolutePath(path()); } //------------------------------------------------------------------------------------------------------------ @@ -1197,16 +1201,27 @@ bool ofDirectory::exists() const { } //------------------------------------------------------------------------------------------------------------ -of::filesystem::path ofDirectory::path() const { - return myDir; +// MARK: - near future +//of::filesystem::path ofDirectory::path() const { +// return myDir; +std::string ofDirectory::path() const { + return myDir.string(); } //------------------------------------------------------------------------------------------------------------ -of::filesystem::path ofDirectory::getAbsolutePath() const { +// MARK: - near future +//of::filesystem::path ofDirectory::getAbsolutePath() const { +// try{ +// return of::filesystem::canonical(of::filesystem::absolute(myDir)); +// }catch(...){ +// return of::filesystem::absolute(myDir); +// } +//} +std::string ofDirectory::getAbsolutePath() const { try{ - return of::filesystem::canonical(of::filesystem::absolute(myDir)); + return of::filesystem::canonical(of::filesystem::absolute(myDir)).string(); }catch(...){ - return of::filesystem::absolute(myDir); + return of::filesystem::absolute(myDir).string(); } } @@ -1656,20 +1671,24 @@ string ofFilePath::addLeadingSlash(const of::filesystem::path& _path){ } //------------------------------------------------------------------------------------------------------------ -of::filesystem::path ofFilePath::addTrailingSlash(const of::filesystem::path & _path){ +// MARK: - near future +//of::filesystem::path ofFilePath::addTrailingSlash(const of::filesystem::path & _path){ +std::string ofFilePath::addTrailingSlash(const of::filesystem::path & _path){ #if OF_USING_STD_FS && !OF_USE_EXPERIMENTAL_FS if(_path.string().empty()) return ""; // FIXME: Remove .string() here and following + // return (of::filesystem::path(_path).make_preferred() / ""); return (of::filesystem::path(_path).make_preferred() / "").string(); #else - auto path = of::filesystem::path(_path).make_preferred().string(); + auto path = of::filesystem::path(_path).make_preferred(); auto sep = of::filesystem::path("/").make_preferred(); if(!path.empty()){ - if(ofToString(path.back()) != sep.string()){ - path = (path / sep).string(); + if(ofToString(path.string().back()) != sep.string()){ + path = (path / sep); } } - return path; +// return path; + return path.string(); #endif } @@ -1681,9 +1700,12 @@ string ofFilePath::getFileExt(const of::filesystem::path& filename){ //------------------------------------------------------------------------------------------------------------ // FIXME: remove const and copy -of::filesystem::path ofFilePath::removeExt(const of::filesystem::path& _filename){ +// MARK: - near future +// of::filesystem::path ofFilePath::removeExt(const of::filesystem::path& _filename){ +std::string ofFilePath::removeExt(const of::filesystem::path& _filename){ auto filename = _filename; - return filename.replace_extension(); +// return filename.replace_extension(); + return filename.replace_extension().string(); } //------------------------------------------------------------------------------------------------------------ @@ -1720,8 +1742,7 @@ string ofFilePath::removeTrailingSlash(const of::filesystem::path& _path){ //------------------------------------------------------------------------------------------------------------ -// FIXME: convert to of::filesystem::path -// FIXME: is this still useful? +// FIXME: is this still useful? if yes convert to of::filesystem::path string ofFilePath::getFileName(const of::filesystem::path& _filePath, bool bRelativeToData){ auto filePath = _filePath; @@ -1729,6 +1750,7 @@ string ofFilePath::getFileName(const of::filesystem::path& _filePath, bool bRela filePath = ofToDataPath(filePath); } + // FIXME: this is probably over complicated return of::filesystem::path(filePath).filename().string(); } @@ -1739,7 +1761,9 @@ string ofFilePath::getBaseName(const of::filesystem::path& filePath){ } //------------------------------------------------------------------------------------------------------------ -of::filesystem::path ofFilePath::getEnclosingDirectory(const of::filesystem::path & _filePath, bool bRelativeToData){ +// MARK: - near future +//of::filesystem::path ofFilePath::getEnclosingDirectory(const of::filesystem::path & _filePath, bool bRelativeToData){ +std::string ofFilePath::getEnclosingDirectory(const of::filesystem::path & _filePath, bool bRelativeToData){ auto fp = _filePath; if(bRelativeToData){ fp = ofToDataPath(fp); @@ -1753,19 +1777,22 @@ bool ofFilePath::createEnclosingDirectory(const of::filesystem::path& filePath, } //------------------------------------------------------------------------------------------------------------ -of::filesystem::path ofFilePath::getAbsolutePath(const of::filesystem::path& path, bool bRelativeToData){ +// FIXME: - near future +//of::filesystem::path ofFilePath::getAbsolutePath(const of::filesystem::path& path, bool bRelativeToData){ +std::string ofFilePath::getAbsolutePath(const of::filesystem::path& path, bool bRelativeToData){ if(bRelativeToData){ return ofToDataPath(path, true); }else{ try{ - return of::filesystem::canonical(of::filesystem::absolute(path)); +// return of::filesystem::canonical(of::filesystem::absolute(path)); + return of::filesystem::canonical(of::filesystem::absolute(path)).string(); }catch(...){ - return of::filesystem::absolute(path); +// return of::filesystem::absolute(path); + return of::filesystem::absolute(path).string(); } } } - //------------------------------------------------------------------------------------------------------------ bool ofFilePath::isAbsolute(const of::filesystem::path& path){ return of::filesystem::path(path).is_absolute(); @@ -1777,9 +1804,14 @@ string ofFilePath::getCurrentWorkingDirectory(){ } //------------------------------------------------------------------------------------------------------------ -of::filesystem::path ofFilePath::join(const of::filesystem::path& path1, const of::filesystem::path& path2){ - // FIXME: remove when possible. helper function more complex than actual solution - return (path1 / path2); +// MARK: - near future +//of::filesystem::path ofFilePath::join(const of::filesystem::path& path1, const of::filesystem::path& path2){ +// // FIXME: deprecate when possible. helper function more complex than actual solution +// return (path1 / path2); +//} +std::string ofFilePath::join(const of::filesystem::path& path1, const of::filesystem::path& path2){ + // FIXME: deprecate when possible. helper function more complex than actual solution + return (path1 / path2).string(); } //------------------------------------------------------------------------------------------------------------ @@ -1814,7 +1846,9 @@ string ofFilePath::getCurrentExePath(){ } //------------------------------------------------------------------------------------------------------------ -of::filesystem::path ofFilePath::getCurrentExeDir(){ +// MARK: - near future +//of::filesystem::path ofFilePath::getCurrentExeDir(){ +std::string ofFilePath::getCurrentExeDir(){ return ofFilePath::getEnclosingDirectory(ofFilePath::getCurrentExePath(), false); } @@ -1833,7 +1867,9 @@ string ofFilePath::getUserHomeDir(){ #endif } -of::filesystem::path ofFilePath::makeRelative(const of::filesystem::path & from, const of::filesystem::path & to){ +// MARK: - near future +//of::filesystem::path ofFilePath::makeRelative(const of::filesystem::path & from, const of::filesystem::path & to){ +std::string ofFilePath::makeRelative(const of::filesystem::path & from, const of::filesystem::path & to){ auto pathFrom = of::filesystem::absolute( from ); auto pathTo = of::filesystem::absolute( to ); of::filesystem::path ret; @@ -1853,7 +1889,8 @@ of::filesystem::path ofFilePath::makeRelative(const of::filesystem::path & from, } } - return ret; +// return ret; + return ret.string(); } //-------------------------------------------------- @@ -1882,13 +1919,19 @@ void ofSetDataPathRoot(const of::filesystem::path& newRoot){ } //-------------------------------------------------- -of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool makeAbsolute){ +// MARK: - near future +//of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool makeAbsolute){ +std::string ofToDataPath(const of::filesystem::path & path, bool makeAbsolute){ if (makeAbsolute && path.is_absolute()) { - return path; + // MARK: need to convert to string? or automatic? +// return path; + return path.string(); } if (!enableDataPath) { - return path; + // MARK: need to convert to string? or automatic? +// return path; + return path.string(); } bool hasTrailingSlash = !path.empty() && path.generic_string().back()=='/'; @@ -1905,7 +1948,7 @@ of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool makeAb #endif // 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(); + const auto & dataPath = dataPathRoot(); of::filesystem::path inputPath(path); of::filesystem::path outputPath; @@ -1914,13 +1957,15 @@ of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool makeAb try { auto outpath = of::filesystem::canonical(inputPath).make_preferred(); if(of::filesystem::is_directory(outpath) && hasTrailingSlash){ - return ofFilePath::addTrailingSlash(outpath.string()); + return ofFilePath::addTrailingSlash(outpath); }else{ - return outpath.string(); +// return outpath.string(); + return outpath; } } catch (...) { - return inputPath.string(); +// return inputPath.string(); + return inputPath; } } @@ -1931,10 +1976,12 @@ of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool makeAb // 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(dataPath); - auto relativeDirDataPath = ofFilePath::makeRelative(of::filesystem::current_path().string(),dataPath.string()); - relativeDirDataPath = ofFilePath::addTrailingSlash(relativeDirDataPath.string()); + auto relativeDirDataPath = ofFilePath::makeRelative(of::filesystem::current_path(), dataPath); + relativeDirDataPath = ofFilePath::addTrailingSlash(relativeDirDataPath); - if (inputPath.string().find(dirDataPath.string()) != 0 && inputPath.string().find(relativeDirDataPath.string())!=0) { + // FIXME: this can be simplified without using string conversion + // if (inputPath.string().find(dirDataPath.string()) != 0 && inputPath.string().find(relativeDirDataPath.string())!=0) { + if (inputPath.string().find(dirDataPath.string()) != 0 && inputPath.string().find(relativeDirDataPath)!=0) { // inputPath doesn't contain data path already, so we build the output path as the inputPath relative to the dataPath if(makeAbsolute){ outputPath = dirDataPath / inputPath; @@ -1954,14 +2001,17 @@ of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool makeAb if(of::filesystem::is_directory(outpath) && hasTrailingSlash){ return ofFilePath::addTrailingSlash(outpath); }else{ +// return outpath; return outpath.string(); } } catch (std::exception &) { - return of::filesystem::absolute(outputPath).string(); +// return of::filesystem::absolute(outputPath).string(); + return of::filesystem::absolute(outputPath); } }else{ // or output the relative path - return outputPath.string(); +// return outputPath; + return outputPath.string(); } -} \ No newline at end of file +} diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index 73411ba5212..db9c09edd20 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -300,8 +300,10 @@ class ofFilePath{ /// /// \param filename file path /// \returns filename without extension - static of::filesystem::path removeExt(const of::filesystem::path& filename); - +// MARK: - near future +// static of::filesystem::path removeExt(const of::filesystem::path& filename); + static std::string removeExt(const of::filesystem::path& filename); + /// Prepend path with a slash, ie. "images" -> "/images". /// /// \param path file or directory path @@ -312,8 +314,10 @@ class ofFilePath{ /// /// \param path directory path /// \returns path + slash - static of::filesystem::path addTrailingSlash(const of::filesystem::path& path); - +// MARK: - near future +// static of::filesystem::path addTrailingSlash(const of::filesystem::path& path); + static std::string addTrailingSlash(const of::filesystem::path& path); + /// Remove a path's trailing slash (if found), /// ie. "images/" -> "images". /// @@ -338,7 +342,8 @@ class ofFilePath{ /// are *not* in the data folder and want the direct path without relative /// "../../" /// \returns absolute path - static of::filesystem::path getAbsolutePath(const of::filesystem::path& path, bool bRelativeToData = true); + // MARK - near future + // static of::filesystem::path getAbsolutePath(const of::filesystem::path& path, bool bRelativeToData = true); static std::string getAbsolutePath(const of::filesystem::path& path, bool bRelativeToData = true); /// Check if a path is an absolute (aka a full path), @@ -379,7 +384,9 @@ class ofFilePath{ /// are *not* in the data folder and want the direct path without relative /// "../../" ///\returns enclosing directory - static of::filesystem::path getEnclosingDirectory(const of::filesystem::path& filePath, bool bRelativeToData = true); +// MARK: - near future +// static of::filesystem::path getEnclosingDirectory(const of::filesystem::path& filePath, bool bRelativeToData = true); + static std::string getEnclosingDirectory(const of::filesystem::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". @@ -411,7 +418,9 @@ class ofFilePath{ /// \param path1 left half of the path to join /// \param path2 right half of the path to join /// \returns joined path - static of::filesystem::path join(const of::filesystem::path& path1, const of::filesystem::path& path2); +// MARK: - near future +// static of::filesystem::path join(const of::filesystem::path& path1, const of::filesystem::path& path2); + static std::string join(const of::filesystem::path& path1, const of::filesystem::path& path2); /// Get the full path to the application's executable file. /// @@ -428,7 +437,9 @@ class ofFilePath{ /// Mac: the Contents/MacOS folder within the application's .app bundle /// /// \returns current executable directory - static of::filesystem::path getCurrentExeDir(); +// MARK: - near future +// static of::filesystem::path getCurrentExeDir(); + static std::string getCurrentExeDir(); /// Get the absolute path to the user's home directory. /// @@ -446,7 +457,9 @@ class ofFilePath{ /// \param from starting path /// \param to destination path /// \returns relative path - static of::filesystem::path makeRelative(const of::filesystem::path & from, const of::filesystem::path & to); + // MARK: - near future +// static of::filesystem::path makeRelative(const of::filesystem::path & from, const of::filesystem::path & to); + static std::string makeRelative(const of::filesystem::path & from, const of::filesystem::path & to); }; /// \class ofFile @@ -559,8 +572,10 @@ class ofFile: public std::fstream{ /// Get the current path. /// /// \returns current path - of::filesystem::path path() const; - +// MARK: - near future +// of::filesystem::path path() const; + std::string path() const; + /// Get the current path without its extension, /// ie. "duck.jpg" ->"duck". /// @@ -585,13 +600,17 @@ class ofFile: public std::fstream{ /// directory. /// /// \returns current path's enclosing directory - of::filesystem::path getEnclosingDirectory() const; +// MARK: - near future +// of::filesystem::path getEnclosingDirectory() const; + std::string getEnclosingDirectory() const; /// \biref Get the absolute, full path of the file, /// ie. "images" -> "/Users/mickey/of/apps/myApps/Donald/bin/data/images". /// /// \returns current path as an absolute path - of::filesystem::path getAbsolutePath() const; +// MARK: - near future +// of::filesystem::path getAbsolutePath() const; + std::string getAbsolutePath() const; /// Check if the current path is readable. /// @@ -861,13 +880,17 @@ class ofDirectory{ /// Get the current path. /// /// \returns current path - of::filesystem::path path() const; - +// MARK: - near future +// of::filesystem::path path() const; + std::string path() const; + /// Get the absolute, full path of the directory, /// ie. "images" -> "/Users/mickey/of/apps/myApps/Donald/bin/data/images". /// /// \return current path as an absolute path - of::filesystem::path getAbsolutePath() const; +// MARK: - near future +// of::filesystem::path getAbsolutePath() const; + std::string getAbsolutePath() const; /// Check if the current path is readable. /// @@ -1204,7 +1227,9 @@ 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(). -of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool absolute=false); +// MARK: - near future +//of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool absolute=false); +std::string ofToDataPath(const of::filesystem::path & path, bool absolute=false); /// \brief Reset the working directory to the platform default. /// diff --git a/libs/openFrameworks/utils/ofSystemUtils.cpp b/libs/openFrameworks/utils/ofSystemUtils.cpp index 62859ffcdde..eca04858f00 100644 --- a/libs/openFrameworks/utils/ofSystemUtils.cpp +++ b/libs/openFrameworks/utils/ofSystemUtils.cpp @@ -331,7 +331,7 @@ static int CALLBACK loadDialogBrowseCallback( std::string defaultPath = *(std::string*)lpData; if(defaultPath!="" && uMsg==BFFM_INITIALIZED){ wchar_t wideCharacterBuffer[MAX_PATH]; - wcscpy(wideCharacterBuffer, convertNarrowToWide(ofToDataPath(defaultPath).string()).c_str()); + wcscpy(wideCharacterBuffer, convertNarrowToWide(ofToDataPath(defaultPath)).c_str()); SendMessage(hwnd,BFFM_SETSELECTION,1,(LPARAM)wideCharacterBuffer); } @@ -412,7 +412,7 @@ ofFileDialogResult ofSystemLoadDialog(std::string windowTitle, bool bFolderSelec //the title if specified wchar_t szTitle[MAX_PATH]; if(defaultPath!=""){ - wcscpy(szDir,convertNarrowToWide(ofToDataPath(defaultPath).string()).c_str()); + wcscpy(szDir,convertNarrowToWide(ofToDataPath(defaultPath)).c_str()); ofn.lpstrInitialDir = szDir; } diff --git a/libs/openFrameworks/utils/ofXml.cpp b/libs/openFrameworks/utils/ofXml.cpp index 5cebfa27b17..244325ddca8 100644 --- a/libs/openFrameworks/utils/ofXml.cpp +++ b/libs/openFrameworks/utils/ofXml.cpp @@ -18,7 +18,7 @@ ofXml::ofXml(std::shared_ptr doc, const pugi::xml_node & xml bool ofXml::load(const of::filesystem::path & file){ auto auxDoc = std::make_shared(); auto p = ofToDataPath(file); - auto res = auxDoc->load_file(ofToDataPath(file).string().c_str()); + auto res = auxDoc->load_file(ofToDataPath(file).c_str()); if( res ){ doc = auxDoc; xml = doc->root(); @@ -50,14 +50,14 @@ bool ofXml::parse(const std::string & xmlStr){ bool ofXml::save(const of::filesystem::path & file) const{ if(xml == doc->root()){ - auto res = doc->save_file(ofToDataPath(file).string().c_str()); + auto res = doc->save_file(ofToDataPath(file).c_str()); ofLogVerbose("ofXml")<<"ofXML Save : "<< res; ofLogVerbose("ofXml")<toString(); return res; }else{ pugi::xml_document doc; if(doc.append_copy(xml.root())){ - return doc.save_file(ofToDataPath(file).string().c_str()); + return doc.save_file(ofToDataPath(file).c_str()); } } return false; diff --git a/libs/openFrameworks/video/ofAVFoundationPlayer.mm b/libs/openFrameworks/video/ofAVFoundationPlayer.mm index 46cd175cef3..24c78410de0 100644 --- a/libs/openFrameworks/video/ofAVFoundationPlayer.mm +++ b/libs/openFrameworks/video/ofAVFoundationPlayer.mm @@ -69,7 +69,7 @@ } NSString * videoPath = [NSString stringWithUTF8String:name.c_str()]; - NSString * videoLocalPath = [NSString stringWithUTF8String:ofToDataPath(name).string().c_str()]; + NSString * videoLocalPath = [NSString stringWithUTF8String:ofToDataPath(name).c_str()]; BOOL bStream = NO; From 80c12997b3d252bdb7c4f450f92b4af8ff78aa73 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 4 Mar 2023 17:56:45 -0300 Subject: [PATCH 85/91] fixes --- libs/openFrameworks/utils/ofFileUtils.cpp | 352 ++++++++++---------- libs/openFrameworks/utils/ofSystemUtils.cpp | 6 +- 2 files changed, 180 insertions(+), 178 deletions(-) diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index d82cdff220c..ae1523ff473 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -14,7 +14,7 @@ #include /* PATH_MAX */ #endif -// FIXME: better explicit declaration +// FIXME: better explicit declaration using std::string; using std::vector; using std::fstream; @@ -23,40 +23,40 @@ using std::ostream; using std::ios; namespace{ - bool enableDataPath = true; + bool enableDataPath = true; - //-------------------------------------------------- + //-------------------------------------------------- // MARK: - near future // of::filesystem::path defaultDataPath(){ std::string defaultDataPath(){ - #if defined TARGET_OSX + #if defined TARGET_OSX return (ofFilePath::getCurrentExeDir() / of::filesystem::path("../../../data/")).string(); - #elif defined TARGET_ANDROID - return string("sdcard/"); - #else + #elif defined TARGET_ANDROID + return string("sdcard/"); + #else return (ofFilePath::getCurrentExeDir() / of::filesystem::path("data/")).string(); - #endif - } + #endif + } - //-------------------------------------------------- - of::filesystem::path & defaultWorkingDirectory(){ - static auto * defaultWorkingDirectory = new of::filesystem::path(ofFilePath::getCurrentExeDir()); - return * defaultWorkingDirectory; - } + //-------------------------------------------------- + of::filesystem::path & defaultWorkingDirectory(){ + static auto * defaultWorkingDirectory = new of::filesystem::path(ofFilePath::getCurrentExeDir()); + return * defaultWorkingDirectory; + } - //-------------------------------------------------- - of::filesystem::path & dataPathRoot(){ - static auto * dataPathRoot = new of::filesystem::path(defaultDataPath()); - return *dataPathRoot; - } + //-------------------------------------------------- + of::filesystem::path & dataPathRoot(){ + static auto * dataPathRoot = new of::filesystem::path(defaultDataPath()); + return *dataPathRoot; + } } namespace of{ - namespace priv{ - void initfileutils(){ - defaultWorkingDirectory() = of::filesystem::absolute(of::filesystem::current_path()); - } - } + namespace priv{ + void initfileutils(){ + defaultWorkingDirectory() = of::filesystem::absolute(of::filesystem::current_path()); + } + } } @@ -599,11 +599,11 @@ bool ofFile::create(const of::filesystem::path & path){ auto oldpath = this->path(); success = open(path,ofFile::WriteOnly,binary); close(); - + if( !oldpath.empty() ){ open(oldpath,oldmode,binary); } - + return success; } @@ -817,21 +817,21 @@ bool ofFile::isHidden() const { void ofFile::setWriteable(bool flag){ try{ #if !OF_USING_STD_FS || (OF_USING_STD_FS && OF_USE_EXPERIMENTAL_FS) - if(flag){ - of::filesystem::permissions(myFile,of::filesystem::perms::owner_write | of::filesystem::perms::add_perms); - }else{ - of::filesystem::permissions(myFile,of::filesystem::perms::owner_write | of::filesystem::perms::remove_perms); - } + if(flag){ + of::filesystem::permissions(myFile,of::filesystem::perms::owner_write | of::filesystem::perms::add_perms); + }else{ + of::filesystem::permissions(myFile,of::filesystem::perms::owner_write | of::filesystem::perms::remove_perms); + } #else - if(flag){ - of::filesystem::permissions(myFile, - of::filesystem::perms::owner_write, - of::filesystem::perm_options::add); - }else{ - of::filesystem::permissions(myFile, - of::filesystem::perms::owner_write, - of::filesystem::perm_options::remove); - } + if(flag){ + of::filesystem::permissions(myFile, + of::filesystem::perms::owner_write, + of::filesystem::perm_options::add); + }else{ + of::filesystem::permissions(myFile, + of::filesystem::perms::owner_write, + of::filesystem::perm_options::remove); + } #endif }catch(std::exception & e){ ofLogError() << "Couldn't set write permission on " << myFile << ": " << e.what(); @@ -848,21 +848,21 @@ void ofFile::setReadOnly(bool flag){ void ofFile::setReadable(bool flag){ try{ #if !OF_USING_STD_FS || (OF_USING_STD_FS && OF_USE_EXPERIMENTAL_FS) - if(flag){ - of::filesystem::permissions(myFile,of::filesystem::perms::owner_read | of::filesystem::perms::add_perms); - }else{ - of::filesystem::permissions(myFile,of::filesystem::perms::owner_read | of::filesystem::perms::remove_perms); - } + if(flag){ + of::filesystem::permissions(myFile,of::filesystem::perms::owner_read | of::filesystem::perms::add_perms); + }else{ + of::filesystem::permissions(myFile,of::filesystem::perms::owner_read | of::filesystem::perms::remove_perms); + } #else - if(flag){ - of::filesystem::permissions(myFile, - of::filesystem::perms::owner_read, - of::filesystem::perm_options::add); - }else{ - of::filesystem::permissions(myFile, - of::filesystem::perms::owner_read, - of::filesystem::perm_options::remove); - } + if(flag){ + of::filesystem::permissions(myFile, + of::filesystem::perms::owner_read, + of::filesystem::perm_options::add); + }else{ + of::filesystem::permissions(myFile, + of::filesystem::perms::owner_read, + of::filesystem::perm_options::remove); + } #endif }catch(std::exception & e){ ofLogError() << "Couldn't set read permission on " << myFile << ": " << e.what(); @@ -874,21 +874,21 @@ void ofFile::setExecutable(bool flag){ try{ #if OF_USING_STD_FS # if OF_USE_EXPERIMENTAL_FS - if(flag){ - of::filesystem::permissions(myFile, of::filesystem::perms::owner_exec | of::filesystem::perms::add_perms); - } else{ - of::filesystem::permissions(myFile, of::filesystem::perms::owner_exec | of::filesystem::perms::remove_perms); - } + if(flag){ + of::filesystem::permissions(myFile, of::filesystem::perms::owner_exec | of::filesystem::perms::add_perms); + } else{ + of::filesystem::permissions(myFile, of::filesystem::perms::owner_exec | of::filesystem::perms::remove_perms); + } # else - if(flag){ - of::filesystem::permissions(myFile, - of::filesystem::perms::owner_exec, - of::filesystem::perm_options::add); - } else{ - of::filesystem::permissions(myFile, - of::filesystem::perms::owner_exec, - of::filesystem::perm_options::remove); - } + if(flag){ + of::filesystem::permissions(myFile, + of::filesystem::perms::owner_exec, + of::filesystem::perm_options::add); + } else{ + of::filesystem::permissions(myFile, + of::filesystem::perms::owner_exec, + of::filesystem::perm_options::remove); + } # endif #else if(flag){ @@ -925,7 +925,7 @@ bool ofFile::copyTo(const of::filesystem::path& _path, bool bRelativeToData, boo if(bRelativeToData){ path = ofToDataPath(path); } - + if(ofFile::doesFileExist(path, false)){ if(isFile()){ ofFile tmp; @@ -976,7 +976,7 @@ bool ofFile::moveTo(const of::filesystem::path& _path, bool bRelativeToData, boo path = ofToDataPath(path); } if(ofFile::doesFileExist(path, false)){ - + if(isFile()){ ofFile tmp; tmp.openFromCWD(path,ofFile::Reference); @@ -1306,11 +1306,11 @@ bool ofDirectory::copyTo(const of::filesystem::path& _path, bool bRelativeToData } } - //our path is bRelativeToData handled from above - so can't open via the constructor approach + //our path is bRelativeToData handled from above - so can't open via the constructor approach ofDirectory dir; dir.openFromCWD(path); dir.create(true); - + // Iterate through the source directory for(of::filesystem::directory_iterator file(myDir); file != of::filesystem::directory_iterator(); ++file){ auto currentPath = of::filesystem::absolute(file->path()); @@ -1336,7 +1336,7 @@ bool ofDirectory::moveTo(const of::filesystem::path& path, bool bRelativeToData, if(copyTo(path,bRelativeToData,overwrite)){ return remove(true); } - + return false; } @@ -1390,7 +1390,7 @@ std::size_t ofDirectory::listDir(){ ofLogError("ofDirectory") << "listDir:() source directory does not exist: \"" << myDir << "\""; return 0; } - + of::filesystem::directory_iterator end_iter; if ( of::filesystem::exists(myDir) && of::filesystem::is_directory(myDir)){ for( of::filesystem::directory_iterator dir_iter(myDir) ; dir_iter != end_iter ; ++dir_iter){ @@ -1412,7 +1412,7 @@ std::size_t ofDirectory::listDir(){ ofRemove(files, [&](ofFile & file){ return std::find(extensions.begin(), extensions.end(), ofToLower(file.getExtension())) == extensions.end(); }); - } + } if(ofGetLogLevel() == OF_LOG_VERBOSE){ for(int i = 0; i < (int)size(); i++){ @@ -1534,7 +1534,7 @@ bool ofDirectory::removeDirectory(const of::filesystem::path& _path, bool delete }else{ dirToRemove.openFromCWD(path,ofFile::Reference); } - + return dirToRemove.remove(deleteIfNotEmpty); } @@ -1545,15 +1545,15 @@ bool ofDirectory::createDirectory(const of::filesystem::path& _dirPath, bool bRe if(bRelativeToData){ dirPath = ofToDataPath(dirPath); } - + // on OSX,of::filesystem::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: - + bool bDoesExistAlready = ofDirectory::doesDirectoryExist(dirPath,false); - + if (!bDoesExistAlready){ - + bool success = false; try{ if(!recursive){ @@ -1567,7 +1567,7 @@ bool ofDirectory::createDirectory(const of::filesystem::path& _dirPath, bool bRe } return success; } - + // no need to create it - it already exists. return true; } @@ -1660,7 +1660,7 @@ vector::const_reverse_iterator ofDirectory::rend() const{ //------------------------------------------------------------------------------------------------------------ string ofFilePath::addLeadingSlash(const of::filesystem::path& _path){ - auto path = _path.string(); + auto path = _path.string(); auto sep = of::filesystem::path("/").make_preferred(); if(!path.empty()){ if(ofToString(path[0]) != sep.string()){ @@ -1675,12 +1675,12 @@ string ofFilePath::addLeadingSlash(const of::filesystem::path& _path){ //of::filesystem::path ofFilePath::addTrailingSlash(const of::filesystem::path & _path){ std::string ofFilePath::addTrailingSlash(const of::filesystem::path & _path){ #if OF_USING_STD_FS && !OF_USE_EXPERIMENTAL_FS - if(_path.string().empty()) return ""; + if(_path.string().empty()) return ""; // FIXME: Remove .string() here and following - // return (of::filesystem::path(_path).make_preferred() / ""); - return (of::filesystem::path(_path).make_preferred() / "").string(); + // return (of::filesystem::path(_path).make_preferred() / ""); + return (of::filesystem::path(_path).make_preferred() / "").string(); #else - auto path = of::filesystem::path(_path).make_preferred(); + auto path = of::filesystem::path(_path).make_preferred(); auto sep = of::filesystem::path("/").make_preferred(); if(!path.empty()){ if(ofToString(path.string().back()) != sep.string()){ @@ -1713,27 +1713,27 @@ string ofFilePath::getPathForDirectory(const of::filesystem::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 "/" - + // FIXME: Remove .string() here and following // FIXME: this seems over complicated and not useful anymore, using filesystem #if OF_USING_STD_FS && !OF_USE_EXPERIMENTAL_FS - if(path.string().empty()) return ""; - return (path / "").string(); + if(path.string().empty()) return ""; + return (path / "").string(); #else - auto sep = of::filesystem::path("/").make_preferred(); - if(!path.empty() && ofToString(path.string().back())!=sep.string()){ - return (path / sep).string(); - }else{ - return path.string(); - } + auto sep = of::filesystem::path("/").make_preferred(); + if(!path.empty() && ofToString(path.string().back())!=sep.string()){ + return (path / sep).string(); + }else{ + return path.string(); + } #endif } //------------------------------------------------------------------------------------------------------------ // FIXME: convert to of::filesystem::path string ofFilePath::removeTrailingSlash(const of::filesystem::path& _path){ - auto path = _path.string(); + auto path = _path.string(); if(path.length() > 0 && (path[path.length() - 1] == '/' || path[path.length() - 1] == '\\')){ path = path.substr(0, path.length() - 1); } @@ -1756,7 +1756,7 @@ string ofFilePath::getFileName(const of::filesystem::path& _filePath, bool bRela //------------------------------------------------------------------------------------------------------------ string ofFilePath::getBaseName(const of::filesystem::path& filePath){ - // FIXME: is this still useful? + // FIXME: is this still useful? return ofFile(filePath,ofFile::Reference).getBaseName(); } @@ -1895,123 +1895,123 @@ std::string ofFilePath::makeRelative(const of::filesystem::path & from, const of //-------------------------------------------------- void ofEnableDataPath(){ - enableDataPath = true; + enableDataPath = true; } //-------------------------------------------------- void ofDisableDataPath(){ - enableDataPath = false; + enableDataPath = false; } //-------------------------------------------------- bool ofRestoreWorkingDirectoryToDefault(){ - try{ - of::filesystem::current_path(defaultWorkingDirectory()); - return true; - }catch(...){ - return false; - } + try{ + of::filesystem::current_path(defaultWorkingDirectory()); + return true; + }catch(...){ + return false; + } } //-------------------------------------------------- void ofSetDataPathRoot(const of::filesystem::path& newRoot){ - dataPathRoot() = newRoot; + dataPathRoot() = newRoot; } //-------------------------------------------------- // MARK: - near future //of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool makeAbsolute){ std::string ofToDataPath(const of::filesystem::path & path, bool makeAbsolute){ - if (makeAbsolute && path.is_absolute()) { + if (makeAbsolute && path.is_absolute()) { // MARK: need to convert to string? or automatic? // return path; return path.string(); - } - - if (!enableDataPath) { + } + + if (!enableDataPath) { // MARK: need to convert to string? or automatic? // return path; return path.string(); - } + } - bool hasTrailingSlash = !path.empty() && path.generic_string().back()=='/'; + bool hasTrailingSlash = !path.empty() && path.generic_string().back()=='/'; - // if our Current Working Directory has changed (e.g. file open dialog) + // if our Current Working Directory has changed (e.g. file open dialog) #ifdef TARGET_WIN32 - if (defaultWorkingDirectory() != of::filesystem::current_path()) { - // change our cwd back to where it was on app load - bool ret = ofRestoreWorkingDirectoryToDefault(); - if(!ret){ - ofLogWarning("ofUtils") << "ofToDataPath: error while trying to change back to default working directory " << defaultWorkingDirectory(); - } - } + if (defaultWorkingDirectory() != of::filesystem::current_path()) { + // change our cwd back to where it was on app load + bool ret = ofRestoreWorkingDirectoryToDefault(); + if(!ret){ + ofLogWarning("ofUtils") << "ofToDataPath: error while trying to change back to default working directory " << defaultWorkingDirectory(); + } + } #endif - // 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(); - of::filesystem::path inputPath(path); - of::filesystem::path outputPath; + // 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(); + of::filesystem::path inputPath(path); + of::filesystem::path outputPath; - // if path is already absolute, just return it - if (inputPath.is_absolute()) { - try { - auto outpath = of::filesystem::canonical(inputPath).make_preferred(); - if(of::filesystem::is_directory(outpath) && hasTrailingSlash){ + // if path is already absolute, just return it + if (inputPath.is_absolute()) { + try { + auto outpath = of::filesystem::canonical(inputPath).make_preferred(); + if(of::filesystem::is_directory(outpath) && hasTrailingSlash){ return ofFilePath::addTrailingSlash(outpath); - }else{ -// return outpath.string(); - return outpath; - } - } - catch (...) { + }else{ + return outpath.string(); + // return outpath; + } + } + catch (...) { // return inputPath.string(); - return inputPath; - } - } + return inputPath; + } + } - // here we check whether path already refers to the data folder by looking for common elements - // if the path begins with the full contents of dataPathRoot then the data path has already been added - // we compare inputPath.toString() rather that the input var path to ensure common formatting against dataPath.toString() + // here we check whether path already refers to the data folder by looking for common elements + // if the path begins with the full contents of dataPathRoot then the data path has already been added + // we compare inputPath.toString() rather that the input var path to ensure common formatting against dataPath.toString() auto dirDataPath = dataPath; - // 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(dataPath); + // 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(dataPath); - auto relativeDirDataPath = ofFilePath::makeRelative(of::filesystem::current_path(), dataPath); - relativeDirDataPath = ofFilePath::addTrailingSlash(relativeDirDataPath); + auto relativeDirDataPath = ofFilePath::makeRelative(of::filesystem::current_path(), dataPath); + relativeDirDataPath = ofFilePath::addTrailingSlash(relativeDirDataPath); // FIXME: this can be simplified without using string conversion - // if (inputPath.string().find(dirDataPath.string()) != 0 && inputPath.string().find(relativeDirDataPath.string())!=0) { - if (inputPath.string().find(dirDataPath.string()) != 0 && inputPath.string().find(relativeDirDataPath)!=0) { - // inputPath doesn't contain data path already, so we build the output path as the inputPath relative to the dataPath - if(makeAbsolute){ - outputPath = dirDataPath / inputPath; - }else{ - outputPath = relativeDirDataPath / inputPath; - } - } else { - // inputPath already contains data path, so no need to change - outputPath = inputPath; - } - - // finally, if we do want an absolute path and we don't already have one - if(makeAbsolute){ - // then we return the absolute form of the path - try { - auto outpath = of::filesystem::canonical(of::filesystem::absolute(outputPath)).make_preferred(); - if(of::filesystem::is_directory(outpath) && hasTrailingSlash){ - return ofFilePath::addTrailingSlash(outpath); - }else{ + // if (inputPath.string().find(dirDataPath.string()) != 0 && inputPath.string().find(relativeDirDataPath.string())!=0) { + if (inputPath.string().find(dirDataPath.string()) != 0 && inputPath.string().find(relativeDirDataPath)!=0) { + // inputPath doesn't contain data path already, so we build the output path as the inputPath relative to the dataPath + if(makeAbsolute){ + outputPath = dirDataPath / inputPath; + }else{ + outputPath = relativeDirDataPath / inputPath; + } + } else { + // inputPath already contains data path, so no need to change + outputPath = inputPath; + } + + // finally, if we do want an absolute path and we don't already have one + if(makeAbsolute){ + // then we return the absolute form of the path + try { + auto outpath = of::filesystem::canonical(of::filesystem::absolute(outputPath)).make_preferred(); + if(of::filesystem::is_directory(outpath) && hasTrailingSlash){ + return ofFilePath::addTrailingSlash(outpath); + }else{ // return outpath; - return outpath.string(); - } - } - catch (std::exception &) { -// return of::filesystem::absolute(outputPath).string(); - return of::filesystem::absolute(outputPath); - } - }else{ - // or output the relative path + return outpath.string(); + } + } + catch (std::exception &) { + return of::filesystem::absolute(outputPath).string(); + // return of::filesystem::absolute(outputPath); + } + }else{ + // or output the relative path // return outputPath; return outputPath.string(); - } + } } diff --git a/libs/openFrameworks/utils/ofSystemUtils.cpp b/libs/openFrameworks/utils/ofSystemUtils.cpp index eca04858f00..4aa7f510b41 100644 --- a/libs/openFrameworks/utils/ofSystemUtils.cpp +++ b/libs/openFrameworks/utils/ofSystemUtils.cpp @@ -488,8 +488,10 @@ ofFileDialogResult ofSystemLoadDialog(std::string windowTitle, bool bFolderSelec //---------------------------------------------------------------------------------------- #if defined( TARGET_LINUX ) && defined (OF_USING_GTK) auto locale = std::locale(); - if(bFolderSelection) results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,windowTitle,ofToDataPath(defaultPath).string()); - else results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_OPEN,windowTitle,ofToDataPath(defaultPath).string()); + if(bFolderSelection) + results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, windowTitle, ofToDataPath(defaultPath).c_str()); + else + results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_OPEN, windowTitle, ofToDataPath(defaultPath).c_str()); resetLocale(locale); #endif //---------------------------------------------------------------------------------------- From 376211ecf639a34cc5487adc6c8c24f279bcdf5e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 5 Mar 2023 23:22:39 -0300 Subject: [PATCH 86/91] fix issues --- libs/openFrameworks/graphics/ofTrueTypeFont.cpp | 2 +- libs/openFrameworks/utils/ofFileUtils.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp index baa9d58ea7c..14ef414c850 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp @@ -415,7 +415,7 @@ static bool loadFontFace(const of::filesystem::path& _fontname, FT_Face & face, ofLogVerbose("ofTrueTypeFont") << "loadFontFace(): \"" << fontname << "\" not a file in data loading system font from \"" << filename << "\""; } FT_Error err; - err = FT_New_Face( library, filename.c_str(), fontID, &face ); + err = FT_New_Face( library, filename.string().c_str(), fontID, &face ); if (err) { // simple error table in lieu of full table (see fterrors.h) string errorString = "unknown freetype"; diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index ae1523ff473..0859879ab0f 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -1964,8 +1964,8 @@ std::string ofToDataPath(const of::filesystem::path & path, bool makeAbsolute){ } } catch (...) { -// return inputPath.string(); - return inputPath; + return inputPath.string(); + // return inputPath; } } From d2d874ee1afb8b23f1092501edcba1337f292020 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 5 Mar 2023 23:46:36 -0300 Subject: [PATCH 87/91] more fixes --- addons/ofxSvg/src/ofxSvg.cpp | 22 ++++++++++++++----- .../sound/ofOpenALSoundPlayer.cpp | 8 +++---- libs/openFrameworks/utils/ofSystemUtils.cpp | 3 ++- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/addons/ofxSvg/src/ofxSvg.cpp b/addons/ofxSvg/src/ofxSvg.cpp index d34d62ff6c3..d2df34fb83b 100644 --- a/addons/ofxSvg/src/ofxSvg.cpp +++ b/addons/ofxSvg/src/ofxSvg.cpp @@ -28,19 +28,29 @@ ofPath & ofxSvg::getPathAt(int n){ } void ofxSvg::load(of::filesystem::path fileName){ - fileName = ofToDataPath(fileName); + // fileName = ofToDataPath(fileName); + std::string file = ofToDataPath(fileName); // FIXME: I think this is the equivalent of .empty() which is simpler. // maybe use file exists to check instead? - if(fileName.compare("") == 0){ - ofLogError("ofxSVG") << "load(): path does not exist: \"" << fileName << "\""; + // if(fileName.compare("") == 0){ + // ofLogError("ofxSVG") << "load(): path does not exist: \"" << fileName << "\""; + // return; + // } + + // ofBuffer buffer = ofBufferFromFile(fileName); + + // loadFromString(buffer.getText(), fileName); + + if(file.compare("") == 0){ + ofLogError("ofxSVG") << "load(): path does not exist: \"" << file << "\""; return; } - ofBuffer buffer = ofBufferFromFile(fileName); - - loadFromString(buffer.getText(), fileName); + ofBuffer buffer = ofBufferFromFile(file); + loadFromString(buffer.getText(), file); + } void ofxSvg::loadFromString(std::string stringdata, std::string urlstring){ diff --git a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp index 7589b334802..8dca8913cbb 100644 --- a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp @@ -231,7 +231,7 @@ void ofOpenALSoundPlayer::close(){ // ---------------------------------------------------------------------------- bool ofOpenALSoundPlayer::sfReadFile(const of::filesystem::path& path, std::vector & buffer, std::vector & fftAuxBuffer){ SF_INFO sfInfo; - SNDFILE* f = sf_open(path.c_str(),SFM_READ,&sfInfo); + SNDFILE* f = sf_open(path.string().c_str(),SFM_READ,&sfInfo); if(!f){ ofLogError("ofOpenALSoundPlayer") << "sfReadFile(): couldn't read \"" << path << "\""; return false; @@ -286,7 +286,7 @@ bool ofOpenALSoundPlayer::sfReadFile(const of::filesystem::path& path, std::vect bool ofOpenALSoundPlayer::mpg123ReadFile(const of::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer){ int err = MPG123_OK; mpg123_handle * f = mpg123_new(nullptr,&err); - if(mpg123_open(f,path.c_str())!=MPG123_OK){ + if(mpg123_open(f,path.string().c_str())!=MPG123_OK){ ofLogError("ofOpenALSoundPlayer") << "mpg123ReadFile(): couldn't read \"" << path << "\""; return false; } @@ -324,7 +324,7 @@ bool ofOpenALSoundPlayer::mpg123ReadFile(const of::filesystem::path& path,std::v bool ofOpenALSoundPlayer::sfStream(const of::filesystem::path& path,std::vector & buffer,std::vector & fftAuxBuffer){ if(!streamf){ SF_INFO sfInfo; - streamf = sf_open(path.c_str(),SFM_READ,&sfInfo); + streamf = sf_open(path.string().c_str(),SFM_READ,&sfInfo); if(!streamf){ ofLogError("ofOpenALSoundPlayer") << "sfStream(): couldn't read \"" << path << "\""; return false; @@ -388,7 +388,7 @@ bool ofOpenALSoundPlayer::mpg123Stream(const of::filesystem::path& path,std::vec if(!mp3streamf){ int err = MPG123_OK; mp3streamf = mpg123_new(nullptr,&err); - if(mpg123_open(mp3streamf,path.c_str())!=MPG123_OK){ + if(mpg123_open(mp3streamf,path.string().c_str())!=MPG123_OK){ mpg123_close(mp3streamf); mpg123_delete(mp3streamf); ofLogError("ofOpenALSoundPlayer") << "mpg123Stream(): couldn't read \"" << path << "\""; diff --git a/libs/openFrameworks/utils/ofSystemUtils.cpp b/libs/openFrameworks/utils/ofSystemUtils.cpp index 4aa7f510b41..fd0612c9116 100644 --- a/libs/openFrameworks/utils/ofSystemUtils.cpp +++ b/libs/openFrameworks/utils/ofSystemUtils.cpp @@ -573,7 +573,8 @@ ofFileDialogResult ofSystemSaveDialog(std::string defaultName, std::string messa //---------------------------------------------------------------------------------------- #if defined( TARGET_LINUX ) && defined (OF_USING_GTK) auto locale = std::locale(); - results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_SAVE, messageName, ofToDataPath(defaultName).string()); + // results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_SAVE, messageName, ofToDataPath(defaultName).string()); + results.filePath = gtkFileDialog(GTK_FILE_CHOOSER_ACTION_SAVE, messageName, ofToDataPath(defaultName)); resetLocale(locale); #endif //---------------------------------------------------------------------------------------- From bb9558e001f52c2eb946b835c7a0a2527c72fd1a Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 6 Mar 2023 00:03:29 -0300 Subject: [PATCH 88/91] tests fix --- tests/utils/fileUtils/src/main.cpp | 63 ++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/tests/utils/fileUtils/src/main.cpp b/tests/utils/fileUtils/src/main.cpp index 6f27ca022ec..9f958f07564 100644 --- a/tests/utils/fileUtils/src/main.cpp +++ b/tests/utils/fileUtils/src/main.cpp @@ -180,9 +180,11 @@ class ofApp: public ofxUnitTestsApp{ ofxTestEq(ofFilePath::getBaseName("test/test.txt"),"test","ofFilePath::getBaseName",ofFilePath::getBaseName("test/test.txt")); ofxTestEq(ofFilePath::getBaseName(ofFilePath::removeTrailingSlash(ofFilePath::getEnclosingDirectory("testdir/test.txt"))),"testdir","ofFilePath::getEnclosingDirectory",ofFilePath::getBaseName(ofFilePath::getEnclosingDirectory("testdir/test.txt"))); #ifdef TARGET_WIN32 - ofxTestEq(ofFilePath::join("d1","d2").string(),"d1\\d2","ofFilePath::join",ofFilePath::join("d1","d2").string()); + // ofxTestEq(ofFilePath::join("d1","d2").string(),"d1\\d2","ofFilePath::join",ofFilePath::join("d1","d2").string()); + ofxTestEq(ofFilePath::join("d1","d2"),"d1\\d2","ofFilePath::join",ofFilePath::join("d1","d2")); #else - ofxTestEq(ofFilePath::join("d1","d2").string(),"d1/d2","ofFilePath::join",ofFilePath::join("d1","d2").string()); + // ofxTestEq(ofFilePath::join("d1","d2").string(),"d1/d2","ofFilePath::join",ofFilePath::join("d1","d2").string()); + ofxTestEq(ofFilePath::join("d1","d2"),"d1/d2","ofFilePath::join",ofFilePath::join("d1","d2")); #endif ofxTest(of::filesystem::exists(ofFile("test.txt")), "ofFile cast to filesystem::path"); @@ -218,39 +220,58 @@ class ofApp: public ofxUnitTestsApp{ ofLogNotice() << ""; ofLogNotice() << "tests #4462"; if(ofGetTargetPlatform()==OF_TARGET_WINVS || ofGetTargetPlatform()==OF_TARGET_MINGW){ - ofxTestEq(ofToDataPath("movies\\",true).string().back(), '\\', "absolute ofToDataPath with \\ should end in \\"); - ofxTestEq(ofToDataPath("movies",true).string().back(), 's', "absolute ofToDataPath without \\ should not end in \\"); + // ofxTestEq(ofToDataPath("movies\\",true).string().back(), '\\', "absolute ofToDataPath with \\ should end in \\"); + // ofxTestEq(ofToDataPath("movies",true).string().back(), 's', "absolute ofToDataPath without \\ should not end in \\"); + // ofDirectory("movies").create(); + // ofxTestEq(ofToDataPath("movies\\",true).string().back(), '\\', "absolute ofToDataPath with \\ should end in \\"); + // ofxTestEq(ofToDataPath("movies",true).string().back(), 's', "absolute ofToDataPath without \\ should not end in \\"); + ofxTestEq(ofToDataPath("movies\\",true).back(), '\\', "absolute ofToDataPath with \\ should end in \\"); + ofxTestEq(ofToDataPath("movies",true).back(), 's', "absolute ofToDataPath without \\ should not end in \\"); ofDirectory("movies").create(); - ofxTestEq(ofToDataPath("movies\\",true).string().back(), '\\', "absolute ofToDataPath with \\ should end in \\"); - ofxTestEq(ofToDataPath("movies",true).string().back(), 's', "absolute ofToDataPath without \\ should not end in \\"); + ofxTestEq(ofToDataPath("movies\\",true).back(), '\\', "absolute ofToDataPath with \\ should end in \\"); + ofxTestEq(ofToDataPath("movies",true).back(), 's', "absolute ofToDataPath without \\ should not end in \\"); }else{ - ofxTestEq(ofToDataPath("movies/",true).string().back(), '/', "absolute ofToDataPath with / should end in /"); - ofxTestEq(ofToDataPath("movies",true).string().back(), 's', "absolute ofToDataPath without / should not end in /"); + // ofxTestEq(ofToDataPath("movies/",true).string().back(), '/', "absolute ofToDataPath with / should end in /"); + // ofxTestEq(ofToDataPath("movies",true).string().back(), 's', "absolute ofToDataPath without / should not end in /"); + // ofDirectory("movies").create(); + // ofxTestEq(ofToDataPath("movies/",true).string().back(), '/', "absolute ofToDataPath with / should end in /"); + // ofxTestEq(ofToDataPath("movies",true).string().back(), 's', "absolute ofToDataPath without / should not end in /"); + ofxTestEq(ofToDataPath("movies/",true).back(), '/', "absolute ofToDataPath with / should end in /"); + ofxTestEq(ofToDataPath("movies",true).back(), 's', "absolute ofToDataPath without / should not end in /"); ofDirectory("movies").create(); - ofxTestEq(ofToDataPath("movies/",true).string().back(), '/', "absolute ofToDataPath with / should end in /"); - ofxTestEq(ofToDataPath("movies",true).string().back(), 's', "absolute ofToDataPath without / should not end in /"); + ofxTestEq(ofToDataPath("movies/",true).back(), '/', "absolute ofToDataPath with / should end in /"); + ofxTestEq(ofToDataPath("movies",true).back(), 's', "absolute ofToDataPath without / should not end in /"); } //======================================================================== ofLogNotice() << ""; ofLogNotice() << "tests #4598"; - ofxTestEq(ofToDataPath("").string().back(), of::filesystem::path::preferred_separator, "ofToDataPath with empty string shouldn't crash"); + // ofxTestEq(ofToDataPath("").string().back(), of::filesystem::path::preferred_separator, "ofToDataPath with empty string shouldn't crash"); + ofxTestEq(ofToDataPath("").back(), of::filesystem::path::preferred_separator, "ofToDataPath with empty string shouldn't crash"); //======================================================================== ofLogNotice() << ""; ofLogNotice() << "tests #4563"; +// #ifdef TARGET_LINUX +// ofxTestEq(ofToDataPath("a.txt").string(), "data/a.txt","#4563 test1"); +// ofxTestEq(ofToDataPath("data.txt").string(), "data/data.txt", "#4563 test2"); +// ofxTestEq(ofToDataPath("").string(), "data/", "#4563 test3"); +// #elif defined(TARGET_OSX) +// ofxTestEq(ofToDataPath("a.txt").string(), "../../../data/a.txt","#4563 test1"); +// ofxTestEq(ofToDataPath("data.txt").string(), "../../../data/data.txt", "#4563 test2"); +// ofxTestEq(ofToDataPath("").string(), "../../../data/", "#4563 test3"); +// #endif #ifdef TARGET_LINUX - ofxTestEq(ofToDataPath("a.txt").string(), "data/a.txt","#4563 test1"); - ofxTestEq(ofToDataPath("data.txt").string(), "data/data.txt", "#4563 test2"); - ofxTestEq(ofToDataPath("").string(), "data/", "#4563 test3"); + ofxTestEq(ofToDataPath("a.txt"), "data/a.txt","#4563 test1"); + ofxTestEq(ofToDataPath("data.txt"), "data/data.txt", "#4563 test2"); + ofxTestEq(ofToDataPath(""), "data/", "#4563 test3"); #elif defined(TARGET_OSX) - ofxTestEq(ofToDataPath("a.txt").string(), "../../../data/a.txt","#4563 test1"); - ofxTestEq(ofToDataPath("data.txt").string(), "../../../data/data.txt", "#4563 test2"); - ofxTestEq(ofToDataPath("").string(), "../../../data/", "#4563 test3"); + ofxTestEq(ofToDataPath("a.txt"), "../../../data/a.txt","#4563 test1"); + ofxTestEq(ofToDataPath("data.txt"), "../../../data/data.txt", "#4563 test2"); + ofxTestEq(ofToDataPath(""), "../../../data/", "#4563 test3"); #endif - //======================================================================== // clean test files dir.open("."); @@ -268,12 +289,14 @@ class ofApp: public ofxUnitTestsApp{ dir.remove(true); if(ofGetTargetPlatform()==OF_TARGET_WINVS || ofGetTargetPlatform()==OF_TARGET_MINGW){ ofDirectory currentVideoDirectory(ofToDataPath("..\\..\\..\\video", true)); - auto path = currentVideoDirectory.path().string(); + // auto path = currentVideoDirectory.path().string(); + auto path = currentVideoDirectory.path(); std::string pathEnd("data\\..\\..\\..\\video\\"); ofxTestEq(path.substr(path.size()-pathEnd.size()), pathEnd, "#4564"); }else{ ofDirectory currentVideoDirectory(ofToDataPath("../../../video", true)); - auto path = currentVideoDirectory.path().string(); + // auto path = currentVideoDirectory.path().string(); + auto path = currentVideoDirectory.path(); std::string pathEnd("data/../../../video/"); ofxTestEq(path.substr(path.size()-pathEnd.size()), pathEnd, "#4564"); } From 70c2fa98f2ed63a3c4c123ef3c52ef99daff2a96 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 6 Mar 2023 21:23:36 -0300 Subject: [PATCH 89/91] try catch --- libs/openFrameworks/utils/ofFileUtils.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 0859879ab0f..7e81a77de4b 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -30,7 +30,11 @@ namespace{ // of::filesystem::path defaultDataPath(){ std::string defaultDataPath(){ #if defined TARGET_OSX - return (ofFilePath::getCurrentExeDir() / of::filesystem::path("../../../data/")).string(); + try{ + return of::filesystem::canonical(ofFilePath::getCurrentExeDir() / of::filesystem::path("../../../data/")).string(); + }catch(...){ + return (ofFilePath::getCurrentExeDir() / of::filesystem::path("../../../data/")).string(); + } #elif defined TARGET_ANDROID return string("sdcard/"); #else From fa895ae74fd42d59f3dd6e87c59099a00bbf6a66 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 6 Mar 2023 21:57:26 -0300 Subject: [PATCH 90/91] try catch in #else --- libs/openFrameworks/utils/ofFileUtils.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 7e81a77de4b..be6f60e121e 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -38,20 +38,24 @@ namespace{ #elif defined TARGET_ANDROID return string("sdcard/"); #else - return (ofFilePath::getCurrentExeDir() / of::filesystem::path("data/")).string(); + try{ + return std::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); + }catch(...){ + return (ofFilePath::getCurrentExeDir() / of::filesystem::path("data/")).string(); + } #endif } //-------------------------------------------------- of::filesystem::path & defaultWorkingDirectory(){ - static auto * defaultWorkingDirectory = new of::filesystem::path(ofFilePath::getCurrentExeDir()); - return * defaultWorkingDirectory; + static auto * defaultWorkingDirectory = new of::filesystem::path(ofFilePath::getCurrentExeDir()); + return * defaultWorkingDirectory; } //-------------------------------------------------- of::filesystem::path & dataPathRoot(){ - static auto * dataPathRoot = new of::filesystem::path(defaultDataPath()); - return *dataPathRoot; + static auto * dataPathRoot = new of::filesystem::path(defaultDataPath()); + return *dataPathRoot; } } @@ -1927,13 +1931,11 @@ void ofSetDataPathRoot(const of::filesystem::path& newRoot){ //of::filesystem::path ofToDataPath(const of::filesystem::path & path, bool makeAbsolute){ std::string ofToDataPath(const of::filesystem::path & path, bool makeAbsolute){ if (makeAbsolute && path.is_absolute()) { - // MARK: need to convert to string? or automatic? -// return path; +// return path; return path.string(); } if (!enableDataPath) { - // MARK: need to convert to string? or automatic? // return path; return path.string(); } From 76ef977ab512bd3f98f53d7ee12e25c30f07a3f2 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 6 Mar 2023 22:17:21 -0300 Subject: [PATCH 91/91] typo --- libs/openFrameworks/utils/ofFileUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index be6f60e121e..6e855e53311 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -39,7 +39,7 @@ namespace{ return string("sdcard/"); #else try{ - return std::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); + return of::filesystem::canonical(ofFilePath::join(ofFilePath::getCurrentExeDir(), "data/")).make_preferred().string(); }catch(...){ return (ofFilePath::getCurrentExeDir() / of::filesystem::path("data/")).string(); }