Skip to content

Commit 5dd623d

Browse files
authored
of::filesystem PR (#7110)
#changelog #utils
1 parent edb72bd commit 5dd623d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+738
-589
lines changed

addons/ofxAndroid/src/ofAppAndroidWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ Java_cc_openframeworks_OFAndroid_setAppDataDir( JNIEnv* env, jobject thiz, jst
266266
jboolean iscopy;
267267
const char *mfile = env->GetStringUTFChars(data_dir, &iscopy);
268268
__android_log_print(ANDROID_LOG_INFO,"ofAppAndroidWindow",("setting app dir name to: \"" + string(mfile) + "\"").c_str());
269-
ofSetDataPathRoot(string(mfile)+"/");
269+
ofSetDataPathRoot({ string(mfile)+"/" });
270270
env->ReleaseStringUTFChars(data_dir, mfile);
271271
}
272272

addons/ofxAndroid/src/ofxAndroidSoundPlayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ofxAndroidSoundPlayer::~ofxAndroidSoundPlayer(){
4343

4444

4545
//------------------------------------------------------------
46-
bool ofxAndroidSoundPlayer::load(const std::filesystem::path& fileName, bool stream){
46+
bool ofxAndroidSoundPlayer::load(const of::filesystem::path& fileName, bool stream){
4747
if(!javaSoundPlayer){
4848
ofLogError("ofxAndroidSoundPlayer") << "loadSound(): java SoundPlayer not loaded";
4949
return false;

addons/ofxAndroid/src/ofxAndroidSoundPlayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ofxAndroidSoundPlayer: public ofBaseSoundPlayer{
88
ofxAndroidSoundPlayer();
99
virtual ~ofxAndroidSoundPlayer();
1010

11-
bool load(const std::filesystem::path& fileName, bool stream = false);
11+
bool load(const of::filesystem::path& fileName, bool stream = false);
1212
void unload();
1313
void play();
1414
void stop();

addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,20 +388,20 @@ void ofxAssimpModelLoader::loadGLResources(){
388388
auto ogPath = texPathStr;
389389
bool bHasEmbeddedTexture = false;
390390

391-
string modelFolder = ofFilePath::getEnclosingDirectory( file.path() );
392-
string relTexPath = ofFilePath::getEnclosingDirectory(texPathStr,false);
393-
string texFile = ofFilePath::getFileName(texPathStr);
394-
string realPath = ofFilePath::join(ofFilePath::join(modelFolder, relTexPath), texFile);
391+
auto modelFolder = ofFilePath::getEnclosingDirectory( file.path() );
392+
auto relTexPath = ofFilePath::getEnclosingDirectory(texPathStr,false);
393+
auto realPath = modelFolder / of::filesystem::path{ texPathStr };
394+
395395

396396
#ifndef TARGET_LINUX_ARM
397397
if(bTryEmbed || ofFile::doesFileExist(realPath) == false) {
398398
auto embeddedTexture = scene->GetEmbeddedTexture(ogPath.c_str());
399399
if( embeddedTexture ){
400400
bHasEmbeddedTexture = true;
401-
ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource() texture " << texFile << " is embedded ";
401+
ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource() texture " << realPath.filename() << " is embedded ";
402402
}else{
403403
ofLogError("ofxAssimpModelLoader") << "loadGLResource(): texture doesn't exist: \""
404-
<< file.getFileName() + "\" in \"" << realPath << "\"";
404+
<< file.getFileName() + "\" in \"" << realPath.string() << "\"";
405405
}
406406
}
407407
#endif
@@ -419,7 +419,7 @@ void ofxAssimpModelLoader::loadGLResources(){
419419
meshHelper.addTexture(assimpTexture);
420420

421421
ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource(): texture already loaded: \""
422-
<< file.getFileName() + "\" from \"" << realPath << "\"" << " adding texture as " << assimpTexture.getTextureTypeAsString() ;
422+
<< file.getFileName() + "\" from \"" << realPath.string() << "\"" << " adding texture as " << assimpTexture.getTextureTypeAsString() ;
423423
} else {
424424

425425
shared_ptr<ofTexture> texture = std::make_shared<ofTexture>();
@@ -463,7 +463,7 @@ void ofxAssimpModelLoader::loadGLResources(){
463463
ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource(): texture " << tmpTex.getTextureTypeAsString() << " loaded, dimensions: " << texture->getWidth() << "x" << texture->getHeight();
464464
}else{
465465
ofLogError("ofxAssimpModelLoader") << "loadGLResource(): couldn't load texture: \""
466-
<< file.getFileName() + "\" from \"" << realPath << "\"";
466+
<< file.getFileName() + "\" from \"" << realPath.string() << "\"";
467467
}
468468
}
469469
}

addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "ofxAssimpTexture.h"
2020
#include "ofMesh.h"
2121
#include "ofMath.h"
22+
#include "ofConstants.h"
2223

2324
#include <assimp/Importer.hpp>
2425

@@ -177,7 +178,10 @@ class ofxAssimpModelLoader{
177178
glm::mat4 modelMatrix;
178179

179180
std::vector<ofLight> lights;
180-
std::map<std::string,std::shared_ptr<ofTexture>> textures;
181+
std::map<
182+
of::filesystem::path,
183+
std::shared_ptr<ofTexture>
184+
> textures;
181185
std::vector<ofxAssimpMeshHelper> modelMeshes;
182186
std::vector<ofxAssimpAnimation> animations;
183187
int currentAnimation; // DEPRECATED - to be removed with deprecated animation functions.

addons/ofxAssimpModelLoader/src/ofxAssimpTexture.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "ofxAssimpTexture.h"
99
#include "ofLog.h"
1010

11-
void ofxAssimpTexture::setup(const ofTexture & texture, std::string texturePath, bool bTexRepeat) {
11+
void ofxAssimpTexture::setup(const ofTexture & texture, const of::filesystem::path & texturePath, bool bTexRepeat) {
1212
this->texture = texture;
1313
if( bTexRepeat ){
1414
this->texture.setTextureWrap(GL_REPEAT, GL_REPEAT);
@@ -42,7 +42,7 @@ ofTexture & ofxAssimpTexture::getTextureRef() {
4242
return texture;
4343
}
4444

45-
std::string ofxAssimpTexture::getTexturePath() {
45+
of::filesystem::path ofxAssimpTexture::getTexturePath() {
4646
return texturePath;
4747
}
4848

addons/ofxAssimpModelLoader/src/ofxAssimpTexture.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ class ofxAssimpTexture {
1414

1515
public:
1616

17-
void setup(const ofTexture & texture, std::string texturePath, bool bTexRepeat = true);
17+
void setup(const ofTexture & texture, const of::filesystem::path & texturePath, bool bTexRepeat = true);
1818

1919
ofTexture & getTextureRef();
20-
std::string getTexturePath();
20+
of::filesystem::path getTexturePath();
2121
bool hasTexture();
2222

2323
void setTextureType(aiTextureType aTexType);
@@ -27,7 +27,7 @@ class ofxAssimpTexture {
2727
private:
2828

2929
ofTexture texture;
30-
std::string texturePath;
30+
of::filesystem::path texturePath;
3131
aiTextureType textureType;
3232
std::string mTexTypeStr;
3333
};

addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ ofHttpResponse ofxEmscriptenURLFileLoader::get(const string & url){
2222
return ofHttpResponse();
2323
}
2424

25-
int ofxEmscriptenURLFileLoader::getAsync(const string & url, const string & name){
25+
int ofxEmscriptenURLFileLoader::getAsync(const string & url, const string & name){
2626
ofHttpRequest * req = new ofHttpRequest(url,name,false);
2727
#if __EMSCRIPTEN_major__>1 || (__EMSCRIPTEN_major__==1 && __EMSCRIPTEN_minor__>22)
2828
emscripten_async_wget2_data(url.c_str(), "GET", "", req, true, &onload_cb, &onerror_cb, NULL);
2929
#endif
3030
return req->getId();
3131
}
3232

33-
ofHttpResponse ofxEmscriptenURLFileLoader::saveTo(const string & url, const std::filesystem::path & path){
33+
ofHttpResponse ofxEmscriptenURLFileLoader::saveTo(const string & url, const of::filesystem::path & path){
3434
saveAsync(url,path);
3535
return ofHttpResponse();
3636
}
3737

38-
int ofxEmscriptenURLFileLoader::saveAsync(const string & url, const std::filesystem::path & path){
38+
int ofxEmscriptenURLFileLoader::saveAsync(const string & url, const of::filesystem::path & path){
3939
ofHttpRequest * req = new ofHttpRequest(url,url,true);
4040
#if __EMSCRIPTEN_major__>1 || (__EMSCRIPTEN_major__==1 && __EMSCRIPTEN_minor__>22)
4141
emscripten_async_wget2(url.c_str(), path.c_str(), "GET", "", req, &onload_file_cb, &onerror_file_cb, NULL);

addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ class ofxEmscriptenURLFileLoader: public ofBaseURLFileLoader {
1111
public:
1212
ofxEmscriptenURLFileLoader();
1313
virtual ~ofxEmscriptenURLFileLoader();
14-
ofHttpResponse get(const std::string & url);
15-
int getAsync(const std::string & url, const std::string & name=""); // returns id
16-
ofHttpResponse saveTo(const std::string & url, const std::filesystem::path & path);
17-
int saveAsync(const std::string & url, const std::filesystem::path & path);
14+
ofHttpResponse get(const std::string & url);
15+
int getAsync(const std::string & url, const std::string & name=""); // returns id
16+
ofHttpResponse saveTo(const std::string & url, const of::filesystem::path & path);
17+
int saveAsync(const std::string & url, const of::filesystem::path & path);
1818
ofHttpResponse handleRequest(const ofHttpRequest & request);
1919
int handleRequestAsync(const ofHttpRequest & request);
2020
void remove(int id);

addons/ofxOpenCv/src/ofxCvHaarFinder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void ofxCvHaarFinder::setNeighbors(unsigned neighbors) {
4949
this->neighbors = neighbors;
5050
}
5151

52+
// FIXME: convert to of::filesystem::path
5253
void ofxCvHaarFinder::setup(std::string haarFile) {
5354

5455
this->haarFile = haarFile;

0 commit comments

Comments
 (0)