Check if root path ended with directory separator

This commit is contained in:
Matt Nadareski
2023-04-23 20:47:41 -04:00
parent ac718efa78
commit 95afc206dc

View File

@@ -44,8 +44,12 @@ namespace SabreTools.DatTools
string filename = inputs[newItem.Source.Index].CurrentPath;
string rootpath = inputs[newItem.Source.Index].ParentPath;
if (!string.IsNullOrWhiteSpace(rootpath))
if (!string.IsNullOrWhiteSpace(rootpath)
&& !rootpath.EndsWith(Path.DirectorySeparatorChar)
&& !rootpath.EndsWith(Path.AltDirectorySeparatorChar))
{
rootpath += Path.DirectorySeparatorChar.ToString();
}
filename = filename.Remove(0, rootpath.Length);
newItem.Machine.Name = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar