[FileTypes] Rename methods to fit better

This commit is contained in:
Matt Nadareski
2018-02-15 23:52:57 -08:00
parent 5740cecc0d
commit d36cff2f9b
13 changed files with 56 additions and 57 deletions

View File

@@ -4403,7 +4403,7 @@ namespace SabreTools.Library.DatFiles
Folder archive = Utilities.GetArchive(file);
if (archive != null)
{
(fileStream, realName) = archive.ExtractEntryStream(datItem.Name);
(fileStream, realName) = archive.CopyToStream(datItem.Name);
}
}
// Otherwise, just open the filestream
@@ -4487,7 +4487,7 @@ namespace SabreTools.Library.DatFiles
Folder archive = Utilities.GetArchive(file);
if (archive != null)
{
(fileStream, realName) = archive.ExtractEntryStream(datItem.Name);
(fileStream, realName) = archive.CopyToStream(datItem.Name);
}
}
// Otherwise, just open the filestream
@@ -4577,7 +4577,7 @@ namespace SabreTools.Library.DatFiles
Folder archive = Utilities.GetArchive(file);
if (archive != null)
{
(fileStream, realName) = archive.ExtractEntryStream(datItem.Name);
(fileStream, realName) = archive.CopyToStream(datItem.Name);
}
}
// Otherwise, just open the filestream

View File

@@ -48,7 +48,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public new abstract bool ExtractAll(string outDir);
public override abstract bool CopyAll(string outDir);
/// <summary>
/// Attempt to extract an entry from an archive
@@ -56,7 +56,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>Name of the extracted file, null on error</returns>
public new abstract string ExtractEntry(string entryName, string outDir);
public override abstract string CopyToFile(string entryName, string outDir);
/// <summary>
/// Attempt to extract a stream from an archive
@@ -64,7 +64,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="realEntry">Output representing the entry name that was found</param>
/// <returns>MemoryStream representing the entry, null on error</returns>
public new abstract (MemoryStream, string) ExtractEntryStream(string entryName);
public override abstract (MemoryStream, string) CopyToStream(string entryName);
#endregion
@@ -104,7 +104,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public abstract bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false);
public override abstract bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false);
/// <summary>
/// Write an input stream to an archive
@@ -115,7 +115,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public abstract bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false);
public override abstract bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false);
/// <summary>
/// Write a set of input files to an archive (assuming the same output archive name)
@@ -126,7 +126,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public abstract bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false);
public override abstract bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false);
#endregion
}

View File

