From 2d2ae31814f6aaf4596508b7f9d76958bc4cfa51 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 13 Apr 2016 00:44:55 -0700 Subject: [PATCH] Fix using "Default" --- DATFromDir/DATFromDir.cs | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/DATFromDir/DATFromDir.cs b/DATFromDir/DATFromDir.cs index 67c79b07..1ecfaa39 100644 --- a/DATFromDir/DATFromDir.cs +++ b/DATFromDir/DATFromDir.cs @@ -174,10 +174,23 @@ namespace SabreTools // the possibiliites for different ways to generate a DAT from multiple things // Double check to see what it needs to be named - string[] splitPath = _basePath.Split(Path.DirectorySeparatorChar); - _name = (_name == "" ? (inputs.Count > 1 ? Environment.CurrentDirectory.Split(Path.DirectorySeparatorChar).Last() : - (_basePath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? splitPath[splitPath.Length - 2] : splitPath.Last())) : _name); - _name = (_name == "" ? "Default " : _name); + if (_name == "") + { + if (inputs.Count > 1) + { + _name = Environment.CurrentDirectory.Split(Path.DirectorySeparatorChar).Last(); + Console.WriteLine(_name); + } + else + { + if (_basePath.EndsWith(Path.DirectorySeparatorChar.ToString())) + { + _basePath = _basePath.Substring(0, _basePath.Length - 1); + } + _name = _basePath.Split(Path.DirectorySeparatorChar).Last(); + } + } + _name = (_name == "" ? "Default" : _name); _desc = (_desc == "" ? _name + (_noDate ? "" : " (" + _date + ")") : _desc); // Now write it all out as a DAT @@ -386,9 +399,14 @@ namespace SabreTools } } - string actualroot = (item == _basePath ? "Default" : Path.GetDirectoryName(item.Remove(0, _basePath.Length)).Split(Path.DirectorySeparatorChar)[0]); - actualroot = (actualroot == "" ? "Default" : actualroot); - string actualitem = (item == _basePath ? item : item.Remove(0, _basePath.Length).Remove(0, (actualroot != "Default" ? actualroot.Length + 1 : 0))); + if (_basePath.EndsWith(Path.DirectorySeparatorChar.ToString())) + { + _basePath = _basePath.Substring(0, _basePath.Length - 1); + } + + string actualroot = (item == _basePath ? item.Split(Path.DirectorySeparatorChar).Last() : item.Remove(0, _basePath.Length).Split(Path.DirectorySeparatorChar)[0]); + actualroot = (actualroot == "" ? _basePath : actualroot); + string actualitem = (item == _basePath ? item : item.Remove(0, _basePath.Length).Remove(0, (actualroot != "Default" ? actualroot.Length : 0))); // Drag and drop is funny if (actualitem == Path.GetFullPath(actualitem))