Extract out IO namespace, Part 3

This commit is contained in:
Matt Nadareski
2020-12-08 00:13:22 -08:00
parent 53f5d07ae4
commit 96f0a94b10
60 changed files with 950 additions and 1319 deletions

View File

@@ -72,7 +72,7 @@ namespace SabreTools.Library.FileTypes
Directory.CreateDirectory(outDir);
// Decompress the _filename stream
FileStream outstream = FileExtensions.TryCreate(Path.Combine(outDir, Path.GetFileNameWithoutExtension(this.Filename)));
FileStream outstream = File.Create(Path.Combine(outDir, Path.GetFileNameWithoutExtension(this.Filename)));
var gz = new gZip();
ZipReturn ret = gz.ZipFileOpen(this.Filename);
ret = gz.ZipFileOpenReadStream(0, out Stream gzstream, out ulong streamSize);
@@ -124,7 +124,7 @@ namespace SabreTools.Library.FileTypes
Directory.CreateDirectory(Path.GetDirectoryName(realEntry));
// Now open and write the file if possible
FileStream fs = FileExtensions.TryCreate(realEntry);
FileStream fs = File.Create(realEntry);
if (fs != null)
{
ms.Seek(0, SeekOrigin.Begin);
@@ -226,7 +226,7 @@ namespace SabreTools.Library.FileTypes
if (this.AvailableHashes == Hash.CRC)
{
gzipEntryRom.Filename = gamename;
using (BinaryReader br = new BinaryReader(FileExtensions.TryOpenRead(this.Filename)))
using (BinaryReader br = new BinaryReader(File.OpenRead(this.Filename)))
{
br.BaseStream.Seek(-8, SeekOrigin.End);
gzipEntryRom.CRC = br.ReadBytesBigEndian(4);
@@ -306,7 +306,7 @@ namespace SabreTools.Library.FileTypes
}
// Get the Romba-specific header data
BinaryReader br = new BinaryReader(FileExtensions.TryOpenRead(this.Filename));
BinaryReader br = new BinaryReader(File.OpenRead(this.Filename));
byte[] header = br.ReadBytes(12); // Get preamble header for checking
br.ReadBytes(16); // headermd5
br.ReadBytes(4); // headercrc
@@ -371,7 +371,7 @@ namespace SabreTools.Library.FileTypes
byte[] headermd5; // MD5
byte[] headercrc; // CRC
ulong headersz; // Int64 size
BinaryReader br = new BinaryReader(FileExtensions.TryOpenRead(this.Filename));
BinaryReader br = new BinaryReader(File.OpenRead(this.Filename));
header = br.ReadBytes(12);
headermd5 = br.ReadBytes(16);
headercrc = br.ReadBytes(4);
@@ -435,7 +435,7 @@ namespace SabreTools.Library.FileTypes
inputFile = Path.GetFullPath(inputFile);
// Get the file stream for the file and write out
return Write(FileExtensions.TryOpenRead(inputFile), outDir, rom);
return Write(File.OpenRead(inputFile), outDir, rom);
}
/// <summary>
@@ -474,7 +474,7 @@ namespace SabreTools.Library.FileTypes
if (!File.Exists(outfile))
{
// Compress the input stream
FileStream outputStream = FileExtensions.TryCreate(outfile);
FileStream outputStream = File.Create(outfile);
// Open the output file for writing
BinaryWriter sw = new BinaryWriter(outputStream);