Last active
July 16, 2020 01:09
-
-
Save moebiussurfing/cda6e1bf4504071a43979917265d2e41 to your computer and use it in GitHub Desktop.
openframeworks | check if a folder path exist and creates one if not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//check if a folder path exist and creates one if not | |
//many times when you try to save a file, this is not possible and do not happens bc the container folder do not exist | |
//-------------------------------------------------------------- | |
void CheckFolder(string _path) | |
{ | |
ofLogNotice(__FUNCTION__) << _path; | |
ofDirectory dataDirectory(ofToDataPath(_path, true)); | |
//check if folder path exist | |
if (!dataDirectory.isDirectory()) | |
{ | |
ofLogError(__FUNCTION__) << "FOLDER NOT FOUND! TRYING TO CREATE..."; | |
//try to create folder | |
bool b = dataDirectory.createDirectory(ofToDataPath(_path, true)); | |
//debug if creation has been succeded | |
if (b) ofLogNotice(__FUNCTION__) << "CREATED '" << _path << "' SUCCESSFULLY!"; | |
else ofLogError(__FUNCTION__) << "UNABLE TO CREATE '" << _path << "' FOLDER!"; | |
} | |
else | |
{ | |
ofLogNotice(__FUNCTION__) << "OK! LOCATED FOLDER: '" << _path << "'";//nothing to do | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment