Better mode implementation

This commit is contained in:
gabriel 2024-02-15 11:26:13 -04:00
parent 715ce45066
commit 5772516126

View file

@ -32,30 +32,31 @@ 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 = mode.toLowerCase();
switch (mode) {
case "rb":
case "rb+":
case "r+b":
mode = "r";
break;
case "wb":
case "wb+":
case "w+b":
mode = "w";
break;
case "rwt":
case "wt":
case "rw":
case "r":
case "w":
case "wa":
break;
default:
throw new IllegalArgumentException("Invalid mode: "+mode);
}
mode = parseNativeMode(mode);
Context context = PandroidApplication.getAppContext();
Uri uri = FileUtils.obtainUri(path);
ParcelFileDescriptor parcel;