bool CCUtils::createIntermediateFolders(string path) { string parent = getParentPath(path); bool exist = isPathExistent(parent); bool success = true; if(!exist) { createIntermediateFolders(parent); success = createFolder(parent); } // return success flag return success; }
void CCUtils::wipeExternal(StringList paths) { string internalStorage = getInternalStoragePath(); if(internalStorage[internalStorage.length() - 1] != '/') { internalStorage += "/"; } for(StringList::iterator iter = paths.begin(); iter != paths.end(); iter++) { string fullpath = internalStorage + (*iter); if(isPathExistent(fullpath)) { deleteFile(fullpath); } } }
string CCUtils::externalize(const string& path) { if(!CCFileUtils::sharedFileUtils()->isAbsolutePath(path)) { // ensure internal dir ends with slash string internalStorage = getInternalStoragePath(); if(internalStorage[internalStorage.length() - 1] != '/') { internalStorage += "/"; } // append search path const vector<string>& searchPaths = CCFileUtils::sharedFileUtils()->getSearchPaths(); for(vector<string>::const_iterator iter = searchPaths.begin(); iter != searchPaths.end(); iter++) { string fullpath = internalStorage + (*iter) + path; if(isPathExistent(fullpath)) { return fullpath; } } // fallback, without search path return internalStorage + path; } else { return path; } }