コード例 #1
0
ファイル: CCUtils.cpp プロジェクト: live17909/cocos2dx-better
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;
}
コード例 #2
0
ファイル: CCUtils.cpp プロジェクト: stubma/cocos2dx-classical
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);
		}
	}
}
コード例 #3
0
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;
    }
}