mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-19 09:15:23 +12:00
Peach things
This commit is contained in:
parent
e57755d866
commit
715ce45066
1 changed files with 26 additions and 4 deletions
|
@ -34,16 +34,38 @@ public class AlberDriver {
|
||||||
|
|
||||||
public static int openDocument(String path, String mode){
|
public static int openDocument(String path, String mode){
|
||||||
try {
|
try {
|
||||||
mode = mode.substring(0,1);
|
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);
|
||||||
|
}
|
||||||
Context context = PandroidApplication.getAppContext();
|
Context context = PandroidApplication.getAppContext();
|
||||||
Uri uri = FileUtils.obtainUri(path);
|
Uri uri = FileUtils.obtainUri(path);
|
||||||
ParcelFileDescriptor parcel;
|
ParcelFileDescriptor parcel;
|
||||||
if (Objects.equals(uri.getScheme(), "game")) {
|
if (Objects.equals(uri.getScheme(), "game")) {
|
||||||
|
if (mode.contains("w")){
|
||||||
|
throw new IllegalArgumentException("Cannot write to rom-fs");
|
||||||
|
}
|
||||||
uri = FileUtils.obtainUri(GameUtils.getCurrentGame().getRomPath());
|
uri = FileUtils.obtainUri(GameUtils.getCurrentGame().getRomPath());
|
||||||
parcel = context.getContentResolver().openFileDescriptor(uri, "r");
|
|
||||||
} else {
|
|
||||||
parcel = context.getContentResolver().openFileDescriptor(uri, mode);
|
|
||||||
}
|
}
|
||||||
|
parcel = context.getContentResolver().openFileDescriptor(uri, mode);
|
||||||
int fd = parcel.detachFd();
|
int fd = parcel.detachFd();
|
||||||
parcel.close();
|
parcel.close();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue