[ALL] More temp standardization, naming standardization

This commit is contained in:
Matt Nadareski
2016-09-16 16:35:58 -07:00
parent c6c1c3de74
commit bf6d45a542
12 changed files with 230 additions and 230 deletions

View File

@@ -71,7 +71,7 @@ namespace SabreTools
foreach (string input in inputs)
{
DATFromDir dfd = new DATFromDir(input, datdata, false /* noMD5 */, false /* noSHA1 */, true /* bare */, false /* archivesAsFiles */,
true /* enableGzip */, false /* addBlanks */, false /* addDate */, "__temp__" /* tempdir */, 4 /* maxDegreeOfParallelism */, _logger);
true /* enableGzip */, false /* addBlanks */, false /* addDate */, "__temp__" /* tempDir */, 4 /* maxDegreeOfParallelism */, _logger);
dfd.Start();
DatTools.WriteDatfile(dfd.DatData, "", logger);
}

View File

@@ -66,7 +66,7 @@ namespace SabreTools
_enableGzip = enableGzip;
_addBlanks = addBlanks;
_addDate = addDate;
_tempDir = (String.IsNullOrEmpty(tempDir) ? Path.Combine(Path.GetTempPath(), "__temp__") : tempDir);
_tempDir = (String.IsNullOrEmpty(tempDir) ? Path.GetTempPath() : tempDir);
_maxDegreeOfParallelism = maxDegreeOfParallelism;
_logger = logger;
}

View File

@@ -14,7 +14,7 @@ namespace SabreTools
// Private instance variables
private string _systems;
private string _sources;
private string _outdir;
private string _outDir;
private string _connectionString;
private bool _norename;
private bool _old;
@@ -27,12 +27,12 @@ namespace SabreTools
/// </summary>
/// <param name="systems">Comma-separated list of systems to be included in the DAT (blank means all)</param>
/// <param name="sources">Comma-separated list of sources to be included in the DAT (blank means all)</param>
/// <param name="outdir">The output folder where the generated DAT will be put; blank means the current directory</param>
/// <param name="outDir">The output folder where the generated DAT will be put; blank means the current directory</param>
/// <param name="connectionString">Connection string for SQLite</param>
/// <param name="logger">Logger object for file or console output</param>
/// <param name="norename">True if files should not be renamed with system and/or source in merged mode (default false)</param>
/// <param name="old">True if the output file should be in ClrMamePro format (default false)</param>
public Generate(string systems, string sources, string outdir, string connectionString, Logger logger, bool norename = false, bool old = false)
public Generate(string systems, string sources, string outDir, string connectionString, Logger logger, bool norename = false, bool old = false)
{
_systems = systems;
_sources = sources;
@@ -42,12 +42,12 @@ namespace SabreTools
_logger = logger;
// Take care of special outfolder cases
_outdir = (outdir == "" ? Environment.CurrentDirectory + Path.DirectorySeparatorChar :
(!outdir.EndsWith(Path.DirectorySeparatorChar.ToString()) ? outdir + Path.DirectorySeparatorChar : outdir)
_outDir = (outDir == "" ? Environment.CurrentDirectory + Path.DirectorySeparatorChar :
(!outDir.EndsWith(Path.DirectorySeparatorChar.ToString()) ? outDir + Path.DirectorySeparatorChar : outDir)
);
if (_outdir != "" && !Directory.Exists(_outdir))
if (_outDir != "" && !Directory.Exists(_outDir))
{
Directory.CreateDirectory(_outdir);
Directory.CreateDirectory(_outDir);
}
}
@@ -179,7 +179,7 @@ namespace SabreTools
Files = dict,
};
return DatTools.WriteDatfile(datdata, _outdir, _logger);
return DatTools.WriteDatfile(datdata, _outDir, _logger);
}
/// <summary>

View File

@@ -14,7 +14,7 @@ namespace SabreTools
// Private instance variables
private List<string> _inputs;
private bool _restore;
private string _outdir;
private string _outDir;
private Logger _logger;
/// <summary>
@@ -22,13 +22,13 @@ namespace SabreTools
/// </summary>
/// <param name="inputs">Input file or folder names</param>
/// <param name="restore">False if we're extracting headers (default), true if we're restoring them</param>
/// <param name="outdir">Output directory to write new files to, blank defaults to rom folder</param>
/// <param name="outDir">Output directory to write new files to, blank defaults to rom folder</param>
/// <param name="logger">Logger object for file and console output</param>
public Headerer(List<string> inputs, bool restore, string outdir, Logger logger)
public Headerer(List<string> inputs, bool restore, string outDir, Logger logger)
{
_inputs = inputs;
_restore = restore;
_outdir = outdir;
_outDir = outDir;
_logger = logger;
}
@@ -38,9 +38,9 @@ namespace SabreTools
/// <returns>True if it succeeded, false otherwise</returns>
public bool Process()
{
if (_outdir != "" && !Directory.Exists(_outdir))
if (_outDir != "" && !Directory.Exists(_outDir))
{
Directory.CreateDirectory(_outdir);
Directory.CreateDirectory(_outDir);
}
bool success = true;
@@ -121,7 +121,7 @@ namespace SabreTools
}
// Otherwise, apply the rule to the file
string newfile = (_outdir == "" ? Path.GetFullPath(file) + ".new" : Path.Combine(_outdir, Path.GetFileName(file)));
string newfile = (_outDir == "" ? Path.GetFullPath(file) + ".new" : Path.Combine(_outDir, Path.GetFileName(file)));
Skippers.TransformFile(file, newfile, rule, _logger);
// If the output file doesn't exist, return false
@@ -208,9 +208,9 @@ namespace SabreTools
header = sldr.GetString(0);
_logger.User("Creating reheadered file: " +
(_outdir == "" ? Path.GetFullPath(file) + ".new" : Path.Combine(_outdir, Path.GetFileName(file))) + sub);
(_outDir == "" ? Path.GetFullPath(file) + ".new" : Path.Combine(_outDir, Path.GetFileName(file))) + sub);
FileTools.AppendBytesToFile(file,
(_outdir == "" ? Path.GetFullPath(file) + ".new" : Path.Combine(_outdir, Path.GetFileName(file))) + sub, header, string.Empty);
(_outDir == "" ? Path.GetFullPath(file) + ".new" : Path.Combine(_outDir, Path.GetFileName(file))) + sub, header, string.Empty);
_logger.User("Reheadered file created!");
}
}

View File

