Skip to content

Commit

Permalink
Close map files during editing
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperHackio committed Feb 16, 2024
1 parent 8abb70c commit e7fd65d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/whitehole/io/ExternalFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
public class ExternalFile implements FileBase {
private final RandomAccessFile file;
private boolean isBigEndian;
private final String filePath;

private final ByteBuffer byteBuffer = ByteBuffer.allocate(8);
private final CharBuffer charBuffer = CharBuffer.allocate(1);

public ExternalFile(String path) throws FileNotFoundException {
filePath = path;
file = new RandomAccessFile(path, "rw");
isBigEndian = false;
System.out.println("FILE OPEN: "+filePath);
}

@Override
Expand All @@ -40,6 +43,7 @@ public void save() throws IOException {
@Override
public void close() throws IOException {
file.close();
System.out.println("FILE CLOSE: "+filePath);
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions src/whitehole/smg/StageArchive.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ private void loadZone() {
loadLayeredObjects(designArc, "Placement", "AreaObjInfo");
}
}
mapArc.close();
}
catch (IOException ex) {
System.out.println(ex);
Expand Down Expand Up @@ -237,6 +238,7 @@ private void loadPaths() {
// Saving

public void save() throws IOException {
mapArc = new RarcFile(filesystem.openFile(mapPath));
saveLayeredZones();
savePaths();

Expand All @@ -256,6 +258,7 @@ public void save() throws IOException {
}

mapArc.save();
mapArc.close();
}

private void saveLayeredObjects(RarcFile archive, String folder, String file) throws IOException {
Expand Down

0 comments on commit e7fd65d

Please sign in to comment.