Skip to content

Commit

Permalink
[HydroThunderTool] Fix invalid paths for file associations
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperbx committed Aug 16, 2024
1 parent f39e5de commit aa75b1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 10 additions & 1 deletion HyperLib/Helpers/FileSystemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static string TruncateLastExtension(string in_filePath, bool in_isFileNam
return Path.Combine(Path.GetDirectoryName(in_filePath), name);
}

public static string OmitFirstDirectory(string in_path)
public static string OmitRootDirectory(string in_path)
{
var index = in_path.IndexOf(Path.DirectorySeparatorChar);

Expand All @@ -69,6 +69,15 @@ public static string OmitFirstDirectory(string in_path)
: in_path;
}

public static string GetRootDirectory(string in_path)
{
var index = in_path.IndexOf(Path.DirectorySeparatorChar);

return index >= 0
? in_path[..(index + 1)]
: in_path;
}

public static EFileSystemBasicType GetBasicType(string in_path)
{
if (Directory.Exists(in_path))
Expand Down
5 changes: 3 additions & 2 deletions Tools/HydroThunderTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ this directory is likely an extracted PC archive.
Otherwise, we should prompt the user to confirm. */
if (File.Exists(Path.Combine(path, "Base.apf")))
{
path = Path.GetRelativePath(path, inputPath);
path = FileSystemHelper.OmitFirstDirectory(path);
var archiveRoot = FileSystemHelper.GetRootDirectory(Path.GetRelativePath(path, inputPath));

path = Path.Combine(path, archiveRoot);

foreach (var dir in Directory.EnumerateDirectories(path))
{
Expand Down

0 comments on commit aa75b1f

Please sign in to comment.