using Zio; namespace MfGames.Nitride.IO.Paths; /// /// Extension methods for the UPath class. /// public static class UPathExtensions { /// /// Gets the directory path, which excludes the directory at the end /// of the path. /// /// The path to manipulate. /// A normalized path. public static string GetDirectoryIndexPath(this UPath path) { if (path.GetNameWithoutExtension() == "index") { return path.GetDirectory() .ToString() .TrimEnd('/') + "/"; } return path.ToString(); } public static string GetParentDirectoryIndexPath(this UPath path) { UPath indexPath = path.GetDirectoryIndexPath(); UPath parent = indexPath.GetDirectory(); if (parent == null!) { parent = "/"; } string parentPath = parent.ToString() .TrimEnd('/') + "/"; return parentPath; } }