@@ -9,8 +9,8 @@ namespace SabreTools.Helper
// Private instance variables
private Dat _datdata;
private List<string> _inputs;
private string _outdir;
private string _tempdir;
private string _outDir;
private string _tempDir;
private bool _quickScan;
private bool _toFolder;
private bool _verify;
@@ -34,8 +34,8 @@ namespace SabreTools.Helper
/// </summary>
/// <param name="datdata">Name of the DAT to compare against</param>
/// <param name="inputs">List of input files/folders to check</param>
/// <param name="outdir">Output directory to use to build to</param>
/// <param name="tempdir">Temporary directory for archive extraction</param>
/// <param name="outDir">Output directory to use to build to</param>
/// <param name="tempDir">Temporary directory for archive extraction</param>
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
/// <param name="toFolder">True if files should be output to folder, false otherwise</param>
/// <param name="verify">True if output directory should be checked instead of rebuilt to, false otherwise</param>
@@ -48,14 +48,14 @@ namespace SabreTools.Helper
/// <param name="zip">Integer representing the archive handling level for Zip</param>
/// <param name="updateDat">True if the updated DAT should be output, false otherwise</param>
/// <param name="logger">Logger object for file and console output</param>
public SimpleSort(Dat datdata, List<string> inputs, string outdir, string tempdir,
public SimpleSort(Dat datdata, List<string> inputs, string outDir, string tempDir,
bool quickScan, bool toFolder, bool verify, bool delete, bool? torrentX, bool romba, int sevenzip,
int gz, int rar, int zip, bool updateDat, Logger logger)
{
_datdata = datdata;
_inputs = inputs;
_outdir = (outdir == "" ? "Rebuild" : outdir);
_tempdir = (tempdir == "" ? Path.Combine(Path.GetTempPath(), "__temp__") : tempdir);
_outDir = (outDir == "" ? "Rebuild" : outDir);
_tempDir = (String.IsNullOrEmpty(tempDir) ? Path.GetTempPath() : tempDir);
_quickScan = quickScan;
_toFolder = toFolder;
_verify = verify;
@@ -84,20 +84,20 @@ namespace SabreTools.Helper
public bool StartProcessing()
{
// First, check that the output directory exists
if (!Directory.Exists(_outdir))
if (!Directory.Exists(_outDir))
{
Directory.CreateDirectory(_outdir);
_outdir = Path.GetFullPath(_outdir);
Directory.CreateDirectory(_outDir);
_outDir = Path.GetFullPath(_outDir);
}
// Then create or clean the temp directory
if (!Directory.Exists(_tempdir))
if (!Directory.Exists(_tempDir))
{
Directory.CreateDirectory(_tempdir);
Directory.CreateDirectory(_tempDir);
}
else
{
FileTools.CleanDirectory(_tempdir);
FileTools.CleanDirectory(_tempDir);
}
if (_verify)
@@ -120,7 +120,7 @@ namespace SabreTools.Helper
// Enumerate all files from the output directory
List<string> files = new List<string>();
foreach (string file in Directory.EnumerateFiles(_outdir, "*", SearchOption.AllDirectories))
foreach (string file in Directory.EnumerateFiles(_outDir, "*", SearchOption.AllDirectories))
{
_logger.Log("File found: '" + file + "'");
files.Add(Path.GetFullPath(file));
@@ -135,7 +135,7 @@ namespace SabreTools.Helper
foreach (string input in _inputs)
{
DATFromDir dfd = new DATFromDir(input, _datdata, false /* noMD5 */, false /* noSHA1 */, true /* bare */, false /* archivesAsFiles */,
true /* enableGzip */, false /* addBlanks */, false /* addDate */, "" /* tempdir */, 4 /* maxDegreeOfParallelism */, _logger);
true /* enableGzip */, false /* addBlanks */, false /* addDate */, "" /* tempDir */, 4 /* maxDegreeOfParallelism */, _logger);
dfd.Start();
_datdata = dfd.DatData;
}
@@ -224,15 +224,15 @@ namespace SabreTools.Helper
for (int i = 0; i < files.Count; i++)
{
success &= RebuildToOutputHelper(files[i], i, files.Count);
FileTools.CleanDirectory(_tempdir);
FileTools.CleanDirectory(_tempDir);
}
// Now one final delete of the temp directory
while (Directory.Exists(_tempdir))
while (Directory.Exists(_tempDir))
{
try
{
Directory.Delete(_tempdir, true);
Directory.Delete(_tempDir, true);
}
catch
{
@@ -315,7 +315,7 @@ namespace SabreTools.Helper
if (_toFolder)
{
// Copy file to output directory
string gamedir = Path.Combine(_outdir, found.Machine.Name);
string gamedir = Path.Combine(_outDir, found.Machine.Name);
if (!Directory.Exists(gamedir))
{
Directory.CreateDirectory(gamedir);
@@ -332,15 +332,15 @@ namespace SabreTools.Helper
{
if (_torrentX == true)
{
FileTools.WriteTorrentZip(input, _outdir, found, _logger);
FileTools.WriteTorrentZip(input, _outDir, found, _logger);
}
else if (_torrentX == false)
{
FileTools.WriteTorrentGZ(input, _outdir, _romba, _logger);
FileTools.WriteTorrentGZ(input, _outDir, _romba, _logger);
}
else
{
FileTools.WriteToArchive(input, _outdir, found);
FileTools.WriteToArchive(input, _outDir, found);
}
}
}
@@ -386,7 +386,7 @@ namespace SabreTools.Helper
if (_toFolder)
{
// Copy file to output directory
string gamedir = Path.Combine(_outdir, found.Machine.Name);
string gamedir = Path.Combine(_outDir, found.Machine.Name);
if (!Directory.Exists(gamedir))
{
Directory.CreateDirectory(gamedir);
@@ -403,15 +403,15 @@ namespace SabreTools.Helper
{
if (_torrentX == true)
{
FileTools.WriteTorrentZip(newinput, _outdir, found, _logger);
FileTools.WriteTorrentZip(newinput, _outDir, found, _logger);
}
else if (_torrentX == false)
{
FileTools.WriteTorrentGZ(newinput, _outdir, _romba, _logger);
FileTools.WriteTorrentGZ(newinput, _outDir, _romba, _logger);
}
else
{
FileTools.WriteToArchive(newinput, _outdir, found);
FileTools.WriteToArchive(newinput, _outDir, found);
}
}
@@ -436,7 +436,7 @@ namespace SabreTools.Helper
if (_toFolder)
{
// Copy file to output directory
string gamedir = Path.Combine(_outdir, found.Machine.Name);
string gamedir = Path.Combine(_outDir, found.Machine.Name);
if (!Directory.Exists(gamedir))
{
Directory.CreateDirectory(gamedir);
@@ -454,15 +454,15 @@ namespace SabreTools.Helper
_logger.Log("Matched name: " + newfound.Name);
if (_torrentX == true)
{
FileTools.WriteTorrentZip(input, _outdir, newfound, _logger);
FileTools.WriteTorrentZip(input, _outDir, newfound, _logger);
}
else if (_torrentX == false)
{
FileTools.WriteTorrentGZ(input, _outdir, _romba, _logger);
FileTools.WriteTorrentGZ(input, _outDir, _romba, _logger);
}
else
{
FileTools.WriteToArchive(input, _outdir, newfound);
FileTools.WriteToArchive(input, _outDir, newfound);
}
}
}
@@ -516,10 +516,10 @@ namespace SabreTools.Helper
{
// Copy file to output directory
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + found.Name + "'");
string outfile = FileTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
string outfile = FileTools.ExtractSingleItemFromArchive(input, rom.Name, _tempDir, _logger);
if (File.Exists(outfile))
{
string gamedir = Path.Combine(_outdir, found.Machine.Name);
string gamedir = Path.Combine(_outDir, found.Machine.Name);
if (!Directory.Exists(gamedir))
{
Directory.CreateDirectory(gamedir);
@@ -539,20 +539,20 @@ namespace SabreTools.Helper
if (Build.MonoEnvironment || _torrentX == false)
{
string outfile = FileTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
string outfile = FileTools.ExtractSingleItemFromArchive(input, rom.Name, _tempDir, _logger);
if (File.Exists(outfile))
{
if (_torrentX == true)
{
FileTools.WriteTorrentZip(outfile, _outdir, found, _logger);
FileTools.WriteTorrentZip(outfile, _outDir, found, _logger);
}
else if (_torrentX == false)
{
FileTools.WriteTorrentGZ(outfile, _outdir, _romba, _logger);
FileTools.WriteTorrentGZ(outfile, _outDir, _romba, _logger);
}
else
{
FileTools.WriteToArchive(outfile, _outdir, found);
FileTools.WriteToArchive(outfile, _outDir, found);
}
try
@@ -564,7 +564,7 @@ namespace SabreTools.Helper
}
else
{
FileTools.CopyFileBetweenArchives(input, _outdir, rom.Name, found, _logger);
FileTools.CopyFileBetweenArchives(input, _outDir, rom.Name, found, _logger);
}
}
}
@@ -574,7 +574,7 @@ namespace SabreTools.Helper
else
{
// Now, if the file is a supported archive type, also run on all files within
bool encounteredErrors = FileTools.ExtractArchive(input, _tempdir, _7z, _gz, _rar, _zip, _logger);
bool encounteredErrors = FileTools.ExtractArchive(input, _tempDir, _7z, _gz, _rar, _zip, _logger);
// Remove the current file if we are in recursion so it's not picked up in the next step
if (recurse)
@@ -593,7 +593,7 @@ namespace SabreTools.Helper
if (!encounteredErrors)
{
_logger.Log("Archive found! Successfully extracted");
foreach (string file in Directory.EnumerateFiles(_tempdir, "*", SearchOption.AllDirectories))
foreach (string file in Directory.EnumerateFiles(_tempDir, "*", SearchOption.AllDirectories))
{
success &= RebuildToOutputHelper(file, index, total, true);
}
@@ -627,14 +627,14 @@ namespace SabreTools.Helper
*/
// Assuming archived sets, move all toplevel folders to temp
foreach (string directory in Directory.EnumerateDirectories(_outdir, "*", SearchOption.TopDirectoryOnly))
foreach (string directory in Directory.EnumerateDirectories(_outDir, "*", SearchOption.TopDirectoryOnly))
{
Directory.Move(directory, Path.Combine(_tempdir, Path.GetFileNameWithoutExtension(directory)));
Directory.Move(directory, Path.Combine(_tempDir, Path.GetFileNameWithoutExtension(directory)));
}
// Now process the inputs (assumed that it's archived sets as of right now
Dictionary<string, List<Rom>> scanned = new Dictionary<string, List<Rom>>();
foreach (string archive in Directory.EnumerateFiles(_outdir, "*", SearchOption.AllDirectories))
foreach (string archive in Directory.EnumerateFiles(_outDir, "*", SearchOption.AllDirectories))
{
// If we are in quickscan, get the list of roms that way
List<Rom> roms = new List<Rom>();
@@ -645,7 +645,7 @@ namespace SabreTools.Helper
// Otherwise, extract it and get info one by one
else
{
string temparcdir = Path.Combine(_tempdir, Path.GetFileNameWithoutExtension(archive));
string temparcdir = Path.Combine(_tempDir, Path.GetFileNameWithoutExtension(archive));
FileTools.ExtractArchive(Path.GetFullPath(archive), temparcdir, _logger);
foreach (string tempfile in Directory.EnumerateFiles(temparcdir, "*", SearchOption.AllDirectories))
{
@@ -745,20 +745,20 @@ namespace SabreTools.Helper
bool success = true;
// First, check that the output directory exists
if (!Directory.Exists(_outdir))
if (!Directory.Exists(_outDir))
{
Directory.CreateDirectory(_outdir);
_outdir = Path.GetFullPath(_outdir);
Directory.CreateDirectory(_outDir);
_outDir = Path.GetFullPath(_outDir);
}
// Then create or clean the temp directory
if (!Directory.Exists(_tempdir))
if (!Directory.Exists(_tempDir))
{
Directory.CreateDirectory(_tempdir);
Directory.CreateDirectory(_tempDir);
}
else
{
FileTools.CleanDirectory(_tempdir);
FileTools.CleanDirectory(_tempDir);
}
// Now process all of the inputs
@@ -774,26 +774,26 @@ namespace SabreTools.Helper
if (shouldExternalProcess)
{
_logger.User("Processing file " + input);
success &= FileTools.WriteTorrentGZ(input, _outdir, _romba, _logger);
success &= FileTools.WriteTorrentGZ(input, _outDir, _romba, _logger);
}
// Process the file as an archive, if necessary
if (shouldInternalProcess)
{
// Now, if the file is a supported archive type, also run on all files within
bool encounteredErrors = FileTools.ExtractArchive(input, _tempdir, _7z, _gz, _rar, _zip, _logger);
bool encounteredErrors = FileTools.ExtractArchive(input, _tempDir, _7z, _gz, _rar, _zip, _logger);
// If no errors were encountered, we loop through the temp directory
if (!encounteredErrors)
{
_logger.Log("Archive found! Successfully extracted");
foreach (string file in Directory.EnumerateFiles(_tempdir, "*", SearchOption.AllDirectories))
foreach (string file in Directory.EnumerateFiles(_tempDir, "*", SearchOption.AllDirectories))
{
_logger.User("Processing extracted file " + file);
success &= FileTools.WriteTorrentGZ(file, _outdir, _romba, _logger);
success &= FileTools.WriteTorrentGZ(file, _outDir, _romba, _logger);
}
FileTools.CleanDirectory(_tempdir);
FileTools.CleanDirectory(_tempDir);
}
}
@@ -814,11 +814,11 @@ namespace SabreTools.Helper
}
// Now one final delete of the temp directory
while (Directory.Exists(_tempdir))
while (Directory.Exists(_tempDir))
{
try
{
Directory.Delete(_tempdir, true);
Directory.Delete(_tempDir, true);
}
catch
{
@@ -827,19 +827,19 @@ namespace SabreTools.Helper
}
// If we're in romba mode and the size file doesn't exist, create it
if (_romba && !File.Exists(Path.Combine(_outdir, ".romba_size")))
if (_romba && !File.Exists(Path.Combine(_outDir, ".romba_size")))
{
// Get the size of all of the files in the output folder
long size = 0;
foreach (string file in Directory.EnumerateFiles(_outdir, "*", SearchOption.AllDirectories))
foreach (string file in Directory.EnumerateFiles(_outDir, "*", SearchOption.AllDirectories))
{
FileInfo tempinfo = new FileInfo(file);
size += tempinfo.Length;
}
// Write out the value to each of the romba depot files
using (StreamWriter tw = new StreamWriter(File.Open(Path.Combine(_outdir, ".romba_size"), FileMode.Create, FileAccess.Write)))
using (StreamWriter twb = new StreamWriter(File.Open(Path.Combine(_outdir, ".romba_size.backup"), FileMode.Create, FileAccess.Write)))
using (StreamWriter tw = new StreamWriter(File.Open(Path.Combine(_outDir, ".romba_size"), FileMode.Create, FileAccess.Write)))
using (StreamWriter twb = new StreamWriter(File.Open(Path.Combine(_outDir, ".romba_size.backup"), FileMode.Create, FileAccess.Write)))
{
tw.Write(size);
twb.Write(size);

View File

@@ -2103,12 +2103,12 @@ namespace SabreTools.Helper
/// <summary>
/// Output user defined merge
/// </summary>
/// <param name="outdir">Output directory to write the DATs to</param>
/// <param name="outDir">Output directory to write the DATs to</param>
/// <param name="inputs">List of inputs to write out from</param>
/// <param name="userData">Main DatData to draw information from</param>
/// <param name="datHeaders">Dat headers used optionally</param>
/// <param name="logger">Logging object for console and file output</param>
public static void MergeNoDiff(string outdir, Dat userData, List<string> inputs, List<Dat> datHeaders, Logger logger)
public static void MergeNoDiff(string outDir, Dat userData, List<string> inputs, List<Dat> datHeaders, Logger logger)
{
// If we're in SuperDAT mode, prefix all games with their respective DATs
if (userData.Type == "SuperDAT")
@@ -2137,7 +2137,7 @@ namespace SabreTools.Helper
// Output a DAT only if there are roms
if (userData.Files.Count != 0)
{
WriteDatfile(userData, outdir, logger);
WriteDatfile(userData, outDir, logger);
}
}
@@ -2151,7 +2151,7 @@ namespace SabreTools.Helper
/// <param name="inputFileNames">Names of the input files and/or folders</param>
/// <param name="datdata">User specified inputs contained in a DatData object</param>
/// <param name="outputFormat">Non-zero flag for output format, zero otherwise for default</param>
/// <param name="outputDirectory">Optional param for output directory</param>
/// <param name="outDir">Optional param for output directory</param>
/// <param name="merge">True if input files should be merged into a single file, false otherwise</param>
/// <param name="diff">Non-zero flag for diffing mode, zero otherwise</param>
/// <param name="cascade">True if the diffed files should be cascade diffed, false if diffed files should be reverse cascaded, null otherwise</param>
@@ -2175,7 +2175,7 @@ namespace SabreTools.Helper
/// <param name="root">String representing root directory to compare against for length calculation</param>
/// <param name="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</param>
/// <param name="logger">Logging object for console and file output</param>
public static void Update(List<string> inputFileNames, Dat datdata, OutputFormat outputFormat, string outputDirectory, bool merge,
public static void Update(List<string> inputFileNames, Dat datdata, OutputFormat outputFormat, string outDir, bool merge,
DiffMode diff, bool? cascade, bool inplace, bool skip, bool bare, bool clean, bool softlist, string gamename, string romname, string romtype,
long sgt, long slt, long seq, string crc, string md5, string sha1, bool? nodump, bool trim, bool single, string root, int maxDegreeOfParallelism,
Logger logger)
@@ -2231,23 +2231,23 @@ namespace SabreTools.Helper
// Create a dictionary of all ROMs from the input DATs
Dat userData;
List<Dat> datHeaders = PopulateUserData(newInputFileNames, inplace, clean, softlist,
outputDirectory, datdata, out userData, gamename, romname, romtype, sgt, slt, seq,
outDir, datdata, out userData, gamename, romname, romtype, sgt, slt, seq,
crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, logger);
// Modify the Dictionary if necessary and output the results
if (diff != 0 && cascade == null)
{
DiffNoCascade(diff, outputDirectory, userData, newInputFileNames, logger);
DiffNoCascade(diff, outDir, userData, newInputFileNames, logger);
}
// If we're in cascade and diff, output only cascaded diffs
else if (diff != 0 && cascade != null)
{
DiffCascade(outputDirectory, inplace, userData, newInputFileNames, datHeaders, skip, logger);
DiffCascade(outDir, inplace, userData, newInputFileNames, datHeaders, skip, logger);
}
// Output all entries with user-defined merge
else
{
MergeNoDiff(outputDirectory, userData, newInputFileNames, datHeaders, logger);
MergeNoDiff(outDir, userData, newInputFileNames, datHeaders, logger);
}
}
// Otherwise, loop through all of the inputs individually
@@ -2274,7 +2274,7 @@ namespace SabreTools.Helper
// If we have roms, output them
if (innerDatdata.Files.Count != 0)
{
WriteDatfile(innerDatdata, (outputDirectory == "" ? Path.GetDirectoryName(inputFileName) : outputDirectory), logger, overwrite: (outputDirectory != ""));
WriteDatfile(innerDatdata, (outDir == "" ? Path.GetDirectoryName(inputFileName) : outDir), logger, overwrite: (outDir != ""));
}
}
else if (Directory.Exists(inputFileName))
@@ -2294,7 +2294,7 @@ namespace SabreTools.Helper
// If we have roms, output them
if (innerDatdata.Files != null && innerDatdata.Files.Count != 0)
{
WriteDatfile(innerDatdata, (outputDirectory == "" ? Path.GetDirectoryName(file) : outputDirectory + Path.GetDirectoryName(file).Remove(0, inputFileName.Length - 1)), logger, overwrite: (outputDirectory != ""));
WriteDatfile(innerDatdata, (outDir == "" ? Path.GetDirectoryName(file) : outDir + Path.GetDirectoryName(file).Remove(0, inputFileName.Length - 1)), logger, overwrite: (outDir != ""));
}
});
}
@@ -2327,7 +2327,7 @@ namespace SabreTools.Helper
/// <param name="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</param>
/// <param name="logger">Logging object for console and file output</param>
/// <returns>List of DatData objects representing headers</returns>
private static List<Dat> PopulateUserData(List<string> inputs, bool inplace, bool clean, bool softlist, string outdir,
private static List<Dat> PopulateUserData(List<string> inputs, bool inplace, bool clean, bool softlist, string outDir,
Dat inputDat, out Dat userData, string gamename, string romname, string romtype, long sgt, long slt, long seq, string crc,
string md5, string sha1, bool? nodump, bool trim, bool single, string root, int maxDegreeOfParallelism, Logger logger)
{
@@ -2389,11 +2389,11 @@ namespace SabreTools.Helper
/// Output non-cascading diffs
/// </summary>
/// <param name="diff">Non-zero flag for diffing mode, zero otherwise</param>
/// <param name="outdir">Output directory to write the DATs to</param>
/// <param name="outDir">Output directory to write the DATs to</param>
/// <param name="userData">Main DatData to draw information from</param>
/// <param name="inputs">List of inputs to write out from</param>
/// <param name="logger">Logging object for console and file output</param>
public static void DiffNoCascade(DiffMode diff, string outdir, Dat userData, List<string> inputs, Logger logger)
public static void DiffNoCascade(DiffMode diff, string outDir, Dat userData, List<string> inputs, Logger logger)
{
DateTime start = DateTime.Now;
logger.User("Initializing all output DATs");
@@ -2532,13 +2532,13 @@ namespace SabreTools.Helper
// Output the difflist (a-b)+(b-a) diff
if ((diff & DiffMode.NoDupes) != 0)
{
WriteDatfile(outerDiffData, outdir, logger);
WriteDatfile(outerDiffData, outDir, logger);
}
// Output the (ab) diff
if ((diff & DiffMode.Dupes) != 0)
{
WriteDatfile(dupeData, outdir, logger);
WriteDatfile(dupeData, outDir, logger);
}
// Output the individual (a-b) DATs
@@ -2547,7 +2547,7 @@ namespace SabreTools.Helper
for (int j = 0; j < inputs.Count; j++)
{
// If we have an output directory set, replace the path
string path = outdir + (Path.GetDirectoryName(inputs[j].Split('¬')[0]).Remove(0, inputs[j].Split('¬')[1].Length));
string path = outDir + (Path.GetDirectoryName(inputs[j].Split('¬')[0]).Remove(0, inputs[j].Split('¬')[1].Length));
// If we have more than 0 roms, output
if (outDats[j].Files.Count > 0)
@@ -2562,14 +2562,14 @@ namespace SabreTools.Helper
/// <summary>
/// Output cascading diffs
/// </summary>
/// <param name="outdir">Output directory to write the DATs to</param>
/// <param name="outDir">Output directory to write the DATs to</param>
/// <param name="inplace">True if cascaded diffs are outputted in-place, false otherwise</param>
/// <param name="userData">Main DatData to draw information from</param>
/// <param name="inputs">List of inputs to write out from</param>
/// <param name="datHeaders">Dat headers used optionally</param>
/// <param name="skip">True if the first cascaded diff file should be skipped on output, false otherwise</param>
/// <param name="logger">Logging object for console and file output</param>
public static void DiffCascade(string outdir, bool inplace, Dat userData, List<string> inputs, List<Dat> datHeaders, bool skip, Logger logger)
public static void DiffCascade(string outDir, bool inplace, Dat userData, List<string> inputs, List<Dat> datHeaders, bool skip, Logger logger)
{
string post = "";
@@ -2588,7 +2588,7 @@ namespace SabreTools.Helper
Dat diffData;
// If we're in inplace mode, take the appropriate DatData object already stored
if (inplace || !String.IsNullOrEmpty(outdir))
if (inplace || !String.IsNullOrEmpty(outDir))
{
diffData = datHeaders[j];
}
@@ -2646,9 +2646,9 @@ namespace SabreTools.Helper
{
path = Path.GetDirectoryName(inputs[j].Split('¬')[0]);
}
else if (!String.IsNullOrEmpty(outdir))
else if (!String.IsNullOrEmpty(outDir))
{
path = outdir + (Path.GetDirectoryName(inputs[j].Split('¬')[0]).Remove(0, inputs[j].Split('¬')[1].Length));
path = outDir + (Path.GetDirectoryName(inputs[j].Split('¬')[0]).Remove(0, inputs[j].Split('¬')[1].Length));
}
// If we have more than 0 roms, output
@@ -3368,13 +3368,13 @@ namespace SabreTools.Helper
/// Split a DAT by input extensions
/// </summary>
/// <param name="filename">Name of the file to be split</param>
/// <param name="outdir">Name of the directory to write the DATs out to</param>
/// <param name="outDir">Name of the directory to write the DATs out to</param>
/// <param name="basepath">Parent path for replacement</param>
/// <param name="extA">List of extensions to split on (first DAT)</param>
/// <param name="extB">List of extensions to split on (second DAT)</param>
/// <param name="logger">Logger object for console and file writing</param>
/// <returns>True if split succeeded, false otherwise</returns>
public static bool SplitByExt(string filename, string outdir, string basepath, List<string> extA, List<string> extB, Logger logger)
public static bool SplitByExt(string filename, string outDir, string basepath, List<string> extA, List<string> extB, Logger logger)
{
// Make sure all of the extensions have a dot at the beginning
List<string> newExtA = new List<string>();
@@ -3500,18 +3500,18 @@ namespace SabreTools.Helper
}
// Get the output directory
if (outdir != "")
if (outDir != "")
{
outdir = outdir + Path.GetDirectoryName(filename).Remove(0, basepath.Length - 1);
outDir = outDir + Path.GetDirectoryName(filename).Remove(0, basepath.Length - 1);
}
else
{
outdir = Path.GetDirectoryName(filename);
outDir = Path.GetDirectoryName(filename);
}
// Then write out both files
bool success = WriteDatfile(datdataA, outdir, logger);
success &= WriteDatfile(datdataB, outdir, logger);
bool success = WriteDatfile(datdataA, outDir, logger);
success &= WriteDatfile(datdataB, outDir, logger);
return success;
}
@@ -3520,11 +3520,11 @@ namespace SabreTools.Helper
/// Split a DAT by best available hashes
/// </summary>
/// <param name="filename">Name of the file to be split</param>
/// <param name="outdir">Name of the directory to write the DATs out to</param>
/// <param name="outDir">Name of the directory to write the DATs out to</param>
/// <param name="basepath">Parent path for replacement</param>
/// <param name="logger">Logger object for console and file writing</param>
/// <returns>True if split succeeded, false otherwise</returns>
public static bool SplitByHash(string filename, string outdir, string basepath, Logger logger)
public static bool SplitByHash(string filename, string outDir, string basepath, Logger logger)
{
// Sanitize the basepath to be more predictable
basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar);
@@ -3698,13 +3698,13 @@ namespace SabreTools.Helper
}
// Get the output directory
if (outdir != "")
if (outDir != "")
{
outdir = outdir + Path.GetDirectoryName(filename).Remove(0, basepath.Length - 1);
outDir = outDir + Path.GetDirectoryName(filename).Remove(0, basepath.Length - 1);
}
else
{
outdir = Path.GetDirectoryName(filename);
outDir = Path.GetDirectoryName(filename);
}
// Now, output all of the files to the output directory
@@ -3712,19 +3712,19 @@ namespace SabreTools.Helper
bool success = true;
if (nodump.Files.Count > 0)
{
success &= WriteDatfile(nodump, outdir, logger);
success &= WriteDatfile(nodump, outDir, logger);
}
if (sha1.Files.Count > 0)
{
success &= WriteDatfile(sha1, outdir, logger);
success &= WriteDatfile(sha1, outDir, logger);
}
if (md5.Files.Count > 0)
{
success &= WriteDatfile(md5, outdir, logger);
success &= WriteDatfile(md5, outDir, logger);
}
if (crc.Files.Count > 0)
{
success &= WriteDatfile(crc, outdir, logger);
success &= WriteDatfile(crc, outDir, logger);
}
return success;
@@ -3734,11 +3734,11 @@ namespace SabreTools.Helper
/// Split a DAT by type of Rom
/// </summary>
/// <param name="filename">Name of the file to be split</param>
/// <param name="outdir">Name of the directory to write the DATs out to</param>
/// <param name="outDir">Name of the directory to write the DATs out to</param>
/// <param name="basepath">Parent path for replacement</param>
/// <param name="logger">Logger object for console and file writing</param>
/// <returns>True if split succeeded, false otherwise</returns>
public static bool SplitByType(string filename, string outdir, string basepath, Logger logger)
public static bool SplitByType(string filename, string outDir, string basepath, Logger logger)
{
// Sanitize the basepath to be more predictable
basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar);
@@ -3877,13 +3877,13 @@ namespace SabreTools.Helper
}
// Get the output directory
if (outdir != "")
if (outDir != "")
{
outdir = outdir + Path.GetDirectoryName(filename).Remove(0, basepath.Length - 1);
outDir = outDir + Path.GetDirectoryName(filename).Remove(0, basepath.Length - 1);
}
else
{
outdir = Path.GetDirectoryName(filename);
outDir = Path.GetDirectoryName(filename);
}
// Now, output all of the files to the output directory
@@ -3891,15 +3891,15 @@ namespace SabreTools.Helper
bool success = true;
if (romdat.Files.Count > 0)
{
success &= WriteDatfile(romdat, outdir, logger);
success &= WriteDatfile(romdat, outDir, logger);
}
if (diskdat.Files.Count > 0)
{
success &= WriteDatfile(diskdat, outdir, logger);
success &= WriteDatfile(diskdat, outDir, logger);
}
if (sampledat.Files.Count > 0)
{
success &= WriteDatfile(sampledat, outdir, logger);
success &= WriteDatfile(sampledat, outDir, logger);
}
return success;

View File

@@ -22,10 +22,10 @@ namespace SabreTools.Helper
/// Copy a file to an output archive
/// </summary>
/// <param name="inputFile">Input filename to be moved</param>
/// <param name="outputDirectory">Output directory to build to</param>
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">RomData representing the new information</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public static bool WriteToArchive(string inputFile, string outputDirectory, Rom rom)
public static bool WriteToArchive(string inputFile, string outDir, Rom rom)
{
bool success = false;
@@ -35,7 +35,7 @@ namespace SabreTools.Helper
return success;
}
string archiveFileName = Path.Combine(outputDirectory, rom.Machine.Name + ".zip");
string archiveFileName = Path.Combine(outDir, rom.Machine.Name + ".zip");
ZipArchive outarchive = null;
try
@@ -92,11 +92,11 @@ namespace SabreTools.Helper
/// Copy a file to an output torrentzip archive
/// </summary>
/// <param name="inputFile">Input filename to be moved</param>
/// <param name="outputDirectory">Output directory to build to</param>
/// <param name="outDir">Output directory to build to</param>
/// <param name="rom">RomData representing the new information</param>
/// <param name="logger">Logger object for file and console output</param>
/// <returns>True if the archive was written properly, false otherwise</returns>
public static bool WriteTorrentZip(string inputFile, string outputDirectory, Rom rom, Logger logger)
public static bool WriteTorrentZip(string inputFile, string outDir, Rom rom, Logger logger)
{
bool success = false;
string tempFile = Path.GetTempFileName();
@@ -107,7 +107,7 @@ namespace SabreTools.Helper
return success;
}
string archiveFileName = Path.Combine(outputDirectory, rom.Machine.Name + ".zip");
string archiveFileName = Path.Combine(outDir, rom.Machine.Name + ".zip");
// If the output file exists but isn't a zip archive, return
if (File.Exists(archiveFileName) && GetCurrentArchiveType(archiveFileName, logger) != ArchiveType.Zip)
@@ -256,12 +256,12 @@ namespace SabreTools.Helper
/// Write an input file to a torrent GZ file
/// </summary>
/// <param name="input">File to write from</param>
/// <param name="outputDirectory">Directory to write archive to</param>
/// <param name="outDir">Directory to write archive to</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="logger">Logger object for file and console output</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 static bool WriteTorrentGZ(string input, string outputDirectory, bool romba, Logger logger)
public static bool WriteTorrentGZ(string input, string outDir, bool romba, Logger logger)
{
// Check that the input file exists
if (!File.Exists(input))
@@ -272,17 +272,17 @@ namespace SabreTools.Helper
input = Path.GetFullPath(input);
// Make sure the output directory exists
if (!Directory.Exists(outputDirectory))
if (!Directory.Exists(outDir))
{
Directory.CreateDirectory(outputDirectory);
Directory.CreateDirectory(outDir);
}
outputDirectory = Path.GetFullPath(outputDirectory);
outDir = Path.GetFullPath(outDir);
// Now get the Rom info for the file so we have hashes and size
Rom rom = FileTools.GetSingleFileInfo(input);
// If it doesn't exist, create the output file and then write
string outfile = Path.Combine(outputDirectory, rom.HashData.SHA1 + ".gz");
string outfile = Path.Combine(outDir, rom.HashData.SHA1 + ".gz");
using (FileStream inputstream = new FileStream(input, FileMode.Open))
using (GZipStream output = new GZipStream(File.Open(outfile, FileMode.Create, FileAccess.Write), CompressionMode.Compress))
{
@@ -325,15 +325,15 @@ namespace SabreTools.Helper
if (romba)
{
string subfolder = Path.Combine(rom.HashData.SHA1.Substring(0, 2), rom.HashData.SHA1.Substring(2, 2), rom.HashData.SHA1.Substring(4, 2), rom.HashData.SHA1.Substring(6, 2));
outputDirectory = Path.Combine(outputDirectory, subfolder);
if (!Directory.Exists(outputDirectory))
outDir = Path.Combine(outDir, subfolder);
if (!Directory.Exists(outDir))
{
Directory.CreateDirectory(outputDirectory);
Directory.CreateDirectory(outDir);
}
try
{
File.Move(outfile, Path.Combine(outputDirectory, Path.GetFileName(outfile)));
File.Move(outfile, Path.Combine(outDir, Path.GetFileName(outfile)));
}
catch (Exception ex)
{
@@ -353,43 +353,43 @@ namespace SabreTools.Helper
/// Attempt to extract a file as an archive
/// </summary>
/// <param name="input">Name of the file to be extracted</param>
/// <param name="tempdir">Temporary directory for archive extraction</param>
/// <param name="tempDir">Temporary directory for archive extraction</param>
/// <param name="logger">Logger object for file and console output</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public static bool ExtractArchive(string input, string tempdir, Logger logger)
public static bool ExtractArchive(string input, string tempDir, Logger logger)
{
return ExtractArchive(input, tempdir, ArchiveScanLevel.Both, ArchiveScanLevel.External, ArchiveScanLevel.External, ArchiveScanLevel.Both, logger);
return ExtractArchive(input, tempDir, ArchiveScanLevel.Both, ArchiveScanLevel.External, ArchiveScanLevel.External, ArchiveScanLevel.Both, logger);
}
/// <summary>
/// Attempt to extract a file as an archive
/// </summary>
/// <param name="input">Name of the file to be extracted</param>
/// <param name="tempdir">Temporary directory for archive extraction</param>
/// <param name="tempDir">Temporary directory for archive extraction</param>
/// <param name="sevenzip">Integer representing the archive handling level for 7z</param>
/// <param name="gz">Integer representing the archive handling level for GZip</param>
/// <param name="rar">Integer representing the archive handling level for RAR</param>
/// <param name="zip">Integer representing the archive handling level for Zip</param>
/// <param name="logger">Logger object for file and console output</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public static bool ExtractArchive(string input, string tempdir, int sevenzip,
public static bool ExtractArchive(string input, string tempDir, int sevenzip,
int gz, int rar, int zip, Logger logger)
{
return ExtractArchive(input, tempdir, (ArchiveScanLevel)sevenzip, (ArchiveScanLevel)gz, (ArchiveScanLevel)rar, (ArchiveScanLevel)zip, logger);
return ExtractArchive(input, tempDir, (ArchiveScanLevel)sevenzip, (ArchiveScanLevel)gz, (ArchiveScanLevel)rar, (ArchiveScanLevel)zip, logger);
}
/// <summary>
/// Attempt to extract a file as an archive
/// </summary>
/// <param name="input">Name of the file to be extracted</param>
/// <param name="tempdir">Temporary directory for archive extraction</param>
/// <param name="tempDir">Temporary directory for archive extraction</param>
/// <param name="sevenzip">Archive handling level for 7z</param>
/// <param name="gz">Archive handling level for GZip</param>
/// <param name="rar">Archive handling level for RAR</param>
/// <param name="zip">Archive handling level for Zip</param>
/// <param name="logger">Logger object for file and console output</param>
/// <returns>True if the extraction was a success, false otherwise</returns>
public static bool ExtractArchive(string input, string tempdir, ArchiveScanLevel sevenzip,
public static bool ExtractArchive(string input, string tempDir, ArchiveScanLevel sevenzip,
ArchiveScanLevel gz, ArchiveScanLevel rar, ArchiveScanLevel zip, Logger logger)
{
bool encounteredErrors = true;
@@ -413,10 +413,10 @@ namespace SabreTools.Helper
logger.Log("Found archive of type: " + at);
// Create the temp directory
Directory.CreateDirectory(tempdir);
Directory.CreateDirectory(tempDir);
// Extract all files to the temp directory
sza.WriteToDirectory(tempdir, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
sza.WriteToDirectory(tempDir, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
encounteredErrors = false;
}
else if (at == ArchiveType.GZip && gz != ArchiveScanLevel.External)
@@ -424,11 +424,11 @@ namespace SabreTools.Helper
logger.Log("Found archive of type: " + at);
// Create the temp directory
Directory.CreateDirectory(tempdir);
Directory.CreateDirectory(tempDir);
using (FileStream itemstream = File.OpenRead(input))
{
using (FileStream outstream = File.Create(Path.Combine(tempdir, Path.GetFileNameWithoutExtension(input))))
using (FileStream outstream = File.Create(Path.Combine(tempDir, Path.GetFileNameWithoutExtension(input))))
{
using (GZipStream gzstream = new GZipStream(itemstream, CompressionMode.Decompress))
{
@@ -447,10 +447,10 @@ namespace SabreTools.Helper
(at == ArchiveType.Rar && rar != ArchiveScanLevel.External))
{
// Create the temp directory
Directory.CreateDirectory(tempdir);
Directory.CreateDirectory(tempDir);
// Extract all files to the temp directory
reader.WriteAllToDirectory(tempdir, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
reader.WriteAllToDirectory(tempDir, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
encounteredErrors = false;
}
}
@@ -482,11 +482,11 @@ namespace SabreTools.Helper
/// </summary>
/// <param name="input">Name of the archive to be extracted</param>
/// <param name="entryname">Name of the entry to be extracted</param>
/// <param name="tempdir">Temporary directory for archive extraction</param>
/// <param name="tempDir">Temporary directory for archive extraction</param>
/// <param name="logger">Logger object for file and console output</param>
/// <returns>Name of the extracted file, null on error</returns>
public static string ExtractSingleItemFromArchive(string input, string entryname,
string tempdir, Logger logger)
string tempDir, Logger logger)
{
string outfile = null;
@@ -507,14 +507,14 @@ namespace SabreTools.Helper
if (at == ArchiveType.Zip || at == ArchiveType.SevenZip || at == ArchiveType.Rar)
{
// Create the temp directory
Directory.CreateDirectory(tempdir);
Directory.CreateDirectory(tempDir);
while (reader.MoveToNextEntry())
{
logger.Log("Current entry name: '" + reader.Entry.Key + "'");
if (reader.Entry != null && reader.Entry.Key.Contains(entryname))
{
outfile = Path.GetFullPath(Path.Combine(tempdir, reader.Entry.Key));
outfile = Path.GetFullPath(Path.Combine(tempDir, reader.Entry.Key));
if (!Directory.Exists(Path.GetDirectoryName(outfile)))
{
Directory.CreateDirectory(Path.GetDirectoryName(outfile));
@@ -530,12 +530,12 @@ namespace SabreTools.Helper
using(FileStream itemstream = File.OpenRead(input))
{
using (FileStream outstream = File.Create(Path.Combine(tempdir, Path.GetFileNameWithoutExtension(input))))
using (FileStream outstream = File.Create(Path.Combine(tempDir, Path.GetFileNameWithoutExtension(input))))
{
using (GZipStream gzstream = new GZipStream(itemstream, CompressionMode.Decompress))
{
gzstream.CopyTo(outstream);
outfile = Path.GetFullPath(Path.Combine(tempdir, Path.GetFileNameWithoutExtension(input)));
outfile = Path.GetFullPath(Path.Combine(tempDir, Path.GetFileNameWithoutExtension(input)));
}
}
}
@@ -562,16 +562,16 @@ namespace SabreTools.Helper
/// Attempt to copy a file between archives
/// </summary>
/// <param name="inputArchive">Source archive name</param>
/// <param name="outputDirectory">Destination archive name</param>
/// <param name="outDir">Destination archive name</param>
/// <param name="sourceEntryName">Input entry name</param>
/// <param name="destEntryName">Output entry name</param>
/// <param name="logger">Logger object for file and console output</param>
/// <returns>True if the copy was a success, false otherwise</returns>
public static bool CopyFileBetweenArchives(string inputArchive, string outputDirectory,
public static bool CopyFileBetweenArchives(string inputArchive, string outDir,
string sourceEntryName, Rom destEntry, Logger logger)
{
string tempfile = ExtractSingleItemFromArchive(inputArchive, sourceEntryName, Path.GetTempPath(), logger);
return WriteToArchive(tempfile, outputDirectory, destEntry);
return WriteToArchive(tempfile, outDir, destEntry);
}
#endregion

View File

@@ -159,7 +159,7 @@ namespace SabreTools.Helper
// Create the output dictionary
Dictionary<OutputFormat, string> outfileNames = new Dictionary<OutputFormat, string>();
// Double check the outdir for the end delim
// Double check the outDir for the end delim
if (!outDir.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
outDir += Path.DirectorySeparatorChar;

View File

@@ -49,8 +49,8 @@ namespace SabreTools
/// Wrap sorting files using an input DAT
/// </summary>
/// <param name="inputs">List of all inputted files and folders</param>
/// <param name="outdir">Output directory (empty for default directory)</param>
/// <param name="tempdir">Temporary directory for archive extraction</param>
/// <param name="outDir">Output directory (empty for default directory)</param>
/// <param name="tempDir">Temporary directory for archive extraction</param>
/// <param name="delete">True if input files should be deleted, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="sevenzip">Integer representing the archive handling level for 7z</param>
@@ -58,7 +58,7 @@ namespace SabreTools
/// <param name="rar">Integer representing the archive handling level for RAR</param>
/// <param name="zip">Integer representing the archive handling level for Zip</param>
/// <param name="logger">Logger object for file and console output</param>
public static bool InitConvertFolderTGZ(List<string> inputs, string outdir, string tempdir, bool delete,
public static bool InitConvertFolderTGZ(List<string> inputs, string outDir, string tempDir, bool delete,
bool romba, int sevenzip, int gz, int rar, int zip, Logger logger)
{
// Get all individual files from the inputs
@@ -78,7 +78,7 @@ namespace SabreTools
}
}
SimpleSort ss = new SimpleSort(new Dat(), newinputs, outdir, tempdir, false, false, false, delete, false, romba, sevenzip, gz, rar, zip, false, logger);
SimpleSort ss = new SimpleSort(new Dat(), newinputs, outDir, tempDir, false, false, false, delete, false, romba, sevenzip, gz, rar, zip, false, logger);
return ss.Convert();
}
@@ -178,8 +178,8 @@ namespace SabreTools
/// <param name="inputs">Input files or folders to be split</param>
/// <param name="exta">First extension to split on</param>
/// <param name="extb">Second extension to split on</param>
/// <param name="outdir">Output directory for the split files</param>
private static void InitExtSplit(List<string> inputs, string exta, string extb, string outdir)
/// <param name="outDir">Output directory for the split files</param>
private static void InitExtSplit(List<string> inputs, string exta, string extb, string outDir)
{
// Convert comma-separated strings to list
List<string> extaList = exta.Split(',').ToList();
@@ -190,13 +190,13 @@ namespace SabreTools
{
if (File.Exists(input))
{
DatTools.SplitByExt(Path.GetFullPath(input), outdir, Path.GetDirectoryName(input), extaList, extbList, _logger);
DatTools.SplitByExt(Path.GetFullPath(input), outDir, Path.GetDirectoryName(input), extaList, extbList, _logger);
}
else if (Directory.Exists(input))
{
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
{
DatTools.SplitByExt(file, outdir, (input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar), extaList, extbList, _logger);
DatTools.SplitByExt(file, outDir, (input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar), extaList, extbList, _logger);
}
}
else
@@ -263,21 +263,21 @@ namespace SabreTools
/// Wrap splitting a DAT by best available hashes
/// </summary>
/// <param name="inputs">List of inputs to be used</param>
/// <param name="outdir">Output directory for the split files</param>
private static void InitHashSplit(List<string> inputs, string outdir)
/// <param name="outDir">Output directory for the split files</param>
private static void InitHashSplit(List<string> inputs, string outDir)
{
// Loop over the input files
foreach (string input in inputs)
{
if (File.Exists(input))
{
DatTools.SplitByHash(Path.GetFullPath(input), outdir, Path.GetDirectoryName(input), _logger);
DatTools.SplitByHash(Path.GetFullPath(input), outDir, Path.GetDirectoryName(input), _logger);
}
else if (Directory.Exists(input))
{
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
{
DatTools.SplitByHash(file, outdir, (input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar), _logger);
DatTools.SplitByHash(file, outDir, (input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar), _logger);
}
}
else
@@ -295,11 +295,11 @@ namespace SabreTools
/// </summary>
/// <param name="inputs">Input file or folder names</param>
/// <param name="restore">False if we're extracting headers (default), true if we're restoring them</param>
/// <param name="outdir">Output directory to write new files to, blank defaults to rom folder</param>
/// <param name="outDir">Output directory to write new files to, blank defaults to rom folder</param>
/// <param name="logger">Logger object for file and console output</param>
private static void InitHeaderer(List<string> inputs, bool restore, string outdir, Logger logger)
private static void InitHeaderer(List<string> inputs, bool restore, string outDir, Logger logger)
{
Headerer headerer = new Headerer(inputs, restore, outdir, logger);
Headerer headerer = new Headerer(inputs, restore, outDir, logger);
headerer.Process();
}
@@ -366,8 +366,8 @@ namespace SabreTools
/// </summary>
/// <param name="datfiles">Names of the DATs to compare against</param>
/// <param name="inputs">List of input files/folders to check</param>
/// <param name="outdir">Output directory to use to build to</param>
/// <param name="tempdir">Temporary directory for archive extraction</param>
/// <param name="outDir">Output directory to use to build to</param>
/// <param name="tempDir">Temporary directory for archive extraction</param>
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
/// <param name="sevenzip">Integer representing the archive handling level for 7z</param>
/// <param name="toFolder">True if files should be output to folder, false otherwise</param>
@@ -380,7 +380,7 @@ namespace SabreTools
/// <param name="zip">Integer representing the archive handling level for Zip</param>
/// <param name="updateDat">True if the updated DAT should be output, false otherwise</param>
/// <param name="logger">Logger object for file and console output</param>
private static void InitSortVerify(List<string> datfiles, List<string> inputs, string outdir, string tempdir, bool quickScan,
private static void InitSortVerify(List<string> datfiles, List<string> inputs, string outDir, string tempDir, bool quickScan,
bool toFolder, bool verify, bool delete, bool? torrentX, bool romba, int sevenzip, int gz, int rar, int zip, bool updateDat, Logger logger)
{
// Add all of the input DATs into one huge internal DAT
@@ -390,7 +390,7 @@ namespace SabreTools
datdata = DatTools.Parse(datfile, 99, 99, datdata, logger);
}
SimpleSort ss = new SimpleSort(datdata, inputs, outdir, tempdir, quickScan, toFolder, verify,
SimpleSort ss = new SimpleSort(datdata, inputs, outDir, tempDir, quickScan, toFolder, verify,
delete, torrentX, romba, sevenzip, gz, rar, zip, updateDat, logger);
ss.StartProcessing();
}
@@ -430,21 +430,21 @@ namespace SabreTools
/// Wrap splitting a DAT by item type
/// </summary>
/// <param name="inputs">List of inputs to be used</param>
/// <param name="outdir">Output directory for the split files</param>
private static void InitTypeSplit(List<string> inputs, string outdir)
/// <param name="outDir">Output directory for the split files</param>
private static void InitTypeSplit(List<string> inputs, string outDir)
{
// Loop over the input files
foreach (string input in inputs)
{
if (File.Exists(input))
{
DatTools.SplitByType(Path.GetFullPath(input), outdir, Path.GetFullPath(Path.GetDirectoryName(input)), _logger);
DatTools.SplitByType(Path.GetFullPath(input), outDir, Path.GetFullPath(Path.GetDirectoryName(input)), _logger);
}
else if (Directory.Exists(input))
{
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
{
DatTools.SplitByType(file, outdir, Path.GetFullPath((input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar)), _logger);
DatTools.SplitByType(file, outDir, Path.GetFullPath((input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar)), _logger);
}
}
else
@@ -514,7 +514,7 @@ namespace SabreTools
/// <param name="single">True if all games should be replaced by '!', false otherwise</param>
/// <param name="root">String representing root directory to compare against for length calculation</param>
/// /* Output DAT info */
/// <param name="outdir">Optional param for output directory</param>
/// <param name="outDir">Optional param for output directory</param>
/// <param name="clean">True to clean the game names to WoD standard, false otherwise (default)</param>
/// <param name="softlist">True to allow SL DATs to have game names used instead of descriptions, false otherwise (default)</param>
/// <param name="dedup">True to dedupe the roms in the DAT, false otherwise (default)</param>
@@ -579,7 +579,7 @@ namespace SabreTools
string root,
/* Output DAT info */
string outdir,
string outDir,
bool clean,
bool softlist,
bool dedup,
@@ -705,7 +705,7 @@ namespace SabreTools
XSV = tsv,
};
DatTools.Update(inputs, userInputDat, outputFormat, outdir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist,
DatTools.Update(inputs, userInputDat, outputFormat, outDir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist,
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger);
}

View File

@@ -240,7 +240,7 @@ Make a selection:
/// </summary>
private static void ConvertMenu()
{
string selection = "", input = "", outdir = "";
string selection = "", input = "", outDir = "";
OutputFormat outputFormat = OutputFormat.Xml;
while (selection.ToLowerInvariant() != "b")
{
@@ -251,7 +251,7 @@ Make a selection:
Make a selection:
1) File or folder to convert" + (input == "" ? "" : ":\n" + input) + @"
2) New output folder" + (outdir == "" ? " (blank means source directory)" : ":\n" + outdir) + @"
2) New output folder" + (outDir == "" ? " (blank means source directory)" : ":\n" + outDir) + @"
3) Current output type: " + (outputFormat.ToString()) + @"
4) Process file or folder
B) Go back to the previous menu
@@ -268,7 +268,7 @@ Make a selection:
case "2":
Console.Clear();
Console.Write("Please enter a folder name: ");
outdir = Console.ReadLine();
outDir = Console.ReadLine();
break;
case "3":
string subsel = "";
@@ -312,11 +312,11 @@ Make a selection:
InitUpdate(temp, "", "", "", "", "", "", "", "", "", "", "", "", false, "", "", "",
(outputFormat == OutputFormat.ClrMamePro), (outputFormat == OutputFormat.MissFile), (outputFormat == OutputFormat.RomCenter),
(outputFormat == OutputFormat.SabreDat), (outputFormat == OutputFormat.Xml), false, "", "", false, "", "", false, false, false,
false, false, false, false, false, "", "", "", -1, -1, -1, "", "", "", null, outdir, false, false);
false, false, false, false, false, "", "", "", -1, -1, -1, "", "", "", null, outDir, false, false);
*/
Console.Write("\nPress any key to continue...");
Console.ReadKey();
input = ""; outdir = "";
input = ""; outDir = "";
outputFormat = OutputFormat.Xml;
break;
}
@@ -579,7 +579,7 @@ Make a selection:
/// </summary>
private static void ExtSplitMenu()
{
string selection = "", input = "", exta = "", extb = "", outdir = "";
string selection = "", input = "", exta = "", extb = "", outDir = "";
while (selection.ToLowerInvariant() != "b")
{
Console.Clear();
@@ -591,7 +591,7 @@ Make a selection:
1) File to split" + (input != "" ? ":\n\t" + input : "") + @"
2) First file extension" + (exta != "" ? ":\t" + exta : "") + @"
3) Second file extension" + (extb != "" ? ":\t" + extb : "") + @"
4) Output directory" + (outdir != "" ? ":\n\t" + outdir : "") + @"
4) Output directory" + (outDir != "" ? ":\n\t" + outDir : "") + @"
5) Split the file
B) Go back to the previous menu
");
@@ -617,16 +617,16 @@ Make a selection:
case "4":
Console.Clear();
Console.Write("Please enter the output directory: ");
outdir = Console.ReadLine();
outDir = Console.ReadLine();
break;
case "5":
Console.Clear();
List<string> inputs = new List<string>();
inputs.Add(input);
InitExtSplit(inputs, exta, extb, outdir);
InitExtSplit(inputs, exta, extb, outDir);
Console.Write("\nPress any key to continue...");
Console.ReadKey();
input = ""; exta = ""; extb = ""; outdir = "";
input = ""; exta = ""; extb = ""; outDir = "";
break;
}
}
@@ -637,7 +637,7 @@ Make a selection:
/// </summary>
private static void HashSplitMenu()
{
string selection = "", input = "", outdir = "";
string selection = "", input = "", outDir = "";
while (selection.ToLowerInvariant() != "b")
{
Console.Clear();
@@ -647,7 +647,7 @@ Make a selection:
Make a selection:
1) File or folder to split" + (input != "" ? ":\n\t" + input : "") + @"
2) Output directory" + (outdir != "" ? ":\n\t" + outdir : "") + @"
2) Output directory" + (outDir != "" ? ":\n\t" + outDir : "") + @"
3) Split the file
B) Go back to the previous menu
");
@@ -663,16 +663,16 @@ Make a selection:
case "2":
Console.Clear();
Console.Write("Please enter the output directory: ");
outdir = Console.ReadLine();
outDir = Console.ReadLine();
break;
case "3":
Console.Clear();
List<string> inputs = new List<string>();
inputs.Add(input);
InitHashSplit(inputs, outdir);
InitHashSplit(inputs, outDir);
Console.Write("\nPress any key to continue...");
Console.ReadKey();
input = ""; outdir = "";
input = ""; outDir = "";
break;
}
}

View File

@@ -148,7 +148,7 @@ namespace SabreTools
name = "",
manu = "",
md5 = "",
outdir = "",
outDir = "",
postfix = "",
prefix = "",
repext = "",
@@ -159,7 +159,7 @@ namespace SabreTools
sha1 = "",
sources = "",
systems = "",
tempdir = "",
tempDir = "",
url = "",
version = "";
List<string> inputs = new List<string>();
@@ -531,7 +531,7 @@ namespace SabreTools
}
else if (temparg.StartsWith("-out=") || temparg.StartsWith("--out="))
{
outdir = temparg.Split('=')[1];
outDir = temparg.Split('=')[1];
}
else if (temparg.StartsWith("-post=") || temparg.StartsWith("--postfix="))
{
@@ -587,7 +587,7 @@ namespace SabreTools
}
else if (temparg.StartsWith("-t=") || temparg.StartsWith("--temp="))
{
tempdir = temparg.Split('=')[1];
tempDir = temparg.Split('=')[1];
}
else if (temparg.StartsWith("-u=") || temparg.StartsWith("--url="))
{
@@ -670,13 +670,13 @@ namespace SabreTools
else if (datfromdir)
{
InitDatFromDir(inputs, filename, name, description, category, version, author, forceunpack, outputFormat,
romba, superdat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, addBlanks, addDate, tempdir, maxParallelism);
romba, superdat, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, addBlanks, addDate, tempDir, maxParallelism);
}
// Split a DAT by extension
else if (extsplit)
{
InitExtSplit(inputs, exta, extb, outdir);
InitExtSplit(inputs, exta, extb, outDir);
}
// Generate all DATs
@@ -696,13 +696,13 @@ namespace SabreTools
// Split a DAT by available hashes
else if (hashsplit)
{
InitHashSplit(inputs, outdir);
InitHashSplit(inputs, outDir);
}
// If we're in headerer mode
else if (headerer)
{
InitHeaderer(inputs, restore, outdir, _logger);
InitHeaderer(inputs, restore, outDir, _logger);
}
// Import a file or folder
@@ -749,7 +749,7 @@ namespace SabreTools
// Split a DAT by item type
else if (typesplit)
{
InitTypeSplit(inputs, outdir);
InitTypeSplit(inputs, outDir);
}
// Convert, update, merge, diff, and filter a DAT or folder of DATs
@@ -758,7 +758,7 @@ namespace SabreTools
InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header,
superdat, forcemerge, forcend, forcepack, outputFormat, usegame, prefix,
postfix, quotes, repext, addext, remext, datprefix, romba, tsv, merge, diffMode, cascade, inplace, skip, bare, gamename, romname,
romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, outdir, clean, softlist, dedup, maxParallelism);
romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, outDir, clean, softlist, dedup, maxParallelism);
}
// If nothing is set, show the help

View File

@@ -57,8 +57,8 @@ namespace SabreTools
gz = 2,
rar = 2,
zip = 0;
string outdir = "",
tempdir = "";
string outDir = "",
tempDir = "";
List<string> inputs = new List<string>();
List<string> datfiles = new List<string>();
@@ -140,7 +140,7 @@ namespace SabreTools
}
else if (temparg.StartsWith("-out=") || temparg.StartsWith("--out="))
{
outdir = temparg.Split('=')[1];
outDir = temparg.Split('=')[1];
}
else if (temparg.StartsWith("-rar=") || temparg.StartsWith("--rar="))
{
@@ -151,7 +151,7 @@ namespace SabreTools
}
else if (temparg.StartsWith("-t=") || temparg.StartsWith("--temp="))
{
tempdir = temparg.Split('=')[1];
tempDir = temparg.Split('=')[1];
}
else if (temparg.StartsWith("-zip=") || temparg.StartsWith("--zip="))
{
@@ -198,7 +198,7 @@ namespace SabreTools
// If we are converting the folder to TGZ
else if (convert)
{
InitConvertFolderTGZ(inputs, outdir, tempdir, delete, romba, sevenzip, gz, rar, zip, logger);
InitConvertFolderTGZ(inputs, outDir, tempDir, delete, romba, sevenzip, gz, rar, zip, logger);
}
// If we are doing a simple sort
@@ -206,7 +206,7 @@ namespace SabreTools
{
if (datfiles.Count > 0)
{
InitSortVerify(datfiles, inputs, outdir, tempdir, quickScan, toFolder,
InitSortVerify(datfiles, inputs, outDir, tempDir, quickScan, toFolder,
verify, delete, torrentX, romba, sevenzip, gz, rar, zip, updateDat, logger);
}
else
@@ -233,8 +233,8 @@ namespace SabreTools
/// </summary>
/// <param name="datfiles">Names of the DATs to compare against</param>
/// <param name="inputs">List of input files/folders to check</param>
/// <param name="outdir">Output directory to use to build to</param>
/// <param name="tempdir">Temporary directory for archive extraction</param>
/// <param name="outDir">Output directory to use to build to</param>
/// <param name="tempDir">Temporary directory for archive extraction</param>
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
/// <param name="sevenzip">Integer representing the archive handling level for 7z</param>
/// <param name="toFolder">True if files should be output to folder, false otherwise</param>
@@ -247,7 +247,7 @@ namespace SabreTools
/// <param name="zip">Integer representing the archive handling level for Zip</param>
/// <param name="updateDat">True if the updated DAT should be output, false otherwise</param>
/// <param name="logger">Logger object for file and console output</param>
private static void InitSortVerify(List<string> datfiles, List<string> inputs, string outdir, string tempdir, bool quickScan,
private static void InitSortVerify(List<string> datfiles, List<string> inputs, string outDir, string tempDir, bool quickScan,
bool toFolder, bool verify, bool delete, bool? torrentX, bool romba, int sevenzip, int gz, int rar, int zip, bool updateDat, Logger logger)
{
// Add all of the input DATs into one huge internal DAT
@@ -257,7 +257,7 @@ namespace SabreTools
datdata = DatTools.Parse(datfile, 99, 99, datdata, logger, keep: true, softlist: true);
}
SimpleSort ss = new SimpleSort(datdata, inputs, outdir, tempdir, quickScan, toFolder, verify,
SimpleSort ss = new SimpleSort(datdata, inputs, outDir, tempDir, quickScan, toFolder, verify,
delete, torrentX, romba, sevenzip, gz, rar, zip, updateDat, logger);
ss.StartProcessing();
}
@@ -266,8 +266,8 @@ namespace SabreTools
/// Wrap sorting files using an input DAT
/// </summary>
/// <param name="inputs">List of all inputted files and folders</param>
/// <param name="outdir">Output directory (empty for default directory)</param>
/// <param name="tempdir">Temporary directory for archive extraction</param>
/// <param name="outDir">Output directory (empty for default directory)</param>
/// <param name="tempDir">Temporary directory for archive extraction</param>
/// <param name="delete">True if input files should be deleted, false otherwise</param>
/// <param name="romba">True if files should be output in Romba depot folders, false otherwise</param>
/// <param name="sevenzip">Integer representing the archive handling level for 7z</param>
@@ -275,7 +275,7 @@ namespace SabreTools
/// <param name="rar">Integer representing the archive handling level for RAR</param>
/// <param name="zip">Integer representing the archive handling level for Zip</param>
/// <param name="logger">Logger object for file and console output</param>
public static bool InitConvertFolderTGZ(List<string> inputs, string outdir, string tempdir, bool delete,
public static bool InitConvertFolderTGZ(List<string> inputs, string outDir, string tempDir, bool delete,
bool romba, int sevenzip, int gz, int rar, int zip, Logger logger)
{
// Get all individual files from the inputs
@@ -295,7 +295,7 @@ namespace SabreTools
}
}
SimpleSort ss = new SimpleSort(new Dat(), newinputs, outdir, tempdir, false, false, false,
SimpleSort ss = new SimpleSort(new Dat(), newinputs, outDir, tempDir, false, false, false,
delete, false, romba, sevenzip, gz, rar, zip, false, logger);
return ss.Convert();
}