Esempio n. 1
0
int64_t CCUtils::getAvailableStorageSize() {
    // actually we returned internal storage size
    string path = getInternalStoragePath();
    
    // get statfs
    JniMethodInfo t;
    JniHelper::getMethodInfo(t, "android/os/StatFs", "<init>", "(Ljava/lang/String;)V");
    jstring jPath = t.env->NewStringUTF(path.c_str());
    jobject statfs = t.env->NewObject(t.classID, t.methodID, jPath);
    
    // release
    t.env->DeleteLocalRef(t.classID);
    
    // get block size
    JniHelper::getMethodInfo(t, "android/os/StatFs", "getBlockSize", "()I");
    jint blockSize = t.env->CallIntMethod(statfs, t.methodID);
    
    // release
    t.env->DeleteLocalRef(t.classID);
    
    // get available block count
    JniHelper::getMethodInfo(t, "android/os/StatFs", "getAvailableBlocks", "()I");
    jint blocks = t.env->CallIntMethod(statfs, t.methodID);
    
    // release
    t.env->DeleteLocalRef(jPath);
    t.env->DeleteLocalRef(t.classID);
    
    // return
    return blockSize * blocks;
}
Esempio n. 2
0
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);
		}
	}
}
Esempio n. 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;
    }
}