Exemple #1
0
MAUtil::String XML::getLocalPath()
{
	    // Do this here to work around a MoRE bug.
	    FileLister fl;
	    fl.start("/");

	    MAUtil::String path, os;


	    // Try getting the local path.
	    int result = getSystemProperty("mosync.path.local", path);

	    getSystemProperty("mosync.device.OS", os);

	    lprintfln("OS: %s", MAUtil::lowerString(os).c_str());

	    if(MAUtil::lowerString(os).find("android", 0) != -1)
	    {
	    	MAHandle tfile;

	    	path = "/sdcard/Magna Carta/";

	    	tfile = maFileOpen(path.c_str(), MA_ACCESS_READ_WRITE);

	    	lprintfln("File handle: %d", tfile);
	    	lprintfln("File exists: %d", maFileExists(tfile));


	    	if(!maFileExists(tfile))
	    	{
	    		int result = maFileCreate(tfile);

	    		lprintfln("File create code: %d", result);
	    	}

	    	maFileClose(tfile);

	    	lprintfln("Path: %s", path.c_str());

	    	return path;
	    }

	    // If it works, fine.
	    if(result > 0) {
	        //printf("Got local path: %i\n", result);
	        return path;
	    }

	    // Otherwise, get the first root directory.
	    fl.start("");
	    result = fl.next(path);
	    //MAASSERT(result > 0);
	    return path;
}
Exemple #2
0
static bool writeAFile(const MAUtil::String& dir) {
	// find a root path
	printf("Dir: '%s'\n", dir.c_str());
	FileLister fl;
	int res = fl.start(dir.c_str());
	if(res < 0) {
		printf("Error %i\n", res);
		return false;
	}
	MAUtil::String file;
	while(1) {
		res = fl.next(file);
		printf("%i: '%s'\n", res, file.c_str());
		if(res < 0) {
			printf("Error %i\n", res);
			return false;
		}
		if(res == 0) {
			printf("Dir '%s' ends.\n", dir.c_str());
			return false;
		}
		if(file[file.size()-1] == '/') {
			if(tryToWrite(dir + file))
				return true;
			if(writeAFile(dir + file))
				return true;
		}
	}
}
MAUtil::String SettingsScreen::getLocalPath() {
    // Do this here to work around a MoRE bug.
    FileLister fl;
    fl.start("/");

    MAUtil::String path;
    // Try getting the local path.
    int result = getSystemProperty("mosync.path.local", path);
    // If it works, fine.
    if(result > 0) {
        printf("Got local path: %i\n", result);
        return path + "/";
    }
    printf("local path output %i", result);
    // Otherwise, get the first root directory.
    fl.start("");
    result = fl.next(path);
    MAASSERT(result > 0);
    return path;
}