public static boolean deleteDir( File dir ){ if (dir == null || !dir.isDirectory()){ return false; } for (File f : dir.listFiles()){ if (f.isDirectory()){ if (!deleteDir(f)) return false; } else { if (!deleteFile(f)) return false; } } return dir.delete(); }
public static File getFile( String name ){ return getFile( Game.instance.getFilesDir(), name); }
} catch (Exception e) { FileUtils.deleteFile( Rankings.RANKINGS_FILE ); for (int i = 1; i <= classes.length; i++){ String name = classes[i-1]; if (FileUtils.fileExists(name + ".dat")){ try { Bundle gamedata = FileUtils.bundleFromFile(name + ".dat"); FileUtils.bundleToFile(GamesInProgress.gameFile(i), gamedata); FileUtils.deleteFile(name + ".dat"); while (FileUtils.fileExists(name + depth + ".dat")) { gamedata = FileUtils.bundleFromFile(name + depth + ".dat"); FileUtils.bundleToFile(GamesInProgress.depthFile(i, depth), gamedata); FileUtils.deleteFile(name + depth + ".dat"); depth++;
Bundle bundle = FileUtils.bundleFromFile(BONES_FILE); FileUtils.deleteFile( BONES_FILE ); depth = 0;
public static File gameFolder( int slot ){ return FileUtils.getDir(Messages.format(GAME_FOLDER, slot)); }
public static void saveGlobal() { if (saveNeeded) { Bundle bundle = new Bundle(); store( bundle, global ); try { FileUtils.bundleToFile(BADGES_FILE, bundle); saveNeeded = false; } catch (IOException e) { ShatteredPixelDungeon.reportException(e); } } }
public static void loadGlobal() { if (global == null) { try { Bundle bundle = FileUtils.bundleFromFile( BADGES_FILE ); global = restore( bundle ); } catch (IOException e) { global = new HashSet<Badge>(); } } }
public static Bundle bundleFromFile( File file ) throws IOException{ return bundleFromStream(new FileInputStream(file)); }
public static void bundleToFile( File file, Bundle bundle ) throws IOException{ bundleToStream( new FileOutputStream(file), bundle); }
public static boolean gameExists( int slot ){ return FileUtils.dirExists(Messages.format(GAME_FOLDER, slot)); }
} catch (Exception e) { FileUtils.deleteFile( Rankings.RANKINGS_FILE ); for (int i = 1; i <= classes.length; i++){ String name = classes[i-1]; if (FileUtils.fileExists(name + ".dat")){ try { Bundle gamedata = FileUtils.bundleFromFile(name + ".dat"); FileUtils.bundleToFile(GamesInProgress.gameFile(i), gamedata); FileUtils.deleteFile(name + ".dat"); while (FileUtils.fileExists(name + depth + ".dat")) { gamedata = FileUtils.bundleFromFile(name + depth + ".dat"); FileUtils.bundleToFile(GamesInProgress.depthFile(i, depth), gamedata); FileUtils.deleteFile(name + depth + ".dat"); depth++;
Bundle bundle = FileUtils.bundleFromFile(BONES_FILE); FileUtils.deleteFile( BONES_FILE ); depth = 0;
public static File getDir( String name ){ return getDir( Game.instance.getFilesDir(), name); }
public static void saveLevel( int save ) throws IOException { Bundle bundle = new Bundle(); bundle.put( LEVEL, level ); FileUtils.bundleToFile(GamesInProgress.depthFile( save, depth), bundle); }
public static void loadGlobal() { if (global == null) { try { Bundle bundle = FileUtils.bundleFromFile( BADGES_FILE ); global = restore( bundle ); } catch (IOException e) { global = new HashSet<Badge>(); } } }
public static Bundle bundleFromFile( File file ) throws IOException{ return bundleFromStream(new FileInputStream(file)); }
public static void bundleToFile( File file, Bundle bundle ) throws IOException{ bundleToStream( new FileOutputStream(file), bundle); }
public static boolean gameExists( int slot ){ return FileUtils.dirExists(Messages.format(GAME_FOLDER, slot)); }
public static boolean deleteDir( File dir ){ if (dir == null || !dir.isDirectory()){ return false; } for (File f : dir.listFiles()){ if (f.isDirectory()){ if (!deleteDir(f)) return false; } else { if (!deleteFile(f)) return false; } } return dir.delete(); }