Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions TimVer/Helpers/PathHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,6 @@ namespace TimVer.Helpers;

internal static class PathHelpers
{

/// <summary>
/// Returns a condensed representation of a file system path by keeping the specified number of
/// leading and trailing path segments and replacing the middle portion with an ellipsis ("...").
/// </summary>
/// <param name="path">The full path to condense. Segments are determined by <see cref="Path.DirectorySeparatorChar"/>.</param>
/// <param name="leading">Number of leading segments to keep (may be zero).</param>
/// <param name="trailing">Number of trailing segments to keep (may be zero).</param>
/// <remarks>
/// Example: input "C:\a\b\c\d\e\f\g", leading=2, trailing=2 => "C:\a\...\f\g".
/// </remarks>
/// <returns>
/// A condensed path string. If the path contains fewer than the sum of <paramref name="leading"/>
/// and <paramref name="trailing"/> segments the original <paramref name="path"/> is returned.
/// </returns>
public static string GetCondensedPath(string path, int leading, int trailing)
{
if (string.IsNullOrEmpty(path))
{
return path;
}
if (leading < 0 || trailing < 0)
{
return path;
}

string[] parts = path.Split(Path.DirectorySeparatorChar);
if (parts.Length <= leading + trailing)
{
return path;
}

StringBuilder sb = new(path.Length);
for (int i = 0; i < leading; i++)
{
sb.Append(parts[i]).Append(Path.DirectorySeparatorChar);
}

sb.Append("...").Append(Path.DirectorySeparatorChar);

for (int i = trailing; i > 0; i--)
{
sb.Append(parts[^i]).Append(Path.DirectorySeparatorChar);
}

return sb.ToString().TrimEnd(Path.DirectorySeparatorChar);
}

/// <summary>
/// If a path to a file includes the user profile name replace it with %USERPROFILE%.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion TimVer/Helpers/TextFileViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void ViewTextFile(string textFile)
p.StartInfo.UseShellExecute = true;
p.StartInfo.ErrorDialog = false;
_ = p.Start();
_log.Debug($"Opening {fname} in default application");
_log.Debug($"Opening {fname}");
}
catch (Win32Exception ex)
{
Expand Down
1 change: 0 additions & 1 deletion TimVer/Views/AboutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
xmlns:config="clr-namespace:TimVer.Configuration"
xmlns:convert="clr-namespace:TimVer.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:global="clr-namespace:System.Globalization;assembly=mscorlib"
xmlns:helpers="clr-namespace:TimVer.Helpers"
xmlns:local="clr-namespace:TimVer"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
Expand Down