Skip to content

Commit

Permalink
Small file storage improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Jul 11, 2024
1 parent 3ce4e2f commit 7d25c9d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ public MemoryFileStorage() {
public InputStream read(TeaFileHandle file) {
String path = fixPath(file.path());
FileData data = getInternal(path);
if(data == null) {
return null;
}
byte[] byteArray = data.getBytes();
try {
return new ByteArrayInputStream(byteArray);
}
catch(RuntimeException e) {
// Something corrupted: we remove it & re-throw the error
removeInternal(path);
throw e;
throw new GdxRuntimeException(getClass().getSimpleName() + " Error: " + path, e);
}
}

Expand Down Expand Up @@ -299,6 +302,9 @@ private String[] list(FileHandle file, boolean equals) {
String[] str = new String[tmpPaths.size];
for(int i = 0; i < tmpPaths.size; i++) {
String s = tmpPaths.get(i);
if(s.startsWith("/")) {
s = s.substring(1);
}
if(debug) {
System.out.println(getClass().getSimpleName() + " LIST[" + i + "]: " + s);
}
Expand Down

0 comments on commit 7d25c9d

Please sign in to comment.