Permalink
Browse files

update to also allow the dataPathRoot to have forward or backslashes …

…and pass the prepend check
  • Loading branch information...
1 parent e1c20bb commit 9784712c0ff9a5ad19fce837af6faa0173a2ee11 @ofTheo ofTheo committed Feb 12, 2013
Showing with 7 additions and 2 deletions.
  1. +7 −2 libs/openFrameworks/utils/ofUtils.cpp
@@ -278,15 +278,20 @@ string ofToDataPath(string path, bool makeAbsolute){
if( enableDataPath ){
- string enclosingFolder = path.substr(0,dataPathRoot().length());
+ //we create dataPath as a string for the check, on windows we modify it to check both types of slashes
+ //however we use the original value from dataPathRoot() to prepend the string if needed.
+ string dataPath = dataPathRoot();
+ string enclosingFolder = path.substr(0,dataPath.length());
+
#ifdef TARGET_WIN32
//this is so we can check both "data\" and "data/" on windows
std::replace( enclosingFolder.begin(), enclosingFolder.end(), '\\', '/' );
+ std::replace( dataPath.begin(), dataPath.end(), '\\', '/' );
#endif // TARGET_WIN32
//check if absolute path has been passed or if data path has already been applied
//do we want to check for C: D: etc ?? like substr(1, 2) == ':' ??
- if( path.length()==0 || (path.substr(0,1) != "/" && path.substr(1,1) != ":" && enclosingFolder != dataPathRoot())){
+ if( path.length()==0 || (path.substr(0,1) != "/" && path.substr(1,1) != ":" && enclosingFolder != dataPath)){
path = dataPathRoot()+path;
}

0 comments on commit 9784712

Please sign in to comment.