1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

fixes in handling of DirAccess for resource path on Android, fixes #1447

This commit is contained in:
Juan Linietsky
2015-04-28 09:38:07 -03:00
parent 0adca0a7c9
commit c6dce44dd8
4 changed files with 57 additions and 33 deletions

View File

@@ -271,6 +271,7 @@ public class GodotIO {
public String[] files;
public int current;
public String path;
}
public int last_dir_id=1;
@@ -281,6 +282,7 @@ public class GodotIO {
AssetDir ad = new AssetDir();
ad.current=0;
ad.path=path;
try {
ad.files = am.list(path);
@@ -290,6 +292,7 @@ public class GodotIO {
return -1;
}
//System.out.printf("Opened dir: %s\n",path);
++last_dir_id;
dirs.put(last_dir_id,ad);
@@ -297,6 +300,32 @@ public class GodotIO {
}
public boolean dir_is_dir(int id) {
if (!dirs.containsKey(id)) {
System.out.printf("dir_next: invalid dir id: %d\n",id);
return false;
}
AssetDir ad = dirs.get(id);
//System.out.printf("go next: %d,%d\n",ad.current,ad.files.length);
int idx = ad.current;
if (idx>0)
idx--;
if (idx>=ad.files.length)
return false;
String fname = ad.files[idx];
try {
if (ad.path.equals(""))
am.open(fname);
else
am.open(ad.path+"/"+fname);
return false;
} catch (Exception e) {
return true;
}
}
public String dir_next(int id) {
if (!dirs.containsKey(id)) {
@@ -305,8 +334,12 @@ public class GodotIO {
}
AssetDir ad = dirs.get(id);
if (ad.current>=ad.files.length)
//System.out.printf("go next: %d,%d\n",ad.current,ad.files.length);
if (ad.current>=ad.files.length) {
ad.current++;
return "";
}
String r = ad.files[ad.current];
ad.current++;
return r;