mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] One utility class now
This commit is contained in:
@@ -117,7 +117,7 @@ namespace SabreTools.Library.FileTypes
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(realEntry));
|
||||
|
||||
// Now open and write the file if possible
|
||||
FileStream fs = FileTools.TryCreate(realEntry);
|
||||
FileStream fs = Utilities.TryCreate(realEntry);
|
||||
if (fs != null)
|
||||
{
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
@@ -196,7 +196,7 @@ namespace SabreTools.Library.FileTypes
|
||||
|
||||
try
|
||||
{
|
||||
TarArchive ta = TarArchive.Open(FileTools.TryOpenRead(_filename));
|
||||
TarArchive ta = TarArchive.Open(Utilities.TryOpenRead(_filename));
|
||||
foreach (TarArchiveEntry entry in ta.Entries.Where(e => e != null && !e.IsDirectory))
|
||||
{
|
||||
// If secure hashes are disabled, do a quickscan
|
||||
@@ -217,7 +217,7 @@ namespace SabreTools.Library.FileTypes
|
||||
else
|
||||
{
|
||||
Stream entryStream = entry.OpenEntryStream();
|
||||
Rom tarEntryRom = (Rom)FileTools.GetStreamInfo(entryStream, entry.Size, omitFromScan: omitFromScan);
|
||||
Rom tarEntryRom = (Rom)Utilities.GetStreamInfo(entryStream, entry.Size, omitFromScan: omitFromScan);
|
||||
tarEntryRom.Name = entry.Key;
|
||||
tarEntryRom.MachineName = gamename;
|
||||
tarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
|
||||
@@ -302,7 +302,7 @@ namespace SabreTools.Library.FileTypes
|
||||
public override bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
|
||||
{
|
||||
// Get the file stream for the file and write out
|
||||
return Write(FileTools.TryOpenRead(inputFile), outDir, rom, date: date);
|
||||
return Write(Utilities.TryOpenRead(inputFile), outDir, rom, date: date);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -332,7 +332,7 @@ namespace SabreTools.Library.FileTypes
|
||||
}
|
||||
|
||||
// Get the output archive name from the first rebuild rom
|
||||
string archiveFileName = Path.Combine(outDir, Style.RemovePathUnsafeCharacters(rom.MachineName) + (rom.MachineName.EndsWith(".tar") ? "" : ".tar"));
|
||||
string archiveFileName = Path.Combine(outDir, Utilities.RemovePathUnsafeCharacters(rom.MachineName) + (rom.MachineName.EndsWith(".tar") ? "" : ".tar"));
|
||||
|
||||
// Set internal variables
|
||||
TarArchive oldTarFile = TarArchive.Create();
|
||||
@@ -451,7 +451,7 @@ namespace SabreTools.Library.FileTypes
|
||||
// If the old file exists, delete it and replace
|
||||
if (File.Exists(archiveFileName))
|
||||
{
|
||||
FileTools.TryDeleteFile(archiveFileName);
|
||||
Utilities.TryDeleteFile(archiveFileName);
|
||||
}
|
||||
File.Move(tempFile, archiveFileName);
|
||||
|
||||
@@ -494,7 +494,7 @@ namespace SabreTools.Library.FileTypes
|
||||
}
|
||||
|
||||
// Get the output archive name from the first rebuild rom
|
||||
string archiveFileName = Path.Combine(outDir, Style.RemovePathUnsafeCharacters(roms[0].MachineName) + (roms[0].MachineName.EndsWith(".tar") ? "" : ".tar"));
|
||||
string archiveFileName = Path.Combine(outDir, Utilities.RemovePathUnsafeCharacters(roms[0].MachineName) + (roms[0].MachineName.EndsWith(".tar") ? "" : ".tar"));
|
||||
|
||||
// Set internal variables
|
||||
TarArchive oldTarFile = TarArchive.Create();
|
||||
@@ -536,7 +536,7 @@ namespace SabreTools.Library.FileTypes
|
||||
}
|
||||
|
||||
// Copy the input stream to the output
|
||||
tarFile.AddEntry(roms[index].Name, FileTools.TryOpenRead(inputFiles[index]), size: roms[index].Size, modified: usableDate);
|
||||
tarFile.AddEntry(roms[index].Name, Utilities.TryOpenRead(inputFiles[index]), size: roms[index].Size, modified: usableDate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,7 +596,7 @@ namespace SabreTools.Library.FileTypes
|
||||
}
|
||||
|
||||
// Copy the input file to the output
|
||||
tarFile.AddEntry(roms[-index - 1].Name, FileTools.TryOpenRead(inputFiles[-index - 1]), size: roms[-index - 1].Size, modified: usableDate);
|
||||
tarFile.AddEntry(roms[-index - 1].Name, Utilities.TryOpenRead(inputFiles[-index - 1]), size: roms[-index - 1].Size, modified: usableDate);
|
||||
}
|
||||
|
||||
// Otherwise, copy the file from the old archive
|
||||
@@ -632,7 +632,7 @@ namespace SabreTools.Library.FileTypes
|
||||
// If the old file exists, delete it and replace
|
||||
if (File.Exists(archiveFileName))
|
||||
{
|
||||
FileTools.TryDeleteFile(archiveFileName);
|
||||
Utilities.TryDeleteFile(archiveFileName);
|
||||
}
|
||||
File.Move(tempFile, archiveFileName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user