mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-22 20:45:00 +00:00
Better mode implementation
This commit is contained in:
parent
715ce45066
commit
5772516126
1 changed files with 23 additions and 22 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue