mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Logger] Updating logging to allow for removal of prefix
This commit is contained in:
@@ -2096,7 +2096,7 @@ namespace SabreTools.Helper
|
|||||||
int parentcount = parent.Count;
|
int parentcount = parent.Count;
|
||||||
if (parentcount == 0)
|
if (parentcount == 0)
|
||||||
{
|
{
|
||||||
logger.Log("Empty parent: " + String.Join("\\", parent));
|
logger.Verbose("Empty parent: " + String.Join("\\", parent));
|
||||||
empty = true;
|
empty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2522,13 +2522,13 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
if (subreader.GetAttribute("flags") == "baddump" || subreader.GetAttribute("status") == "baddump")
|
if (subreader.GetAttribute("flags") == "baddump" || subreader.GetAttribute("status") == "baddump")
|
||||||
{
|
{
|
||||||
logger.Log("Bad dump detected: " +
|
logger.Verbose("Bad dump detected: " +
|
||||||
(subreader.GetAttribute("name") != null && subreader.GetAttribute("name") != "" ? "\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
|
(subreader.GetAttribute("name") != null && subreader.GetAttribute("name") != "" ? "\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
|
||||||
its = ItemStatus.BadDump;
|
its = ItemStatus.BadDump;
|
||||||
}
|
}
|
||||||
if (subreader.GetAttribute("flags") == "itemStatus" || subreader.GetAttribute("status") == "itemStatus")
|
if (subreader.GetAttribute("flags") == "itemStatus" || subreader.GetAttribute("status") == "itemStatus")
|
||||||
{
|
{
|
||||||
logger.Log("Nodump detected: " +
|
logger.Verbose("Nodump detected: " +
|
||||||
(subreader.GetAttribute("name") != null && subreader.GetAttribute("name") != "" ? "\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
|
(subreader.GetAttribute("name") != null && subreader.GetAttribute("name") != "" ? "\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
|
||||||
its = ItemStatus.Nodump;
|
its = ItemStatus.Nodump;
|
||||||
}
|
}
|
||||||
@@ -2677,12 +2677,12 @@ namespace SabreTools.Helper
|
|||||||
its = ItemStatus.Good;
|
its = ItemStatus.Good;
|
||||||
break;
|
break;
|
||||||
case "baddump":
|
case "baddump":
|
||||||
logger.Log("Bad dump detected: " + (xtr.GetAttribute("name") != null && xtr.GetAttribute("name") != "" ?
|
logger.Verbose("Bad dump detected: " + (xtr.GetAttribute("name") != null && xtr.GetAttribute("name") != "" ?
|
||||||
"\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
|
"\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
|
||||||
its = ItemStatus.BadDump;
|
its = ItemStatus.BadDump;
|
||||||
break;
|
break;
|
||||||
case "itemStatus":
|
case "itemStatus":
|
||||||
logger.Log("Nodump detected: " + (xtr.GetAttribute("name") != null && xtr.GetAttribute("name") != "" ?
|
logger.Verbose("Nodump detected: " + (xtr.GetAttribute("name") != null && xtr.GetAttribute("name") != "" ?
|
||||||
"\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
|
"\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
|
||||||
its = ItemStatus.Nodump;
|
its = ItemStatus.Nodump;
|
||||||
break;
|
break;
|
||||||
@@ -3090,7 +3090,7 @@ namespace SabreTools.Helper
|
|||||||
&& ((Rom)rom).MD5 == "null"
|
&& ((Rom)rom).MD5 == "null"
|
||||||
&& ((Rom)rom).SHA1 == "null")
|
&& ((Rom)rom).SHA1 == "null")
|
||||||
{
|
{
|
||||||
logger.Log("Empty folder found: " + rom.MachineName);
|
logger.Verbose("Empty folder found: " + rom.MachineName);
|
||||||
|
|
||||||
// If we're in a mode that doesn't allow for actual empty folders, add the blank info
|
// If we're in a mode that doesn't allow for actual empty folders, add the blank info
|
||||||
if (outputFormat != OutputFormat.SabreDat && outputFormat != OutputFormat.MissFile)
|
if (outputFormat != OutputFormat.SabreDat && outputFormat != OutputFormat.MissFile)
|
||||||
@@ -3123,7 +3123,7 @@ namespace SabreTools.Helper
|
|||||||
// Write the file footer out
|
// Write the file footer out
|
||||||
WriteFooter(sw, outputFormat, depth, logger);
|
WriteFooter(sw, outputFormat, depth, logger);
|
||||||
|
|
||||||
logger.Log("File written!" + Environment.NewLine);
|
logger.Verbose("File written!" + Environment.NewLine);
|
||||||
sw.Dispose();
|
sw.Dispose();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
}
|
}
|
||||||
@@ -3946,7 +3946,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process the input folder
|
// Process the input folder
|
||||||
logger.Log("Folder found: " + basePath);
|
logger.Verbose("Folder found: " + basePath);
|
||||||
|
|
||||||
// Process the files in all subfolders
|
// Process the files in all subfolders
|
||||||
List<string> files = Directory.EnumerateFiles(basePath, "*", SearchOption.AllDirectories).ToList();
|
List<string> files = Directory.EnumerateFiles(basePath, "*", SearchOption.AllDirectories).ToList();
|
||||||
@@ -4007,7 +4007,7 @@ namespace SabreTools.Helper
|
|||||||
romname = romname.Substring(0, romname.Length - 1);
|
romname = romname.Substring(0, romname.Length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Log("Adding blank empty folder: " + gamename);
|
logger.Verbose("Adding blank empty folder: " + gamename);
|
||||||
Files["null"].Add(new Rom(romname, gamename));
|
Files["null"].Add(new Rom(romname, gamename));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -4134,7 +4134,7 @@ namespace SabreTools.Helper
|
|||||||
// If the file was an archive and was extracted successfully, check it
|
// If the file was an archive and was extracted successfully, check it
|
||||||
if (!encounteredErrors)
|
if (!encounteredErrors)
|
||||||
{
|
{
|
||||||
logger.Log(Path.GetFileName(item) + " treated like an archive");
|
logger.Verbose(Path.GetFileName(item) + " treated like an archive");
|
||||||
List<string> extracted = Directory.EnumerateFiles(tempSubDir, "*", SearchOption.AllDirectories).ToList();
|
List<string> extracted = Directory.EnumerateFiles(tempSubDir, "*", SearchOption.AllDirectories).ToList();
|
||||||
Parallel.ForEach(extracted,
|
Parallel.ForEach(extracted,
|
||||||
new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism },
|
new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism },
|
||||||
@@ -4184,7 +4184,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="parent">Parent game to be used</param>
|
/// <param name="parent">Parent game to be used</param>
|
||||||
private void DFDProcessFile(string item, string parent, string basePath, bool noMD5, bool noSHA1, bool addDate, Logger logger)
|
private void DFDProcessFile(string item, string parent, string basePath, bool noMD5, bool noSHA1, bool addDate, Logger logger)
|
||||||
{
|
{
|
||||||
logger.Log(Path.GetFileName(item) + " treated like a file");
|
logger.Verbose(Path.GetFileName(item) + " treated like a file");
|
||||||
Rom rom = FileTools.GetSingleFileInfo(item, noMD5: noMD5, noSHA1: noSHA1, date: addDate);
|
Rom rom = FileTools.GetSingleFileInfo(item, noMD5: noMD5, noSHA1: noSHA1, date: addDate);
|
||||||
|
|
||||||
DFDProcessFileHelper(item, rom, basePath, parent, logger);
|
DFDProcessFileHelper(item, rom, basePath, parent, logger);
|
||||||
@@ -5078,7 +5078,7 @@ namespace SabreTools.Helper
|
|||||||
/// Now process each of the input files
|
/// Now process each of the input files
|
||||||
foreach (string filename in newinputs)
|
foreach (string filename in newinputs)
|
||||||
{
|
{
|
||||||
logger.Log("Beginning stat collection for '" + filename + "'");
|
logger.Verbose("Beginning stat collection for '" + filename + "'");
|
||||||
List<string> games = new List<string>();
|
List<string> games = new List<string>();
|
||||||
DatFile datdata = new DatFile();
|
DatFile datdata = new DatFile();
|
||||||
datdata.Parse(filename, 0, 0, logger);
|
datdata.Parse(filename, 0, 0, logger);
|
||||||
|
|||||||
@@ -117,13 +117,14 @@ namespace SabreTools.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
/// <param name="loglevel">Severity of the information being logged</param>
|
/// <param name="loglevel">Severity of the information being logged</param>
|
||||||
|
/// <param name="appendPrefix">True if the level and datetime should be prepended to each statement, false otherwise</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
public bool Log(string output, LogLevel loglevel = LogLevel.VERBOSE)
|
private bool Log(string output, LogLevel loglevel, bool appendPrefix)
|
||||||
{
|
{
|
||||||
// USER and ERROR writes to console
|
// USER and ERROR writes to console
|
||||||
if (loglevel == LogLevel.USER || loglevel == LogLevel.ERROR)
|
if (loglevel == LogLevel.USER || loglevel == LogLevel.ERROR)
|
||||||
{
|
{
|
||||||
Console.WriteLine((loglevel == LogLevel.ERROR ? loglevel.ToString() + " " : "") + output);
|
Console.WriteLine((loglevel == LogLevel.ERROR && appendPrefix ? loglevel.ToString() + " " : "") + output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're writing to file, use the existing stream
|
// If we're writing to file, use the existing stream
|
||||||
@@ -131,7 +132,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_log.WriteLine(loglevel.ToString() + " - " + DateTime.Now + " - " + output);
|
_log.WriteLine((appendPrefix ? loglevel.ToString() + " - " + DateTime.Now + " - " : "" ) + output);
|
||||||
_log.Flush();
|
_log.Flush();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@@ -151,7 +152,7 @@ namespace SabreTools.Helper
|
|||||||
/// <param name="line">Line number to write out to</param>
|
/// <param name="line">Line number to write out to</param>
|
||||||
/// <param name="column">Column number to write out to</param>
|
/// <param name="column">Column number to write out to</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
public bool Log(string output, int line, int column)
|
public bool WriteExact(string output, int line, int column)
|
||||||
{
|
{
|
||||||
// Set the cursor position (if not being redirected)
|
// Set the cursor position (if not being redirected)
|
||||||
if (!Console.IsOutputRedirected)
|
if (!Console.IsOutputRedirected)
|
||||||
@@ -181,34 +182,48 @@ namespace SabreTools.Helper
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write the given string as a verbose message to the log output
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="output">String to be written log</param>
|
||||||
|
/// <param name="appendPrefix">True if the level and datetime should be prepended to each statement (default), false otherwise</param>
|
||||||
|
/// <returns>True if the output could be written, false otherwise</returns>s
|
||||||
|
public bool Verbose(string output, bool appendPrefix = true)
|
||||||
|
{
|
||||||
|
return Log(output, LogLevel.VERBOSE, appendPrefix);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write the given string as a user message to the log output
|
/// Write the given string as a user message to the log output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
|
/// <param name="appendPrefix">True if the level and datetime should be prepended to each statement (default), false otherwise</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
public bool User(string output)
|
public bool User(string output, bool appendPrefix = true)
|
||||||
{
|
{
|
||||||
return Log(output, LogLevel.USER);
|
return Log(output, LogLevel.USER, appendPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write the given string as a warning to the log output
|
/// Write the given string as a warning to the log output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
|
/// <param name="appendPrefix">True if the level and datetime should be prepended to each statement (default), false otherwise</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
public bool Warning(string output)
|
public bool Warning(string output, bool appendPrefix = true)
|
||||||
{
|
{
|
||||||
return Log(output, LogLevel.WARNING);
|
return Log(output, LogLevel.WARNING, appendPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes the given string as an error in the log
|
/// Writes the given string as an error in the log
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="output">String to be written log</param>
|
/// <param name="output">String to be written log</param>
|
||||||
|
/// <param name="appendPrefix">True if the level and datetime should be prepended to each statement (default), false otherwise</param>
|
||||||
/// <returns>True if the output could be written, false otherwise</returns>
|
/// <returns>True if the output could be written, false otherwise</returns>
|
||||||
public bool Error(string output)
|
public bool Error(string output, bool appendPrefix = true)
|
||||||
{
|
{
|
||||||
return Log(output, LogLevel.ERROR);
|
return Log(output, LogLevel.ERROR, appendPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ namespace SabreTools.Helper
|
|||||||
List<string> files = new List<string>();
|
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 + "'");
|
_logger.Verbose("File found: '" + file + "'");
|
||||||
files.Add(Path.GetFullPath(file));
|
files.Add(Path.GetFullPath(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,15 +212,15 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
if (File.Exists(input))
|
if (File.Exists(input))
|
||||||
{
|
{
|
||||||
_logger.Log("File found: '" + input + "'");
|
_logger.Verbose("File found: '" + input + "'");
|
||||||
files.Add(Path.GetFullPath(input));
|
files.Add(Path.GetFullPath(input));
|
||||||
}
|
}
|
||||||
else if (Directory.Exists(input))
|
else if (Directory.Exists(input))
|
||||||
{
|
{
|
||||||
_logger.Log("Directory found: '" + input + "'");
|
_logger.Verbose("Directory found: '" + input + "'");
|
||||||
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
|
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
_logger.Log("File found: '" + file + "'");
|
_logger.Verbose("File found: '" + file + "'");
|
||||||
files.Add(Path.GetFullPath(file));
|
files.Add(Path.GetFullPath(file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
if (File.Exists(input))
|
if (File.Exists(input))
|
||||||
{
|
{
|
||||||
_logger.Log("File found: '" + input + "'");
|
_logger.Verbose("File found: '" + input + "'");
|
||||||
lock (files)
|
lock (files)
|
||||||
{
|
{
|
||||||
files.Add(Path.GetFullPath(input));
|
files.Add(Path.GetFullPath(input));
|
||||||
@@ -312,14 +312,14 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else if (Directory.Exists(input))
|
else if (Directory.Exists(input))
|
||||||
{
|
{
|
||||||
_logger.Log("Directory found: '" + input + "'");
|
_logger.Verbose("Directory found: '" + input + "'");
|
||||||
|
|
||||||
List<string> infiles = Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories).ToList();
|
List<string> infiles = Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories).ToList();
|
||||||
Parallel.ForEach(infiles,
|
Parallel.ForEach(infiles,
|
||||||
new ParallelOptions { MaxDegreeOfParallelism = _maxDegreeOfParallelism },
|
new ParallelOptions { MaxDegreeOfParallelism = _maxDegreeOfParallelism },
|
||||||
file =>
|
file =>
|
||||||
{
|
{
|
||||||
_logger.Log("File found: '" + input + "'");
|
_logger.Verbose("File found: '" + input + "'");
|
||||||
lock (files)
|
lock (files)
|
||||||
{
|
{
|
||||||
files.Add(Path.GetFullPath(file));
|
files.Add(Path.GetFullPath(file));
|
||||||
@@ -361,9 +361,9 @@ namespace SabreTools.Helper
|
|||||||
// If external scanning is enabled, use that method instead
|
// If external scanning is enabled, use that method instead
|
||||||
if (_quickScan)
|
if (_quickScan)
|
||||||
{
|
{
|
||||||
_logger.Log("Beginning quick scan of contents from '" + file + "'");
|
_logger.Verbose("Beginning quick scan of contents from '" + file + "'");
|
||||||
List<Rom> internalRomData = ArchiveTools.GetArchiveFileInfo(file, _logger);
|
List<Rom> internalRomData = ArchiveTools.GetArchiveFileInfo(file, _logger);
|
||||||
_logger.Log(internalRomData.Count + " entries found in '" + file + "'");
|
_logger.Verbose(internalRomData.Count + " entries found in '" + file + "'");
|
||||||
|
|
||||||
// Now add all of the roms to the DAT
|
// Now add all of the roms to the DAT
|
||||||
for (int i = 0; i < internalRomData.Count; i++)
|
for (int i = 0; i < internalRomData.Count; i++)
|
||||||
@@ -533,7 +533,7 @@ namespace SabreTools.Helper
|
|||||||
string percentage = (index == 0 ? "0.00" : Math.Round((100 * ((double)index / total)), 2, MidpointRounding.AwayFromZero).ToString());
|
string percentage = (index == 0 ? "0.00" : Math.Round((100 * ((double)index / total)), 2, MidpointRounding.AwayFromZero).ToString());
|
||||||
string statement = percentage + "% - " + input;
|
string statement = percentage + "% - " + input;
|
||||||
_logger.ClearBeneath(_cursorTop + 1);
|
_logger.ClearBeneath(_cursorTop + 1);
|
||||||
_logger.Log(statement, _cursorTop, 0);
|
_logger.WriteExact(statement, _cursorTop, 0);
|
||||||
|
|
||||||
// Get if the file should be scanned internally and externally
|
// Get if the file should be scanned internally and externally
|
||||||
bool shouldExternalScan, shouldInternalScan;
|
bool shouldExternalScan, shouldInternalScan;
|
||||||
@@ -552,10 +552,10 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
// Try to find the matches to the file that was found
|
// Try to find the matches to the file that was found
|
||||||
List<DatItem> foundroms = rom.GetDuplicates(_datdata, _logger);
|
List<DatItem> foundroms = rom.GetDuplicates(_datdata, _logger);
|
||||||
_logger.Log("File '" + input + "' had " + foundroms.Count + " matches in the DAT!");
|
_logger.Verbose("File '" + input + "' had " + foundroms.Count + " matches in the DAT!");
|
||||||
foreach (Rom found in foundroms)
|
foreach (Rom found in foundroms)
|
||||||
{
|
{
|
||||||
_logger.Log("Matched name: " + found.Name);
|
_logger.Verbose("Matched name: " + found.Name);
|
||||||
|
|
||||||
// Add rom to the matched list
|
// Add rom to the matched list
|
||||||
string key = found.Size + "-" + found.CRC;
|
string key = found.Size + "-" + found.CRC;
|
||||||
@@ -579,7 +579,7 @@ namespace SabreTools.Helper
|
|||||||
Directory.CreateDirectory(gamedir);
|
Directory.CreateDirectory(gamedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_torrentX == false ? found.SHA1 : found.Name) + "'");
|
_logger.Verbose("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_torrentX == false ? found.SHA1 : found.Name) + "'");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Copy(input, Path.Combine(gamedir, Path.GetFileName(found.Name)));
|
File.Copy(input, Path.Combine(gamedir, Path.GetFileName(found.Name)));
|
||||||
@@ -622,7 +622,7 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
// Try to find the matches to the file that was found
|
// Try to find the matches to the file that was found
|
||||||
List<DatItem> founddroms = drom.GetDuplicates(_datdata, _logger);
|
List<DatItem> founddroms = drom.GetDuplicates(_datdata, _logger);
|
||||||
_logger.Log("File '" + newinput + "' had " + founddroms.Count + " matches in the DAT!");
|
_logger.Verbose("File '" + newinput + "' had " + founddroms.Count + " matches in the DAT!");
|
||||||
foreach (Rom found in founddroms)
|
foreach (Rom found in founddroms)
|
||||||
{
|
{
|
||||||
// Add rom to the matched list
|
// Add rom to the matched list
|
||||||
@@ -639,7 +639,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// First output the headerless rom
|
// First output the headerless rom
|
||||||
_logger.Log("Matched name: " + found.Name);
|
_logger.Verbose("Matched name: " + found.Name);
|
||||||
|
|
||||||
if (_toFolder)
|
if (_toFolder)
|
||||||
{
|
{
|
||||||
@@ -650,7 +650,7 @@ namespace SabreTools.Helper
|
|||||||
Directory.CreateDirectory(gamedir);
|
Directory.CreateDirectory(gamedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_torrentX == false ? found.SHA1 : found.Name) + "'");
|
_logger.Verbose("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_torrentX == false ? found.SHA1 : found.Name) + "'");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Copy(newinput, Path.Combine(gamedir, Path.GetFileName(found.Name)));
|
File.Copy(newinput, Path.Combine(gamedir, Path.GetFileName(found.Name)));
|
||||||
@@ -703,7 +703,7 @@ namespace SabreTools.Helper
|
|||||||
Directory.CreateDirectory(gamedir);
|
Directory.CreateDirectory(gamedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + newfound.Name + "'");
|
_logger.Verbose("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + newfound.Name + "'");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Copy(input, Path.Combine(gamedir, Path.GetFileName(newfound.Name)));
|
File.Copy(input, Path.Combine(gamedir, Path.GetFileName(newfound.Name)));
|
||||||
@@ -712,7 +712,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.Log("Matched name: " + newfound.Name);
|
_logger.Verbose("Matched name: " + newfound.Name);
|
||||||
if (_torrentX == true)
|
if (_torrentX == true)
|
||||||
{
|
{
|
||||||
ArchiveTools.WriteTorrentZip(input, _outDir, newfound, _logger);
|
ArchiveTools.WriteTorrentZip(input, _outDir, newfound, _logger);
|
||||||
@@ -746,9 +746,9 @@ namespace SabreTools.Helper
|
|||||||
// If external scanning is enabled, use that method instead
|
// If external scanning is enabled, use that method instead
|
||||||
if (_quickScan)
|
if (_quickScan)
|
||||||
{
|
{
|
||||||
_logger.Log("Beginning quick scan of contents from '" + input + "'");
|
_logger.Verbose("Beginning quick scan of contents from '" + input + "'");
|
||||||
List<Rom> internalRomData = ArchiveTools.GetArchiveFileInfo(input, _logger);
|
List<Rom> internalRomData = ArchiveTools.GetArchiveFileInfo(input, _logger);
|
||||||
_logger.Log(internalRomData.Count + " entries found in '" + input + "'");
|
_logger.Verbose(internalRomData.Count + " entries found in '" + input + "'");
|
||||||
|
|
||||||
// If the list is populated, then the file was a filled archive
|
// If the list is populated, then the file was a filled archive
|
||||||
if (internalRomData.Count > 0)
|
if (internalRomData.Count > 0)
|
||||||
@@ -757,7 +757,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
// Try to find the matches to the file that was found
|
// Try to find the matches to the file that was found
|
||||||
List<DatItem> foundroms = rom.GetDuplicates(_datdata, _logger);
|
List<DatItem> foundroms = rom.GetDuplicates(_datdata, _logger);
|
||||||
_logger.Log("File '" + rom.Name + "' had " + foundroms.Count + " matches in the DAT!");
|
_logger.Verbose("File '" + rom.Name + "' had " + foundroms.Count + " matches in the DAT!");
|
||||||
foreach (Rom found in foundroms)
|
foreach (Rom found in foundroms)
|
||||||
{
|
{
|
||||||
// Add rom to the matched list
|
// Add rom to the matched list
|
||||||
@@ -776,7 +776,7 @@ namespace SabreTools.Helper
|
|||||||
if (_toFolder)
|
if (_toFolder)
|
||||||
{
|
{
|
||||||
// Copy file to output directory
|
// Copy file to output directory
|
||||||
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + found.Name + "'");
|
_logger.Verbose("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + found.Name + "'");
|
||||||
string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempDir, _logger);
|
string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempDir, _logger);
|
||||||
if (File.Exists(outfile))
|
if (File.Exists(outfile))
|
||||||
{
|
{
|
||||||
@@ -796,7 +796,7 @@ namespace SabreTools.Helper
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Copy file between archives
|
// Copy file between archives
|
||||||
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_torrentX == false ? found.SHA1 : found.Name) + "'");
|
_logger.Verbose("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_torrentX == false ? found.SHA1 : found.Name) + "'");
|
||||||
|
|
||||||
if (Build.MonoEnvironment || _torrentX == false)
|
if (Build.MonoEnvironment || _torrentX == false)
|
||||||
{
|
{
|
||||||
@@ -853,7 +853,7 @@ namespace SabreTools.Helper
|
|||||||
// If no errors were encountered, we loop through the temp directory
|
// If no errors were encountered, we loop through the temp directory
|
||||||
if (!encounteredErrors)
|
if (!encounteredErrors)
|
||||||
{
|
{
|
||||||
_logger.Log("Archive found! Successfully extracted");
|
_logger.Verbose("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);
|
success &= RebuildToOutputHelper(file, index, total, true);
|
||||||
@@ -1047,7 +1047,7 @@ namespace SabreTools.Helper
|
|||||||
// If no errors were encountered, we loop through the temp directory
|
// If no errors were encountered, we loop through the temp directory
|
||||||
if (!encounteredErrors)
|
if (!encounteredErrors)
|
||||||
{
|
{
|
||||||
_logger.Log("Archive found! Successfully extracted");
|
_logger.Verbose("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);
|
_logger.User("Processing extracted file " + file);
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ namespace SabreTools.Helper
|
|||||||
SkipperRule skipperRule = new SkipperRule();
|
SkipperRule skipperRule = new SkipperRule();
|
||||||
|
|
||||||
// Loop through and find a Skipper that has the right name
|
// Loop through and find a Skipper that has the right name
|
||||||
logger.Log("Beginning search for matching header skip rules");
|
logger.Verbose("Beginning search for matching header skip rules");
|
||||||
foreach (Skipper skipper in List)
|
foreach (Skipper skipper in List)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(skipperName) || (!String.IsNullOrEmpty(skipper.Name) && skipperName.ToLowerInvariant() == skipper.Name.ToLowerInvariant()))
|
if (String.IsNullOrEmpty(skipperName) || (!String.IsNullOrEmpty(skipper.Name) && skipperName.ToLowerInvariant() == skipper.Name.ToLowerInvariant()))
|
||||||
@@ -483,7 +483,7 @@ namespace SabreTools.Helper
|
|||||||
// If we have a blank rule, inform the user
|
// If we have a blank rule, inform the user
|
||||||
if (skipperRule.Tests == null)
|
if (skipperRule.Tests == null)
|
||||||
{
|
{
|
||||||
logger.Log("No matching rule found!");
|
logger.Verbose("No matching rule found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return skipperRule;
|
return skipperRule;
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
if (at == ArchiveType.SevenZip && sevenzip != ArchiveScanLevel.External)
|
if (at == ArchiveType.SevenZip && sevenzip != ArchiveScanLevel.External)
|
||||||
{
|
{
|
||||||
logger.Log("Found archive of type: " + at);
|
logger.Verbose("Found archive of type: " + at);
|
||||||
|
|
||||||
// Create the temp directory
|
// Create the temp directory
|
||||||
Directory.CreateDirectory(tempDir);
|
Directory.CreateDirectory(tempDir);
|
||||||
@@ -109,7 +109,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
else if (at == ArchiveType.GZip && gz != ArchiveScanLevel.External)
|
else if (at == ArchiveType.GZip && gz != ArchiveScanLevel.External)
|
||||||
{
|
{
|
||||||
logger.Log("Found archive of type: " + at);
|
logger.Verbose("Found archive of type: " + at);
|
||||||
|
|
||||||
// Create the temp directory
|
// Create the temp directory
|
||||||
Directory.CreateDirectory(tempDir);
|
Directory.CreateDirectory(tempDir);
|
||||||
@@ -128,7 +128,7 @@ namespace SabreTools.Helper
|
|||||||
else if ((at == ArchiveType.Zip && zip != ArchiveScanLevel.External)
|
else if ((at == ArchiveType.Zip && zip != ArchiveScanLevel.External)
|
||||||
|| (at == ArchiveType.Rar && rar != ArchiveScanLevel.External))
|
|| (at == ArchiveType.Rar && rar != ArchiveScanLevel.External))
|
||||||
{
|
{
|
||||||
logger.Log("Found archive of type: " + at);
|
logger.Verbose("Found archive of type: " + at);
|
||||||
|
|
||||||
// Create the temp directory
|
// Create the temp directory
|
||||||
Directory.CreateDirectory(tempDir);
|
Directory.CreateDirectory(tempDir);
|
||||||
@@ -194,7 +194,7 @@ namespace SabreTools.Helper
|
|||||||
reader = ReaderFactory.Open(File.OpenRead(input));
|
reader = ReaderFactory.Open(File.OpenRead(input));
|
||||||
while (reader.MoveToNextEntry())
|
while (reader.MoveToNextEntry())
|
||||||
{
|
{
|
||||||
logger.Log("Current entry name: '" + reader.Entry.Key + "'");
|
logger.Verbose("Current entry name: '" + reader.Entry.Key + "'");
|
||||||
if (reader.Entry != null && reader.Entry.Key.Contains(entryname))
|
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));
|
||||||
@@ -272,7 +272,7 @@ namespace SabreTools.Helper
|
|||||||
IReader reader = null;
|
IReader reader = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.Log("Found archive of type: " + at);
|
logger.Verbose("Found archive of type: " + at);
|
||||||
long size = 0;
|
long size = 0;
|
||||||
string crc = "";
|
string crc = "";
|
||||||
|
|
||||||
@@ -296,7 +296,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
if (reader.Entry != null && !reader.Entry.IsDirectory)
|
if (reader.Entry != null && !reader.Entry.IsDirectory)
|
||||||
{
|
{
|
||||||
logger.Log("Entry found: '" + reader.Entry.Key + "': "
|
logger.Verbose("Entry found: '" + reader.Entry.Key + "': "
|
||||||
+ (size == 0 ? reader.Entry.Size : size) + ", "
|
+ (size == 0 ? reader.Entry.Size : size) + ", "
|
||||||
+ (crc == "" ? reader.Entry.Crc.ToString("X").ToLowerInvariant() : crc));
|
+ (crc == "" ? reader.Entry.Crc.ToString("X").ToLowerInvariant() : crc));
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace SabreTools.Helper
|
|||||||
"'" + header + "', " +
|
"'" + header + "', " +
|
||||||
"'" + source + "')";
|
"'" + source + "')";
|
||||||
slc = new SqliteCommand(query, dbc);
|
slc = new SqliteCommand(query, dbc);
|
||||||
logger.Log("Result of inserting header: " + slc.ExecuteNonQuery());
|
logger.Verbose("Result of inserting header: " + slc.ExecuteNonQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispose of database objects
|
// Dispose of database objects
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the input file, if possible
|
// Read the input file, if possible
|
||||||
logger.Log("Attempting to read file: \"" + filename + "\"");
|
logger.Verbose("Attempting to read file: \"" + filename + "\"");
|
||||||
|
|
||||||
// Check if file exists
|
// Check if file exists
|
||||||
if (!File.Exists(filename))
|
if (!File.Exists(filename))
|
||||||
@@ -100,7 +100,7 @@ namespace SabreTools.Helper
|
|||||||
/// <returns>The XmlTextReader representing the (possibly converted) file, null otherwise</returns>
|
/// <returns>The XmlTextReader representing the (possibly converted) file, null otherwise</returns>
|
||||||
public static XmlTextReader GetXmlTextReader(string filename, Logger logger)
|
public static XmlTextReader GetXmlTextReader(string filename, Logger logger)
|
||||||
{
|
{
|
||||||
logger.Log("Attempting to read file: \"" + filename + "\"");
|
logger.Verbose("Attempting to read file: \"" + filename + "\"");
|
||||||
|
|
||||||
// Check if file exists
|
// Check if file exists
|
||||||
if (!File.Exists(filename))
|
if (!File.Exists(filename))
|
||||||
@@ -282,7 +282,7 @@ namespace SabreTools.Helper
|
|||||||
int sub = 0;
|
int sub = 0;
|
||||||
while (sldr.Read())
|
while (sldr.Read())
|
||||||
{
|
{
|
||||||
logger.Log("Found match with rom type " + sldr.GetString(1));
|
logger.Verbose("Found match with rom type " + sldr.GetString(1));
|
||||||
header = sldr.GetString(0);
|
header = sldr.GetString(0);
|
||||||
|
|
||||||
logger.User("Creating reheadered file: " +
|
logger.User("Creating reheadered file: " +
|
||||||
|
|||||||
Reference in New Issue
Block a user