Defend against trap if renderdata/ directory doesn't exist (deleted by user)
This commit is contained in:
parent
0cedeac3eb
commit
2012c63921
2 changed files with 29 additions and 25 deletions
|
|
@ -293,20 +293,22 @@ public class HDBlockModels {
|
||||||
}
|
}
|
||||||
File customdir = new File(datadir, "renderdata");
|
File customdir = new File(datadir, "renderdata");
|
||||||
String[] files = customdir.list();
|
String[] files = customdir.list();
|
||||||
for(String fn : files) {
|
if(files != null) {
|
||||||
if(fn.endsWith("-models.txt") == false)
|
for(String fn : files) {
|
||||||
continue;
|
if(fn.endsWith("-models.txt") == false)
|
||||||
File custom = new File(customdir, fn);
|
continue;
|
||||||
if(custom.canRead()) {
|
File custom = new File(customdir, fn);
|
||||||
try {
|
if(custom.canRead()) {
|
||||||
in = new FileInputStream(custom);
|
try {
|
||||||
loadModelFile(in, custom.getPath());
|
in = new FileInputStream(custom);
|
||||||
} catch (IOException iox) {
|
loadModelFile(in, custom.getPath());
|
||||||
Log.severe("Error loading " + custom.getPath());
|
} catch (IOException iox) {
|
||||||
} finally {
|
Log.severe("Error loading " + custom.getPath());
|
||||||
if(in != null) {
|
} finally {
|
||||||
try { in.close(); } catch (IOException iox) {}
|
if(in != null) {
|
||||||
in = null;
|
try { in.close(); } catch (IOException iox) {}
|
||||||
|
in = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -788,17 +788,19 @@ public class TexturePack {
|
||||||
|
|
||||||
File renderdir = new File(datadir, "renderdata");
|
File renderdir = new File(datadir, "renderdata");
|
||||||
String[] files = renderdir.list();
|
String[] files = renderdir.list();
|
||||||
for(String fname : files) {
|
if(files != null) {
|
||||||
if(fname.endsWith("-texture.txt")) {
|
for(String fname : files) {
|
||||||
File custom = new File(renderdir, fname);
|
if(fname.endsWith("-texture.txt")) {
|
||||||
if(custom.canRead()) {
|
File custom = new File(renderdir, fname);
|
||||||
try {
|
if(custom.canRead()) {
|
||||||
in = new FileInputStream(custom);
|
try {
|
||||||
loadTextureFile(in, custom.getPath());
|
in = new FileInputStream(custom);
|
||||||
} catch (IOException iox) {
|
loadTextureFile(in, custom.getPath());
|
||||||
Log.severe("Error loading " + custom.getPath() + " - " + iox);
|
} catch (IOException iox) {
|
||||||
} finally {
|
Log.severe("Error loading " + custom.getPath() + " - " + iox);
|
||||||
if(in != null) { try { in.close(); } catch (IOException x) {} in = null; }
|
} finally {
|
||||||
|
if(in != null) { try { in.close(); } catch (IOException x) {} in = null; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue