Fix writing to folder

Make sure that the folder exists as well as make sure that it has the proper path markings
This commit is contained in:
Matt Nadareski
2016-03-31 16:40:28 -07:00
parent 647bb5b7b9
commit e07c54bff3
2 changed files with 9 additions and 3 deletions

View File

@@ -50,9 +50,15 @@ namespace SabreTools
// Take care of special outfolder cases // Take care of special outfolder cases
_outdir = (outdir == "" ? outdir : _outdir = (outdir == "" ? outdir :
(outdir.Contains("/") && !outdir.EndsWith("/") ? outdir + "/" : (outdir.Contains("/") && !outdir.EndsWith("/") ? outdir + "/" :
(outdir.Contains("\\") && !outdir.EndsWith("\\") ? outdir + "\\" : outdir) (outdir.Contains("\\") && !outdir.EndsWith("\\") ? outdir + "\\" :
(!outdir.Contains("/") && !outdir.Contains("\\") ? outdir + "\\" : outdir)
)
) )
); );
if (!Directory.Exists(_outdir))
{
Directory.CreateDirectory(_outdir);
}
_headers = new Dictionary<int, string>(); _headers = new Dictionary<int, string>();
_headers.Add(25, "a7800.xml"); _headers.Add(25, "a7800.xml");
@@ -74,7 +80,7 @@ namespace SabreTools
int id = 0; int id = 0;
if (_sources != "" && Int32.TryParse(_sources, out id) && id <= 14) if (_sources != "" && Int32.TryParse(_sources, out id) && id <= 14)
{ {
_logger.Log("This source (" + id + ") is import-only so a DAT cannot be created. We apologize for the inconvenience."); _logger.Warning("This source (" + id + ") is import-only so a DAT cannot be created. We apologize for the inconvenience.");
return false; return false;
} }

View File

@@ -472,7 +472,7 @@ Make a selection:
1) " + (norename ? "Enable game renaming" : "Disable game renaming") + @" 1) " + (norename ? "Enable game renaming" : "Disable game renaming") + @"
2) " + (old ? "Enable XML output" : "Enable RomVault output") + @" 2) " + (old ? "Enable XML output" : "Enable RomVault output") + @"
3) Enter an output folder 3) Enter an output folder
4) Generate all DAT files 4) Generate all DAT files
B) Go back to the previous menu B) Go back to the previous menu
"); ");