@@ -20,7 +20,6 @@ using SearchOption = System.IO.SearchOption;
using SeekOrigin = System.IO.SeekOrigin;
using Stream = System.IO.Stream;
#endif
using SharpCompress.Common;
namespace SabreTools.Library.FileTypes
{
@@ -66,7 +65,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public bool ExtractAll(string outDir)
public virtual bool CopyAll(string outDir)
{
// Copy all files from the current folder to the output directory recursively
try
@@ -92,7 +91,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>Name of the extracted file, null on error</returns>
public string ExtractEntry(string entryName, string outDir)
public virtual string CopyToFile(string entryName, string outDir)
{
string realentry = null;
@@ -131,7 +130,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="realEntry">Output representing the entry name that was found</param>
/// <returns>MemoryStream representing the entry, null on error</returns>
public (MemoryStream, string) ExtractEntryStream(string entryName)
public virtual (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
string realentry = null;
@@ -175,7 +174,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
/// <returns>List of BaseFile objects representing the found data</returns>
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
public List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
public virtual List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
{
if (_children == null || _children.Count == 0)
{
@@ -200,7 +199,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="input">Input file to get data from</param>
/// <returns>List of empty folders in the folder</returns>
public List<string> GetEmptyFolders()
public virtual List<string> GetEmptyFolders()
{
return Utilities.GetEmptyDirectories(_filename).ToList();
}
@@ -210,7 +209,7 @@ namespace SabreTools.Library.FileTypes
#region Writing
/// <summary>
/// Write an input file to a torrent LRZip file
/// Write an input file to an output folder
/// </summary>
/// <param name="inputFile">Input filename to be moved</param>
/// <param name="outDir">Output directory to build to</param>
@@ -219,13 +218,13 @@ namespace SabreTools.Library.FileTypes
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
public virtual bool Write(string inputFile, string outDir, Rom rom, bool date = false, bool romba = false)
{
throw new NotImplementedException();
}
/// <summary>
/// Write an input stream to a torrent LRZip file
/// Write an input stream to an output folder
/// </summary>
/// <param name="inputStream">Input stream to be moved</param>
/// <param name="outDir">Output directory to build to</param>
@@ -234,7 +233,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the write was a success, false otherwise</returns>
/// <remarks>This works for now, but it can be sped up by using Ionic.Zip or another zlib wrapper that allows for header values built-in. See edc's code.</remarks>
public bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false)
public virtual bool Write(Stream inputStream, string outDir, Rom rom, bool date = false, bool romba = false)
{
bool success = false;
@@ -308,7 +307,7 @@ namespace SabreTools.Library.FileTypes
}
/// <summary>
/// Write a set of input files to a torrent LRZip archive (assuming the same output archive name)
/// Write a set of input files to an output folder (assuming the same output archive name)
/// </summary>
/// <param name="inputFiles">Input files to be moved</param>
/// <param name="outDir">Output directory to build to</param>
@@ -316,7 +315,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="date">True if the date from the DAT should be used if available, false otherwise (default)</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false)
public virtual bool Write(List<string> inputFiles, string outDir, List<Rom> roms, bool date = false, bool romba = false)
{
throw new NotImplementedException();
}

View File

@@ -60,7 +60,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public override bool ExtractAll(string outDir)
public override bool CopyAll(string outDir)
{
bool encounteredErrors = true;
@@ -103,10 +103,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>Name of the extracted file, null on error</returns>
public override string ExtractEntry(string entryName, string outDir)
public override string CopyToFile(string entryName, string outDir)
{
// Try to extract a stream using the given information
(MemoryStream ms, string realEntry) = ExtractEntryStream(entryName);
(MemoryStream ms, string realEntry) = CopyToStream(entryName);
// If the memory stream and the entry name are both non-null, we write to file
if (ms != null && realEntry != null)
@@ -149,7 +149,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="realEntry">Output representing the entry name that was found</param>
/// <returns>MemoryStream representing the entry, null on error</returns>
public override (MemoryStream, string) ExtractEntryStream(string entryName)
public override (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
string realEntry = null;

View File

@@ -49,7 +49,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public override bool ExtractAll(string outDir)
public override bool CopyAll(string outDir)
{
throw new NotImplementedException();
}
@@ -60,7 +60,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>Name of the extracted file, null on error</returns>
public override string ExtractEntry(string entryName, string outDir)
public override string CopyToFile(string entryName, string outDir)
{
throw new NotImplementedException();
}
@@ -71,7 +71,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="realEntry">Output representing the entry name that was found</param>
/// <returns>MemoryStream representing the entry, null on error</returns>
public override (MemoryStream, string) ExtractEntryStream(string entryName)
public override (MemoryStream, string) CopyToStream(string entryName)
{
throw new NotImplementedException();
}

View File

@@ -49,7 +49,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public override bool ExtractAll(string outDir)
public override bool CopyAll(string outDir)
{
throw new NotImplementedException();
}
@@ -60,7 +60,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>Name of the extracted file, null on error</returns>
public override string ExtractEntry(string entryName, string outDir)
public override string CopyToFile(string entryName, string outDir)
{
throw new NotImplementedException();
}
@@ -71,7 +71,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="realEntry">Output representing the entry name that was found</param>
/// <returns>MemoryStream representing the entry, null on error</returns>
public override (MemoryStream, string) ExtractEntryStream(string entryName)
public override (MemoryStream, string) CopyToStream(string entryName)
{
throw new NotImplementedException();
}

View File

@@ -60,7 +60,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public override bool ExtractAll(string outDir)
public override bool CopyAll(string outDir)
{
bool encounteredErrors = true;
@@ -101,10 +101,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>Name of the extracted file, null on error</returns>
public override string ExtractEntry(string entryName, string outDir)
public override string CopyToFile(string entryName, string outDir)
{
// Try to extract a stream using the given information
(MemoryStream ms, string realEntry) = ExtractEntryStream(entryName);
(MemoryStream ms, string realEntry) = CopyToStream(entryName);
// If the memory stream and the entry name are both non-null, we write to file
if (ms != null && realEntry != null)
@@ -147,7 +147,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="realEntry">Output representing the entry name that was found</param>
/// <returns>MemoryStream representing the entry, null on error</returns>
public override (MemoryStream, string) ExtractEntryStream(string entryName)
public override (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
string realEntry = null;

View File

@@ -63,7 +63,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public override bool ExtractAll(string outDir)
public override bool CopyAll(string outDir)
{
bool encounteredErrors = true;
@@ -104,10 +104,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>Name of the extracted file, null on error</returns>
public override string ExtractEntry(string entryName, string outDir)
public override string CopyToFile(string entryName, string outDir)
{
// Try to extract a stream using the given information
(MemoryStream ms, string realEntry) = ExtractEntryStream(entryName);
(MemoryStream ms, string realEntry) = CopyToStream(entryName);
// If the memory stream and the entry name are both non-null, we write to file
if (ms != null && realEntry != null)
@@ -150,7 +150,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="realEntry">Output representing the entry name that was found</param>
/// <returns>MemoryStream representing the entry, null on error</returns>
public override (MemoryStream, string) ExtractEntryStream(string entryName)
public override (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
string realEntry = null;

View File

@@ -63,7 +63,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public override bool ExtractAll(string outDir)
public override bool CopyAll(string outDir)
{
bool encounteredErrors = true;
@@ -104,10 +104,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>Name of the extracted file, null on error</returns>
public override string ExtractEntry(string entryName, string outDir)
public override string CopyToFile(string entryName, string outDir)
{
// Try to extract a stream using the given information
(MemoryStream ms, string realEntry) = ExtractEntryStream(entryName);
(MemoryStream ms, string realEntry) = CopyToStream(entryName);
// If the memory stream and the entry name are both non-null, we write to file
if (ms != null && realEntry != null)
@@ -150,7 +150,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="realEntry">Output representing the entry name that was found</param>
/// <returns>MemoryStream representing the entry, null on error</returns>
public override (MemoryStream, string) ExtractEntryStream(string entryName)
public override (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
string realEntry = null;

View File

@@ -59,7 +59,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public override bool ExtractAll(string outDir)
public override bool CopyAll(string outDir)
{
bool encounteredErrors = true;
@@ -147,10 +147,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>Name of the extracted file, null on error</returns>
public override string ExtractEntry(string entryName, string outDir)
public override string CopyToFile(string entryName, string outDir)
{
// Try to extract a stream using the given information
(MemoryStream ms, string realEntry) = ExtractEntryStream(entryName);
(MemoryStream ms, string realEntry) = CopyToStream(entryName);
// If the memory stream and the entry name are both non-null, we write to file
if (ms != null && realEntry != null)
@@ -193,7 +193,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="realEntry">Output representing the entry name that was found</param>
/// <returns>MemoryStream representing the entry, null on error</returns>
public override (MemoryStream, string) ExtractEntryStream(string entryName)
public override (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
string realEntry = null;

View File

@@ -63,7 +63,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public override bool ExtractAll(string outDir)
public override bool CopyAll(string outDir)
{
bool encounteredErrors = true;
@@ -104,10 +104,10 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>Name of the extracted file, null on error</returns>
public override string ExtractEntry(string entryName, string outDir)
public override string CopyToFile(string entryName, string outDir)
{
// Try to extract a stream using the given information
(MemoryStream ms, string realEntry) = ExtractEntryStream(entryName);
(MemoryStream ms, string realEntry) = CopyToStream(entryName);
// If the memory stream and the entry name are both non-null, we write to file
if (ms != null && realEntry != null)
@@ -150,7 +150,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="realEntry">Output representing the entry name that was found</param>
/// <returns>MemoryStream representing the entry, null on error</returns>
public override (MemoryStream, string) ExtractEntryStream(string entryName)
public override (MemoryStream, string) CopyToStream(string entryName)
{
MemoryStream ms = new MemoryStream();
string realEntry = null;

View File

@@ -49,7 +49,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public override bool ExtractAll(string outDir)
public override bool CopyAll(string outDir)
{
throw new NotImplementedException();
}
@@ -60,7 +60,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>Name of the extracted file, null on error</returns>
public override string ExtractEntry(string entryName, string outDir)
public override string CopyToFile(string entryName, string outDir)
{
throw new NotImplementedException();
}
@@ -71,7 +71,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="realEntry">Output representing the entry name that was found</param>
/// <returns>MemoryStream representing the entry, null on error</returns>
public override (MemoryStream, string) ExtractEntryStream(string entryName)
public override (MemoryStream, string) CopyToStream(string entryName)
{
throw new NotImplementedException();
}

View File

@@ -49,7 +49,7 @@ namespace SabreTools.Library.FileTypes
/// </summary>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public override bool ExtractAll(string outDir)
public override bool CopyAll(string outDir)
{
throw new NotImplementedException();
}
@@ -60,7 +60,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="outDir">Output directory for archive extraction</param>
/// <returns>Name of the extracted file, null on error</returns>
public override string ExtractEntry(string entryName, string outDir)
public override string CopyToFile(string entryName, string outDir)
{
throw new NotImplementedException();
}
@@ -71,7 +71,7 @@ namespace SabreTools.Library.FileTypes
/// <param name="entryName">Name of the entry to be extracted</param>
/// <param name="realEntry">Output representing the entry name that was found</param>
/// <returns>MemoryStream representing the entry, null on error</returns>
public override (MemoryStream, string) ExtractEntryStream(string entryName)
public override (MemoryStream, string) CopyToStream(string entryName)
{
throw new NotImplementedException();
}