fix: export cjm files wip
This commit is contained in:
parent
a1a01661ce
commit
3329795aa7
|
@ -9,6 +9,7 @@ import java.nio.file.StandardCopyOption;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -202,20 +203,42 @@ public class ExportManager
|
|||
}
|
||||
for (GameDetails gameDetails : gameDetailsList)
|
||||
{
|
||||
Path gamePath = Paths.get("./games/" + gameDetails.getGame());
|
||||
String gameName = gameDetails.getGame();
|
||||
|
||||
//TODO: Unzip if needed, rename vsf files to prg according to Spannernick
|
||||
Path gamePath = Paths.get("./games/" + gameName);
|
||||
String extension = FilenameUtils.getExtension(gameName);
|
||||
boolean zipped = false;
|
||||
if (extension.equalsIgnoreCase("gz"))
|
||||
{
|
||||
gameName = FilenameUtils.removeExtension(gameName);
|
||||
//Get next extension
|
||||
extension = FilenameUtils.getExtension(gameName);
|
||||
if (extension.equalsIgnoreCase("vsf"))
|
||||
{
|
||||
//Rename to prg so that it works in the file loader
|
||||
extension = "prg";
|
||||
}
|
||||
zipped = true;
|
||||
}
|
||||
Path targetGamePath = targetDir.toPath().resolve(FileManager.generateFileNameFromTitleForFileLoader(gameDetails.getTitle(), gameDetails.getDuplicateIndex()) + "." + extension);
|
||||
|
||||
Path targetGamePath = targetDir.toPath().resolve(gameDetails.getGame());
|
||||
|
||||
try
|
||||
{
|
||||
if (!gameDetails.getGame().isEmpty())
|
||||
{
|
||||
infoBuilder.append("Copying game file from ");
|
||||
infoBuilder.append(gamePath.toString());
|
||||
infoBuilder.append(" to ");
|
||||
infoBuilder.append(targetGamePath);
|
||||
infoBuilder.append("\n");
|
||||
Files.copy(gamePath, targetGamePath, StandardCopyOption.REPLACE_EXISTING);
|
||||
if (zipped)
|
||||
{
|
||||
FileManager.decompressGzip(gamePath, targetGamePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Files.copy(gamePath, targetGamePath, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
|
|
|
@ -239,7 +239,7 @@ public class FileManager
|
|||
}
|
||||
}
|
||||
|
||||
public void decompressGzip(Path source, Path target) throws IOException
|
||||
public static void decompressGzip(Path source, Path target) throws IOException
|
||||
{
|
||||
try (GZIPInputStream gis = new GZIPInputStream(new FileInputStream(source.toFile()));
|
||||
FileOutputStream fos = new FileOutputStream(target.toFile()))
|
||||
|
@ -379,7 +379,7 @@ public class FileManager
|
|||
if (duplicateIndex > 0)
|
||||
{
|
||||
//Just add the duplicate index if there are several games with the same name
|
||||
newNameString = newNameString + "0" + duplicateIndex;
|
||||
newNameString = newNameString + "_" + duplicateIndex;
|
||||
}
|
||||
|
||||
logger.debug("Game title: \"{}\" ---- New fileName: \"{}\"", title, newNameString);
|
||||
|
@ -1278,7 +1278,7 @@ public class FileManager
|
|||
}
|
||||
return filePath != null ? filePath.toFile() : file;
|
||||
}
|
||||
|
||||
|
||||
private static FileHeader getFirstMatchingRarEntry(Archive archive)
|
||||
{
|
||||
FileHeader fh = archive.nextFileHeader();
|
||||
|
|
Loading…
Reference in New Issue