mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
@@ -221,7 +221,7 @@ namespace SabreTools.Helper.Tools
|
||||
/// <returns>Name of the extracted file, null on error</returns>
|
||||
public static string ExtractItem(string input, string entryName, string tempDir, Logger logger)
|
||||
{
|
||||
string realEntry = String.Empty;
|
||||
string realEntry = "";
|
||||
Stream ms = ExtractStream(input, entryName, out realEntry, logger);
|
||||
|
||||
// If we got out a null or empty entry, then we don't have a stream
|
||||
@@ -265,7 +265,7 @@ namespace SabreTools.Helper.Tools
|
||||
public static Stream ExtractStream(string input, string entryName, out string realEntry, Logger logger)
|
||||
{
|
||||
// Set the real entry name
|
||||
realEntry = String.Empty;
|
||||
realEntry = "";
|
||||
|
||||
// Get a writable stream to return
|
||||
Stream st = new MemoryStream();
|
||||
@@ -433,7 +433,7 @@ namespace SabreTools.Helper.Tools
|
||||
{
|
||||
logger.Verbose("Found archive of type: " + at);
|
||||
long size = 0;
|
||||
string crc = String.Empty;
|
||||
string crc = "";
|
||||
|
||||
switch (at)
|
||||
{
|
||||
@@ -445,14 +445,14 @@ namespace SabreTools.Helper.Tools
|
||||
{
|
||||
logger.Verbose("Entry found: '" + entry.Key + "': "
|
||||
+ (size == 0 ? entry.Size : size) + ", "
|
||||
+ (crc == String.Empty ? entry.Crc.ToString("X").ToLowerInvariant() : crc));
|
||||
+ (crc == "" ? entry.Crc.ToString("X").ToLowerInvariant() : crc));
|
||||
|
||||
roms.Add(new Rom
|
||||
{
|
||||
Type = ItemType.Rom,
|
||||
Name = entry.Key,
|
||||
Size = (size == 0 ? entry.Size : size),
|
||||
CRC = (crc == String.Empty ? entry.Crc.ToString("X").ToLowerInvariant() : crc),
|
||||
CRC = (crc == "" ? entry.Crc.ToString("X").ToLowerInvariant() : crc),
|
||||
|
||||
Machine = new Machine
|
||||
{
|
||||
@@ -481,14 +481,14 @@ namespace SabreTools.Helper.Tools
|
||||
{
|
||||
logger.Verbose("Entry found: '" + entry.Key + "': "
|
||||
+ (size == 0 ? entry.Size : size) + ", "
|
||||
+ (crc == String.Empty ? entry.Crc.ToString("X").ToLowerInvariant() : crc));
|
||||
+ (crc == "" ? entry.Crc.ToString("X").ToLowerInvariant() : crc));
|
||||
|
||||
roms.Add(new Rom
|
||||
{
|
||||
Type = ItemType.Rom,
|
||||
Name = entry.Key,
|
||||
Size = (size == 0 ? entry.Size : size),
|
||||
CRC = (crc == String.Empty ? entry.Crc.ToString("X").ToLowerInvariant() : crc),
|
||||
CRC = (crc == "" ? entry.Crc.ToString("X").ToLowerInvariant() : crc),
|
||||
|
||||
Machine = new Machine
|
||||
{
|
||||
@@ -507,14 +507,14 @@ namespace SabreTools.Helper.Tools
|
||||
{
|
||||
logger.Verbose("Entry found: '" + entry.Key + "': "
|
||||
+ (size == 0 ? entry.Size : size) + ", "
|
||||
+ (crc == String.Empty ? entry.Crc.ToString("X").ToLowerInvariant() : crc));
|
||||
+ (crc == "" ? entry.Crc.ToString("X").ToLowerInvariant() : crc));
|
||||
|
||||
roms.Add(new Rom
|
||||
{
|
||||
Type = ItemType.Rom,
|
||||
Name = entry.Key,
|
||||
Size = (size == 0 ? entry.Size : size),
|
||||
CRC = (crc == String.Empty ? entry.Crc.ToString("X").ToLowerInvariant() : crc),
|
||||
CRC = (crc == "" ? entry.Crc.ToString("X").ToLowerInvariant() : crc),
|
||||
|
||||
Machine = new Machine
|
||||
{
|
||||
@@ -1119,7 +1119,7 @@ namespace SabreTools.Helper.Tools
|
||||
}
|
||||
|
||||
// Get the output archive name from the first rebuild rom
|
||||
string archiveFileName = Path.Combine(outDir, Style.RemovePathUnsafeCharacters(roms[0].Machine.Name) + (roms[0].Machine.Name.EndsWith(".tar") ? String.Empty : ".tar"));
|
||||
string archiveFileName = Path.Combine(outDir, Style.RemovePathUnsafeCharacters(roms[0].Machine.Name) + (roms[0].Machine.Name.EndsWith(".tar") ? "" : ".tar"));
|
||||
|
||||
// Set internal variables
|
||||
Stream tarstream = new MemoryStream();
|
||||
@@ -1445,7 +1445,7 @@ namespace SabreTools.Helper.Tools
|
||||
}
|
||||
|
||||
// Get the output archive name from the first rebuild rom
|
||||
string archiveFileName = Path.Combine(outDir, Style.RemovePathUnsafeCharacters(roms[0].Machine.Name) + (roms[0].Machine.Name.EndsWith(".zip") ? String.Empty : ".zip"));
|
||||
string archiveFileName = Path.Combine(outDir, Style.RemovePathUnsafeCharacters(roms[0].Machine.Name) + (roms[0].Machine.Name.EndsWith(".zip") ? "" : ".zip"));
|
||||
|
||||
// Set internal variables
|
||||
Stream writeStream = null;
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace SabreTools.Helper.Tools
|
||||
}
|
||||
|
||||
// Read the input file, if possible
|
||||
logger.Verbose("Attempting to read file to get format: "" + filename + """);
|
||||
logger.Verbose("Attempting to read file to get format: \"" + filename + "\"");
|
||||
|
||||
// Check if file exists
|
||||
if (!File.Exists(filename))
|
||||
@@ -224,7 +224,7 @@ namespace SabreTools.Helper.Tools
|
||||
|
||||
// Add unique data from the file
|
||||
rom.Name = Path.GetFileName(input);
|
||||
rom.Date = (date ? new FileInfo(input).LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss") : String.Empty);
|
||||
rom.Date = (date ? new FileInfo(input).LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss") : "");
|
||||
|
||||
return rom;
|
||||
}
|
||||
@@ -315,7 +315,7 @@ namespace SabreTools.Helper.Tools
|
||||
public static bool DetectSkipperAndTransform(string file, string outDir, Logger logger)
|
||||
{
|
||||
// Create the output directory if it doesn't exist
|
||||
if (outDir != String.Empty && !Directory.Exists(outDir))
|
||||
if (outDir != "" && !Directory.Exists(outDir))
|
||||
{
|
||||
Directory.CreateDirectory(outDir);
|
||||
}
|
||||
@@ -323,7 +323,7 @@ namespace SabreTools.Helper.Tools
|
||||
logger.User("\nGetting skipper information for '" + file + "'");
|
||||
|
||||
// Get the skipper rule that matches the file, if any
|
||||
SkipperRule rule = Skipper.GetMatchingRule(file, String.Empty, logger);
|
||||
SkipperRule rule = Skipper.GetMatchingRule(file, "", logger);
|
||||
|
||||
// If we have an empty rule, return false
|
||||
if (rule.Tests == null || rule.Tests.Count == 0 || rule.Operation != HeaderSkipOperation.None)
|
||||
@@ -346,7 +346,7 @@ namespace SabreTools.Helper.Tools
|
||||
br.Dispose();
|
||||
|
||||
// Apply the rule to the file
|
||||
string newfile = (outDir == String.Empty ? Path.GetFullPath(file) + ".new" : Path.Combine(outDir, Path.GetFileName(file)));
|
||||
string newfile = (outDir == "" ? Path.GetFullPath(file) + ".new" : Path.Combine(outDir, Path.GetFileName(file)));
|
||||
rule.TransformFile(file, newfile, logger);
|
||||
|
||||
// If the output file doesn't exist, return false
|
||||
@@ -385,7 +385,7 @@ namespace SabreTools.Helper.Tools
|
||||
{
|
||||
try
|
||||
{
|
||||
outputs.Add(Path.GetFullPath(file) + (appendparent ? "¬" + Path.GetFullPath(input) : String.Empty));
|
||||
outputs.Add(Path.GetFullPath(file) + (appendparent ? "¬" + Path.GetFullPath(input) : ""));
|
||||
}
|
||||
catch (PathTooLongException)
|
||||
{
|
||||
@@ -401,7 +401,7 @@ namespace SabreTools.Helper.Tools
|
||||
{
|
||||
try
|
||||
{
|
||||
outputs.Add(Path.GetFullPath(input) + (appendparent ? "¬" + Path.GetFullPath(input) : String.Empty));
|
||||
outputs.Add(Path.GetFullPath(input) + (appendparent ? "¬" + Path.GetFullPath(input) : ""));
|
||||
}
|
||||
catch (PathTooLongException)
|
||||
{
|
||||
@@ -437,7 +437,7 @@ namespace SabreTools.Helper.Tools
|
||||
/// <returns>The XmlTextReader representing the (possibly converted) file, null otherwise</returns>
|
||||
public static XmlReader GetXmlTextReader(string filename, Logger logger)
|
||||
{
|
||||
logger.Verbose("Attempting to read file: "" + filename + """);
|
||||
logger.Verbose("Attempting to read file: \"" + filename + "\"");
|
||||
|
||||
// Check if file exists
|
||||
if (!File.Exists(filename))
|
||||
@@ -494,7 +494,7 @@ namespace SabreTools.Helper.Tools
|
||||
public static bool RestoreHeader(string file, string outDir, Logger logger)
|
||||
{
|
||||
// Create the output directory if it doesn't exist
|
||||
if (outDir != String.Empty && !Directory.Exists(outDir))
|
||||
if (outDir != "" && !Directory.Exists(outDir))
|
||||
{
|
||||
Directory.CreateDirectory(outDir);
|
||||
}
|
||||
@@ -515,9 +515,9 @@ namespace SabreTools.Helper.Tools
|
||||
for (int i = 0; i < headers.Count; i++)
|
||||
{
|
||||
logger.User("Creating reheadered file: " +
|
||||
(outDir == String.Empty ? Path.GetFullPath(file) + ".new" : Path.Combine(outDir, Path.GetFileName(file))) + i);
|
||||
(outDir == "" ? Path.GetFullPath(file) + ".new" : Path.Combine(outDir, Path.GetFileName(file))) + i);
|
||||
AppendBytesToFile(file,
|
||||
(outDir == String.Empty ? Path.GetFullPath(file) + ".new" : Path.Combine(outDir, Path.GetFileName(file))) + i, headers[i], string.Empty);
|
||||
(outDir == "" ? Path.GetFullPath(file) + ".new" : Path.Combine(outDir, Path.GetFileName(file))) + i, headers[i], string.Empty);
|
||||
logger.User("Reheadered file created!");
|
||||
}
|
||||
|
||||
@@ -587,12 +587,12 @@ namespace SabreTools.Helper.Tools
|
||||
if (!noMD5)
|
||||
{
|
||||
md5.TransformFinalBlock(buffer, 0, 0);
|
||||
rom.MD5 = BitConverter.ToString(md5.Hash).Replace("-", String.Empty).ToLowerInvariant();
|
||||
rom.MD5 = BitConverter.ToString(md5.Hash).Replace("-", "").ToLowerInvariant();
|
||||
}
|
||||
if (!noSHA1)
|
||||
{
|
||||
sha1.TransformFinalBlock(buffer, 0, 0);
|
||||
rom.SHA1 = BitConverter.ToString(sha1.Hash).Replace("-", String.Empty).ToLowerInvariant();
|
||||
rom.SHA1 = BitConverter.ToString(sha1.Hash).Replace("-", "").ToLowerInvariant();
|
||||
}
|
||||
|
||||
// Dispose of the hashers
|
||||
|
||||
@@ -67,16 +67,16 @@ namespace SabreTools.Helper.Tools
|
||||
public static string CleanHashData(string hash, int padding)
|
||||
{
|
||||
// First get the hash to the correct length
|
||||
hash = (String.IsNullOrEmpty(hash) ? String.Empty : hash.Trim());
|
||||
hash = (String.IsNullOrEmpty(hash) ? "" : hash.Trim());
|
||||
hash = (hash.StartsWith("0x") ? hash.Remove(0, 2) : hash);
|
||||
hash = (hash == "-" ? String.Empty : hash);
|
||||
hash = (String.IsNullOrEmpty(hash) ? String.Empty : hash.PadLeft(padding, '0'));
|
||||
hash = (hash == "-" ? "" : hash);
|
||||
hash = (String.IsNullOrEmpty(hash) ? "" : hash.PadLeft(padding, '0'));
|
||||
hash = hash.ToLowerInvariant();
|
||||
|
||||
// Then make sure that it has the correct characters
|
||||
if (!Regex.IsMatch(hash, "[0-9a-f]{" + padding + "}"))
|
||||
{
|
||||
hash = String.Empty;
|
||||
hash = "";
|
||||
}
|
||||
|
||||
return hash;
|
||||
@@ -418,15 +418,15 @@ namespace SabreTools.Helper.Tools
|
||||
{
|
||||
// Preprocess the string
|
||||
s = s.Trim();
|
||||
s = Regex.Replace(s, @"^\S* \(", String.Empty); // Remove item identifier and opening brace
|
||||
s = Regex.Replace(s, @"\)\S*#.*$", String.Empty); // Remove trailing comments
|
||||
s = Regex.Replace(s, @"^\S* \(", ""); // Remove item identifier and opening brace
|
||||
s = Regex.Replace(s, @"\)\S*#.*$", ""); // Remove trailing comments
|
||||
s = s.TrimEnd(')'); // Remove closing brace
|
||||
s = s.Trim(); // Remove leading and trailing whitespace
|
||||
|
||||
// Now we get each string, divided up as cleanly as possible
|
||||
string[] matches = Regex
|
||||
//.Matches(s, @"([^\s]*String.Empty[^String.Empty]+String.Empty[^\s]*)|[^String.Empty]?\w+[^String.Empty]?")
|
||||
.Matches(s, @"[^\sString.Empty]+|String.Empty[^String.Empty]*String.Empty")
|
||||
//.Matches(s, @"([^\s]*""[^""]+""[^\s]*)|[^""]?\w+[^""]?")
|
||||
.Matches(s, @"[^\s""]+|""[^""]*""")
|
||||
.Cast<Match>()
|
||||
.Select(m => m.Groups[0].Value)
|
||||
.ToArray();
|
||||
@@ -448,7 +448,7 @@ namespace SabreTools.Helper.Tools
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
return String.Empty;
|
||||
return "";
|
||||
}
|
||||
|
||||
if (s.Contains("/"))
|
||||
@@ -462,7 +462,7 @@ namespace SabreTools.Helper.Tools
|
||||
return String.Join("\\", tempkey.Take(tempkey.Length - 1));
|
||||
}
|
||||
|
||||
return String.Empty;
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -475,7 +475,7 @@ namespace SabreTools.Helper.Tools
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
return String.Empty;
|
||||
return "";
|
||||
}
|
||||
|
||||
if (s.Contains("/"))
|
||||
@@ -575,14 +575,14 @@ namespace SabreTools.Helper.Tools
|
||||
{ "Й", "J" }, { "К", "K" }, { "Л", "L" }, { "М", "M" }, { "Н", "N" },
|
||||
{ "О", "O" }, { "П", "P" }, { "Р", "R" }, { "С", "S" }, { "Т", "T" },
|
||||
{ "У", "U" }, { "Ф", "f" }, { "Х", "Kh" }, { "Ц", "Ts" }, { "Ч", "Ch" },
|
||||
{ "Ш", "Sh" }, { "Щ", "Sch" }, { "Ъ", String.Empty }, { "Ы", "y" }, { "Ь", String.Empty },
|
||||
{ "Ш", "Sh" }, { "Щ", "Sch" }, { "Ъ", "" }, { "Ы", "y" }, { "Ь", "" },
|
||||
{ "Э", "e" }, { "Ю", "yu" }, { "Я", "ya" }, { "а", "a" }, { "б", "b" },
|
||||
{ "в", "v" }, { "г", "g" }, { "д", "d" }, { "е", "e" }, { "ё", "yo" },
|
||||
{ "ж", "zh" }, { "з", "z" }, { "и", "i" }, { "й", "j" }, { "к", "k" },
|
||||
{ "л", "l" }, { "м", "m" }, { "н", "n" }, { "о", "o" }, { "п", "p" },
|
||||
{ "р", "r" }, { "с", "s" }, { "т", "t" }, { "у", "u" }, { "ф", "f" },
|
||||
{ "х", "kh" }, { "ц", "ts" }, { "ч", "ch" }, { "ш", "sh" }, { "щ", "sch" },
|
||||
{ "ъ", String.Empty }, { "ы", "y" }, { "ь", String.Empty }, { "э", "e" }, { "ю", "yu" },
|
||||
{ "ъ", "" }, { "ы", "y" }, { "ь", "" }, { "э", "e" }, { "ю", "yu" },
|
||||
{ "я", "ya" },
|
||||
};
|
||||
|
||||
@@ -715,7 +715,7 @@ namespace SabreTools.Helper.Tools
|
||||
{
|
||||
if (hexString.Contains("-"))
|
||||
{
|
||||
hexString = hexString.Replace("-", String.Empty);
|
||||
hexString = hexString.Replace("-", "");
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -734,7 +734,7 @@ namespace SabreTools.Helper.Tools
|
||||
/// </summary>
|
||||
public static string ConvertAsciiToHex(string asciiString)
|
||||
{
|
||||
string hexOutput = String.Empty;
|
||||
string hexOutput = "";
|
||||
foreach (char _eachChar in asciiString.ToCharArray())
|
||||
{
|
||||
// Get the integral value of the character.
|
||||
|
||||
Reference in New Issue
Block a user