@@ -952,13 +952,7 @@ protected Response getFile(String path, boolean asset) throws IOException {
952
952
log ("Opened " + name + " " + length + " bytes" );
953
953
result = new Response (getAssets ().open (name ), length );
954
954
} else {
955
- File file = getFile (_storage .getExternal (), path );
956
- if (file == null ) {
957
- file = getFile (_storage .getMedia (), path );
958
- }
959
- if (file == null ) {
960
- file = getFile (_storage .getInternal (), path );
961
- }
955
+ File file = getFile (path );
962
956
if (file != null ) {
963
957
result = new Response (new FileInputStream (file ), file .length ());
964
958
} else {
@@ -992,20 +986,11 @@ protected void renameFile(String from, String to) throws IOException {
992
986
if (to == null || !to .endsWith (".bas" )) {
993
987
throw new IOException ("Invalid file name: " + to );
994
988
}
995
- File toFile = getFile (_storage .getInternal (), to );
996
- if (toFile == null ) {
997
- toFile = getFile (_storage .getExternal (), to );
998
- }
989
+ File toFile = getFile (to );
999
990
if (toFile != null ) {
1000
991
throw new IOException ("File already exists" );
1001
992
}
1002
- File fromFile = getFile (_storage .getInternal (), from );
1003
- if (fromFile == null ) {
1004
- fromFile = getFile (_storage .getExternal (), from );
1005
- }
1006
- if (fromFile == null ) {
1007
- fromFile = getFile (_storage .getInternal (), from );
1008
- }
993
+ File fromFile = getFile (from );
1009
994
if (fromFile == null ) {
1010
995
throw new IOException ("Previous file does not exist" );
1011
996
}
@@ -1033,6 +1018,17 @@ private File getFile(String parent, String path) {
1033
1018
return result ;
1034
1019
}
1035
1020
1021
+ private File getFile (String path ) {
1022
+ File file = getFile (_storage .getExternal (), path );
1023
+ if (file == null ) {
1024
+ file = getFile (_storage .getMedia (), path );
1025
+ }
1026
+ if (file == null ) {
1027
+ file = getFile (_storage .getInternal (), path );
1028
+ }
1029
+ return file ;
1030
+ }
1031
+
1036
1032
private long getFileLength (String name ) throws IOException {
1037
1033
Long length = fileLengths .get (name );
1038
1034
if (length == null ) {
0 commit comments