mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ArchiveTools] No need to use temp names anymore
This commit is contained in:
@@ -619,36 +619,14 @@ namespace SabreTools.Helper
|
||||
// Now get the Rom info for the file so we have hashes and size
|
||||
Rom rom = RomTools.GetSingleFileInfo(input);
|
||||
|
||||
// Rename the input file based on the SHA-1
|
||||
string tempname = Path.Combine(Path.GetDirectoryName(input), rom.SHA1);
|
||||
try
|
||||
{
|
||||
File.Move(input, tempname);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warning(ex.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
// If it doesn't exist, create the output file and then write
|
||||
string outfile = Path.Combine(outdir, rom.SHA1 + ".gz");
|
||||
using (FileStream inputstream = new FileStream(tempname, FileMode.Open))
|
||||
using (FileStream inputstream = new FileStream(input, FileMode.Open))
|
||||
using (GZipStream output = new GZipStream(File.Open(outfile, FileMode.Create, FileAccess.Write), CompressionMode.Compress))
|
||||
{
|
||||
inputstream.CopyTo(output);
|
||||
}
|
||||
|
||||
// Name the original input file correctly again, if possible
|
||||
try
|
||||
{
|
||||
File.Move(tempname, input);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warning(ex.ToString());
|
||||
}
|
||||
|
||||
// Now that it's renamed, inject the header info
|
||||
using (BinaryWriter sw = new BinaryWriter(new MemoryStream()))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user