[ArchiveTools] Use more robust tempfile naming

This commit is contained in:
Matt Nadareski
2017-02-23 17:13:27 -08:00
parent 61b0b9cd0c
commit f1d3beb9fb
2 changed files with 49 additions and 3 deletions

View File

@@ -1112,7 +1112,7 @@ namespace SabreTools.Helper.Tools
public static bool WriteTAR(List<string> inputFiles, string outDir, List<Rom> roms, Logger logger, bool date = false) public static bool WriteTAR(List<string> inputFiles, string outDir, List<Rom> roms, Logger logger, bool date = false)
{ {
bool success = false; bool success = false;
string tempFile = Path.GetTempFileName(); string tempFile = Path.Combine(Path.GetTempPath(), "tmp" + Guid.NewGuid().ToString());
// If either list of roms is null or empty, return // If either list of roms is null or empty, return
if (inputFiles == null || roms == null || inputFiles.Count == 0 || roms.Count == 0) if (inputFiles == null || roms == null || inputFiles.Count == 0 || roms.Count == 0)
@@ -1231,7 +1231,7 @@ namespace SabreTools.Helper.Tools
else else
{ {
// Get the stream from the original archive // Get the stream from the original archive
string tempEntry = Path.GetTempFileName(); string tempEntry = Path.Combine(Path.GetTempPath(), "tmp" + Guid.NewGuid().ToString());
oldTarFile.Entries.Where(e => e.Key == key).ToList()[0].WriteToFile(tempEntry); oldTarFile.Entries.Where(e => e.Key == key).ToList()[0].WriteToFile(tempEntry);
// Copy the input stream to the output // Copy the input stream to the output
@@ -1527,7 +1527,7 @@ namespace SabreTools.Helper.Tools
public static bool WriteTorrentZip(List<string> inputFiles, string outDir, List<Rom> roms, Logger logger, bool date = false) public static bool WriteTorrentZip(List<string> inputFiles, string outDir, List<Rom> roms, Logger logger, bool date = false)
{ {
bool success = false; bool success = false;
string tempFile = Path.GetTempFileName(); string tempFile = Path.Combine(Path.GetTempPath(), "tmp" + Guid.NewGuid().ToString());
// If either list of roms is null or empty, return // If either list of roms is null or empty, return
if (inputFiles == null || roms == null || inputFiles.Count == 0 || roms.Count == 0) if (inputFiles == null || roms == null || inputFiles.Count == 0 || roms.Count == 0)

46
build.bat Normal file
View File

@@ -0,0 +1,46 @@
@echo off
set configuration=Mono
set platform=x64
echo ------------------------
echo [ Build SabreTools ]
echo ------------------------
echo.
REM Set the configuration
:Configuration
echo What configuration do you want?
echo 1) Debug
echo 2) Release
echo 3) Mono [Default]
set /P confgnum="> "
if "%confignum%"=="1" ( set configuration=Debug )
if "%confignum%"=="2" ( set configuration=Release )
if "%confignum%"=="3" ( set configuration=Mono )
if "%confignum%"=="" ( set configuration=Mono )
REM Set the platform
:Platform
echo.
echo What platform do you want?
echo 1) AnyCPU
echo 2) x64 [Default]
set /P platnum="> "
if "%platnum%"=="1" ( set platform=AnyCPU )
if "%platnum%"=="2" ( set platform=x64 )
if "%platnum%"=="" ( set platform=x64 )
REM Now run the command
:Command
@echo on
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" SabreTools.sln /property:Configuration=%configuration% /property:Platform=%platform%
pause