Skip to content

Commit

Permalink
Fix ENIGMA_DIR file extension
Browse files Browse the repository at this point in the history
  • Loading branch information
sfPlayer1 committed Jun 15, 2023
1 parent 01dfb72 commit c585d9b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public enum MappingFormat {
TINY_FILE("Tiny file", "tiny", true, true, false, false, false),
TINY_2_FILE("Tiny v2 file", "tiny", true, true, true, true, true),
ENIGMA_FILE("Enigma file", "mapping", false, true, true, true, false),
ENIGMA_FILE("Enigma file", "mappings", false, true, true, true, false),
ENIGMA_DIR("Enigma directory", null, false, true, true, true, false),
MCP_DIR("MCP directory", null, false, false, true, true, false),
SRG_FILE("SRG file", "srg", false, false, false, false, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import net.fabricmc.mappingio.MappingUtil;
import net.fabricmc.mappingio.MappingVisitor;
import net.fabricmc.mappingio.format.MappingFormat;

public final class EnigmaDirReader {
public static void read(Path dir, MappingVisitor visitor) throws IOException {
Expand All @@ -36,7 +35,7 @@ public static void read(Path dir, String sourceNs, String targetNs, MappingVisit
Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (file.getFileName().toString().endsWith("." + MappingFormat.ENIGMA_FILE.fileExt)) {
if (file.getFileName().toString().endsWith("." + DIR_FILE_EXT)) {
EnigmaFileReader.read(Files.newBufferedReader(file), sourceNs, targetNs, visitor);
}

Expand All @@ -45,4 +44,6 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
});
visitor.visitEnd();
}

static final String DIR_FILE_EXT = "mapping"; // non-plural form unlike ENIGMA_FILE
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.List;

import net.fabricmc.mappingio.MappedElementKind;
import net.fabricmc.mappingio.format.MappingFormat;

public final class EnigmaDirWriter extends EnigmaWriterBase {
public EnigmaDirWriter(Path dir, boolean deleteExistingFiles) throws IOException {
Expand All @@ -40,7 +39,7 @@ public EnigmaDirWriter(Path dir, boolean deleteExistingFiles) throws IOException
Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (file.getFileName().toString().endsWith("." + MappingFormat.ENIGMA_FILE.fileExt)) {
if (file.getFileName().toString().endsWith("." + EnigmaDirReader.DIR_FILE_EXT)) {
Files.delete(file);
}

Expand Down Expand Up @@ -82,7 +81,7 @@ public boolean visitElementContent(MappedElementKind targetKind) throws IOExcept
if (pos >= 0) name = name.substring(0, pos);

// currentClass is not an outer class of srcName (or the same)
Path file = dir.resolve(name + "." + MappingFormat.ENIGMA_FILE.fileExt).normalize();
Path file = dir.resolve(name + "." + EnigmaDirReader.DIR_FILE_EXT).normalize();
if (!file.startsWith(dir)) throw new RuntimeException("invalid name: " + name);

if (writer != null) {
Expand Down

0 comments on commit c585d9b

Please sign in to comment.