Skip to content

Commit

Permalink
ok really this time
Browse files Browse the repository at this point in the history
  • Loading branch information
Frotty committed Jun 5, 2017
1 parent 9a7be8c commit 8f428d9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main/java/systems/crigges/jmpq3/JMpqEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import systems.crigges.jmpq3.BlockTable.Block;

import java.io.*;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.MappedByteBuffer;
Expand Down Expand Up @@ -253,13 +252,19 @@ private void setupTempDir() throws JMpqException {
* Makes the archive readonly.
*/
private void loadDefaultListFile() throws IOException {
URL resource = getClass().getClassLoader().getResource("DefaultListfile.txt");
InputStream resource = getClass().getClassLoader().getResourceAsStream("DefaultListfile.txt");
if (resource != null) {
Path defaultListfile = Paths.get("listfile");
try (InputStream is = resource.openStream()) {
Files.copy(is, defaultListfile);
File tempFile = File.createTempFile("jmpq", "lf", tempDir);
tempFile.deleteOnExit();
try (FileOutputStream out = new FileOutputStream(tempFile)) {
//copy stream
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = resource.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
}
}
listFile = new Listfile(Files.readAllBytes(defaultListfile));
listFile = new Listfile(Files.readAllBytes(tempFile.toPath()));
canWrite = false;
}
}
Expand Down

0 comments on commit 8f428d9

Please sign in to comment.