[ALL] Update string check; add output path helper

This commit is contained in:
Matt Nadareski
2017-11-08 13:15:44 -08:00
parent bd27b486f8
commit de16014af9
23 changed files with 397 additions and 410 deletions

View File

@@ -102,7 +102,7 @@ namespace SabreTools.Library.FileTypes
string match = files.Where(s => s.EndsWith(entryName)).FirstOrDefault();
// If we had a file, copy that over to the new name
if (!String.IsNullOrEmpty(match))
if (!String.IsNullOrWhiteSpace(match))
{
realentry = match;
File.Copy(match, Path.Combine(outDir, entryName));
@@ -141,7 +141,7 @@ namespace SabreTools.Library.FileTypes
string match = files.Where(s => s.EndsWith(entryName)).FirstOrDefault();
// If we had a file, copy that over to the new name
if (!String.IsNullOrEmpty(match))
if (!String.IsNullOrWhiteSpace(match))
{
Utilities.TryOpenRead(match).CopyTo(ms);
realentry = match;
@@ -269,7 +269,7 @@ namespace SabreTools.Library.FileTypes
if (rom.Type == ItemType.Rom)
{
if (date && !String.IsNullOrEmpty(((Rom)rom).Date))
if (date && !String.IsNullOrWhiteSpace(((Rom)rom).Date))
{
File.SetCreationTime(fileName, DateTime.Parse(((Rom)rom).Date));
}

View File

@@ -351,7 +351,7 @@ namespace SabreTools.Library.FileTypes
{
// Get temporary date-time if possible
DateTime? usableDate = null;
if (date && !String.IsNullOrEmpty(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt))
if (date && !String.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt))
{
usableDate = dt;
}
@@ -404,7 +404,7 @@ namespace SabreTools.Library.FileTypes
// Get temporary date-time if possible
DateTime? usableDate = null;
if (date && !String.IsNullOrEmpty(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt))
if (date && !String.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt))
{
usableDate = dt;
}
@@ -530,7 +530,7 @@ namespace SabreTools.Library.FileTypes
// Get temporary date-time if possible
DateTime? usableDate = null;
if (date && !String.IsNullOrEmpty(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out DateTime dt))
if (date && !String.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out DateTime dt))
{
usableDate = dt;
}
@@ -590,7 +590,7 @@ namespace SabreTools.Library.FileTypes
{
// Get temporary date-time if possible
DateTime? usableDate = null;
if (date && !String.IsNullOrEmpty(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out DateTime dt))
if (date && !String.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out DateTime dt))
{
usableDate = dt;
}

View File

@@ -81,7 +81,7 @@ namespace SabreTools.Library.FileTypes
zr = zf.OpenReadStream(i, false, out Stream readStream, out ulong streamsize, out SabreTools.Library.Data.CompressionMethod cm, out uint lastMod);
// Create the rest of the path, if needed
if (!String.IsNullOrEmpty(Path.GetDirectoryName(zf.Entries[i].FileName)))
if (!String.IsNullOrWhiteSpace(Path.GetDirectoryName(zf.Entries[i].FileName)))
{
Directory.CreateDirectory(Path.Combine(outDir, Path.GetDirectoryName(zf.Entries[i].FileName)));
}
@@ -465,7 +465,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(inputStream.Length);
DateTime dt = DateTime.Now;
if (date && !String.IsNullOrEmpty(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
if (date && !String.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
{
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.OpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize,
@@ -536,7 +536,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(inputStream.Length);
DateTime dt = DateTime.Now;
if (date && !String.IsNullOrEmpty(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
if (date && !String.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
{
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.OpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize,
@@ -686,7 +686,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(new FileInfo(inputFiles[index]).Length);
DateTime dt = DateTime.Now;
if (date && !String.IsNullOrEmpty(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out dt))
if (date && !String.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out dt))
{
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.OpenWriteStream(false, false, roms[index].Name.Replace('\\', '/'), istreamSize,
@@ -763,7 +763,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(new FileInfo(inputFiles[-index - 1]).Length);
DateTime dt = DateTime.Now;
if (date && !String.IsNullOrEmpty(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out dt))
if (date && !String.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out dt))
{
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.OpenWriteStream(false, false, roms[-index - 1].Name.Replace('\\', '/'), istreamSize,