Skip to content

Commit

Permalink
Move default vmf location algorithm out of BspFileEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
rihi committed Aug 31, 2023
1 parent f711a06 commit 70efa0d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import info.ata4.bspsrc.decompiler.modules.geom.BrushMode;
import info.ata4.bspsrc.decompiler.util.SourceFormat;
import info.ata4.bspsrc.lib.app.SourceAppDB;
import info.ata4.io.util.PathUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -306,11 +305,15 @@ private Set<BspFileEntry> getEntries() throws IOException {
pathStream
.filter(Files::isRegularFile)
.filter(bspPathMatcher::matches)
.map(filePath -> new BspFileEntry(filePath, outputPath))
.map(bspPath -> new BspFileEntry(bspPath, BspPathUtil.defaultVmfPath(bspPath, outputPath)))
.forEach(fileSet::add);
}
} else {
fileSet.add(new BspFileEntry(path, outputPath));
Path vmfPath = bspPaths.size() > 1 || outputPath == null
? BspPathUtil.defaultVmfPath(path, outputPath)
: outputPath;

fileSet.add(new BspFileEntry(path, vmfPath));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package info.ata4.bspsrc.app.util;

import info.ata4.bspsrc.common.util.PathUtil;

import java.nio.file.Path;

public class BspPathUtil {

public static Path defaultVmfPath(Path bspPath, Path vmfDirPath) {
if (vmfDirPath == null)
vmfDirPath = bspPath.getParent();

String base = PathUtil.nameWithoutExtension(bspPath).orElse("");
return vmfDirPath.resolve(base + "_d.vmf");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import info.ata4.bspsrc.common.util.PathUtil;

import java.nio.file.Path;
import java.util.Objects;

import static java.util.Objects.requireNonNull;

/**
*
Expand All @@ -28,19 +29,9 @@ public class BspFileEntry {
private Path nmoFile;
private Path nmosFile;

public BspFileEntry(Path bspFile) {
this(bspFile, null);
}

public BspFileEntry(Path bspFile, Path vmfFile) {
Objects.requireNonNull(bspFile);

if (vmfFile == null) {
vmfFile = replaceExtension(bspFile, "_d.vmf");
}

this.bspFile = bspFile;
this.vmfFile = vmfFile;
this.bspFile = requireNonNull(bspFile);
this.vmfFile = requireNonNull(vmfFile);
this.pakfileDir = replaceExtension(vmfFile, "");
this.nmoFile = replaceExtension(bspFile, ".nmo");
this.nmosFile = replaceExtension(vmfFile, ".nmos");
Expand Down Expand Up @@ -82,7 +73,7 @@ public Path getNmosFile() {

public void setNmosFile(Path nmosFile)
{
Objects.requireNonNull(nmosFile);
requireNonNull(nmosFile);
this.nmosFile = nmosFile;
}

Expand Down

0 comments on commit 70efa0d

Please sign in to comment.