diff --git a/DATabase/Import.cs b/DATabase/Import.cs
index 48de577e..5a4680b6 100644
--- a/DATabase/Import.cs
+++ b/DATabase/Import.cs
@@ -64,7 +64,7 @@ namespace SabreTools
/// Import the data from file into the database
///
/// True if the data was imported, false otherwise
- public bool ImportData ()
+ public bool ImportData()
{
// If file doesn't exist, error and return
if (!File.Exists(_filepath))
diff --git a/DATabase/TrimMerge.cs b/DATabase/TrimMerge.cs
index 71ad2f69..fde2e34a 100644
--- a/DATabase/TrimMerge.cs
+++ b/DATabase/TrimMerge.cs
@@ -35,14 +35,19 @@ namespace SabreTools
///
/// Trim and process the given DAT or folder of DATs
///
- public void Process()
+ /// True if the DAT could be updated, false otherwise
+ public bool Process()
{
+ // If file doesn't exist, error and return
+ if (!File.Exists(_filename))
+ {
+ _logger.Error("File '" + _filename + "' doesn't exist");
+ return false;
+ }
+
_path = (_path == "" ? Environment.CurrentDirectory : _path);
- // Drag and drop means quotes; we don't want quotes
- _filename = _filename.Replace("\"", "");
-
- // We also want the full path of the file, just in case
+ // We want the full path of the file, just in case
_filename = Path.GetFullPath(_filename);
// If it's a single file, handle it as such
@@ -68,7 +73,7 @@ namespace SabreTools
}
}
- _logger.Close();
+ return true;
}
///
diff --git a/DatSplit/DatSplit.cs b/DatSplit/DatSplit.cs
index d430ec8c..10fa8d41 100644
--- a/DatSplit/DatSplit.cs
+++ b/DatSplit/DatSplit.cs
@@ -68,14 +68,28 @@ namespace SabreTools
///
/// Split a DAT based on filtering by 2 extensions
///
- public void Split()
+ /// True if DAT was split, false otherwise
+ public bool Split()
{
+ // If file doesn't exist, error and return
+ if (!File.Exists(_filename))
+ {
+ _logger.Error("File '" + _filename + "' doesn't exist");
+ return false;
+ }
+
List romsA = new List();
List romsB = new List();
// Load the current DAT to be processed
List roms = RomManipulation.Parse(_filename, 0, 0, _logger);
+ // If roms is empty, return false
+ if (roms.Count == 0)
+ {
+ return false;
+ }
+
// Now separate the roms accordingly
foreach (RomData rom in roms)
{
@@ -95,10 +109,12 @@ namespace SabreTools
}
// Then write out both files
- Output.WriteToDat(Path.GetFileNameWithoutExtension(_filename) + "." + _extA, Path.GetFileNameWithoutExtension(_filename) + "." + _extA,
+ bool success = Output.WriteToDat(Path.GetFileNameWithoutExtension(_filename) + "." + _extA, Path.GetFileNameWithoutExtension(_filename) + "." + _extA,
"", "", "", "", false, !RomManipulation.IsXmlDat(_filename), "", romsA, _logger);
- Output.WriteToDat(Path.GetFileNameWithoutExtension(_filename) + "." + _extB, Path.GetFileNameWithoutExtension(_filename) + "." + _extB,
+ success &= Output.WriteToDat(Path.GetFileNameWithoutExtension(_filename) + "." + _extB, Path.GetFileNameWithoutExtension(_filename) + "." + _extB,
"", "", "", "", false, !RomManipulation.IsXmlDat(_filename), "", romsB, _logger);
+
+ return success;
}
}
}