diff --git a/DatToMiss/DatToMiss.cs b/DatToMiss/DatToMiss.cs
index e878fad3..200f7d4e 100644
--- a/DatToMiss/DatToMiss.cs
+++ b/DatToMiss/DatToMiss.cs
@@ -80,9 +80,11 @@ namespace SabreTools
return;
}
+ // Make sure that the path provided is real
+
// Read in the roms from the DAT and then write them to the file
Output.WriteToText(Path.GetDirectoryName(input) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(input) + "-miss.txt",
- RomManipulation.Parse(input, 0, 0, logger), logger, usegame, prefix, postfix);
+ Path.GetDirectoryName(input), RomManipulation.Parse(input, 0, 0, logger), logger, usegame, prefix, postfix);
}
}
}
diff --git a/SabreHelper/Output.cs b/SabreHelper/Output.cs
index d0dca637..16a09197 100644
--- a/SabreHelper/Output.cs
+++ b/SabreHelper/Output.cs
@@ -130,19 +130,36 @@ namespace SabreTools.Helper
/// Output a list of roms as a text file with an arbitrary prefix and postfix
///
/// Name of the output file
+ /// Output directory for the miss file
/// List of RomData objects representing the roms to be output
/// Logger object for console and/or file output
/// True if only games are written to text file (default), false for files only
/// Arbitrary string to prefix each line
/// Arbitrary string to postfix each line
/// True if the file was written, false otherwise
- public static bool WriteToText(string textfile, List roms, Logger logger, bool useGame = true, string prefix = "", string postfix = "")
+ public static bool WriteToText(string textfile, string outdir, List roms, Logger logger, bool useGame = true, string prefix = "", string postfix = "")
{
- logger.Log("Opening file for writing: " + textfile);
+ // Normalize the output directory
+ if (outdir == "")
+ {
+ outdir = Environment.CurrentDirectory;
+ }
+ if (!outdir.EndsWith(Path.DirectorySeparatorChar.ToString()))
+ {
+ outdir += Path.DirectorySeparatorChar;
+ }
+
+ // Make the output directory if it doesn't exist
+ if (!Directory.Exists(outdir))
+ {
+ Directory.CreateDirectory(outdir);
+ }
+
+ logger.Log("Opening file for writing: " + outdir + textfile);
try
{
- FileStream fs = File.Create(textfile);
+ FileStream fs = File.Create(outdir + textfile);
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
string lastgame = "";