Skip to content

Commit

Permalink
don't disable writing on extranous listfile entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Frotty committed Oct 13, 2019
1 parent c126aaa commit 3a1016b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/main/java/systems/crigges/jmpq3/JMpqEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,10 @@ private void readListFile() {
}
for (String fileName : listFile.getFiles()) {
if (!hasFile(fileName)) {
canWrite = false;
log.warn("mpq's listfile is incomplete: " + fileName + " exists in listfile but not in archive.");
return;
log.warn("listfile entry does not exist in archive and will be discarded: " + fileName);
}
}
listFile.getFiles().removeIf(file -> !hasFile(file));
}
} catch (Exception e) {
log.warn("Extracting the mpq's listfile failed. It cannot be rebuild.", e);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/systems/crigges/jmpq3/Listfile.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package systems.crigges.jmpq3;

import java.nio.charset.StandardCharsets;
import java.util.HashSet;
import java.util.Scanner;

public class Listfile {
private HashSet<String> files = new HashSet<String>();

public Listfile(byte[] file) {
String list = new String(file);
String list = new String(file, StandardCharsets.UTF_8);
Scanner sc = new Scanner(list);
while (sc.hasNextLine()) {
addFile(sc.nextLine());
Expand Down Expand Up @@ -39,4 +40,4 @@ public byte[] asByteArray() {
}
return temp.toString().getBytes();
}
}
}

0 comments on commit 3a1016b

Please sign in to comment.