v1.2.0: deleted games now empty the main file instead of deleting it

This commit is contained in:
Evan Debenham
2022-03-21 21:19:56 -04:00
parent c35e750ff0
commit 077bdafe41
4 changed files with 31 additions and 9 deletions

View File

@@ -29,6 +29,7 @@ import com.badlogic.gdx.utils.GdxRuntimeException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
public class FileUtils {
@@ -115,12 +116,16 @@ public class FileUtils {
public static boolean fileExists( String name ){
FileHandle file = getFileHandle( name );
return file.exists() && !file.isDirectory();
return file.exists() && !file.isDirectory() && file.length() > 0;
}
public static boolean deleteFile( String name ){
return getFileHandle( name ).delete();
}
public static void setFileEmpty(String name ){
getFileHandle( name ).writeBytes(new byte[0], true);
}
// Directories
@@ -138,6 +143,17 @@ public class FileUtils {
return dir.deleteDirectory();
}
}
public static ArrayList<String> filesInDir( String name ){
FileHandle dir = getFileHandle( name );
ArrayList result = new ArrayList();
if (dir != null && dir.isDirectory()){
for (FileHandle file : dir.list()){
result.add(file.name());
}
}
return result;
}
// bundle reading