mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-19 09:15:23 +12: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 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){
|
public static int openDocument(String path, String mode){
|
||||||
try {
|
try {
|
||||||
mode = mode.toLowerCase();
|
mode = parseNativeMode(mode);
|
||||||
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);
|
|
||||||
}
|
|
||||||
Context context = PandroidApplication.getAppContext();
|
Context context = PandroidApplication.getAppContext();
|
||||||
Uri uri = FileUtils.obtainUri(path);
|
Uri uri = FileUtils.obtainUri(path);
|
||||||
ParcelFileDescriptor parcel;
|
ParcelFileDescriptor parcel;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue