This commit is contained in:
gabriel 2024-02-15 11:34:22 -04:00
parent 5772516126
commit 36895ede35
2 changed files with 22 additions and 21 deletions

View file

@ -33,30 +33,10 @@ public class AlberDriver {
public static native void setShaderJitEnabled(boolean enable);
public static String parseNativeMode(String mode){
mode = mode.toLowerCase();
switch (mode){
case "r":
case "rb":
return "r";
case "r+":
case "r+b":
case "rb+":
return "rw";
case "w+":
return "rwt";
case "w":
case "wb":
return "wt";
case "wa":
return "wa";
}
throw new IllegalArgumentException("Invalid file mode: "+mode);
}
public static int openDocument(String path, String mode){
try {
mode = parseNativeMode(mode);
mode = FileUtils.parseNativeMode(mode);
Context context = PandroidApplication.getAppContext();
Uri uri = FileUtils.obtainUri(path);
ParcelFileDescriptor parcel;

View file

@ -66,6 +66,27 @@ public class FileUtils {
return file.getAbsolutePath();
}
public static String parseNativeMode(String mode){
mode = mode.toLowerCase();
switch (mode){
case "r":
case "rb":
return "r";
case "r+":
case "r+b":
case "rb+":
return "rw";
case "w+":
return "rwt";
case "w":
case "wb":
return "wt";
case "wa":
return "wa";
}
throw new IllegalArgumentException("Invalid file mode: "+mode);
}
public static boolean exists(String path) {
return parseFile(path).exists();
}