Skip to content

Commit 8be9928

Browse files
committed
Handle hilarious paradox handling of drive letter paths in case insensitive filesystem (on windows)
1 parent ff41eea commit 8be9928

File tree

6 files changed

+169
-70
lines changed

6 files changed

+169
-70
lines changed

src/IronyModManager.IO.Common/PathOperations.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 09-12-2021
55
//
66
// Last Modified By : Mario
7-
// Last Modified On : 07-05-2024
7+
// Last Modified On : 06-26-2025
88
// ***********************************************************************
99
// <copyright file="PathOperations.cs" company="Mario">
1010
// Mario
@@ -27,6 +27,23 @@ public static class PathOperations
2727
{
2828
#region Methods
2929

30+
/// <summary>
31+
/// Gets the actual path casing.
32+
/// </summary>
33+
/// <param name="path">The path.</param>
34+
/// <returns>System.String.</returns>
35+
public static string GetActualPathCasing(string path)
36+
{
37+
if (!File.Exists(path) && !Directory.Exists(path))
38+
{
39+
return path;
40+
}
41+
42+
var di = new DirectoryInfo(path);
43+
44+
return di.Parent != null ? Path.Combine(GetActualPathCasing(di.Parent.FullName), di.Parent.GetFileSystemInfos(di.Name)[0].Name) : di.Name.ToUpperInvariant();
45+
}
46+
3047
/// <summary>
3148
/// Resolves the relative path.
3249
/// </summary>
@@ -46,10 +63,10 @@ public static string ResolveRelativePath(string basePath, string path)
4663
}
4764

4865
/// <summary>
49-
/// Pathes the contains relative segments.
66+
/// Determines if path the contains relative segments.
5067
/// </summary>
5168
/// <param name="path">The path.</param>
52-
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
69+
/// <returns><c>true</c> if contains relative segment, <c>false</c> otherwise.</returns>
5370
private static bool PathContainsRelativeSegments(string path)
5471
{
5572
return path.StandardizeDirectorySeparator().Split(Path.DirectorySeparatorChar).Any(p => string.IsNullOrWhiteSpace(p.Replace(".", string.Empty)));

src/IronyModManager.IO/Mods/Constants.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,25 @@
44
// Created : 08-11-2020
55
//
66
// Last Modified By : Mario
7-
// Last Modified On : 02-23-2023
7+
// Last Modified On : 06-26-2025
88
// ***********************************************************************
99
// <copyright file="Constants.cs" company="Mario">
1010
// Mario
1111
// </copyright>
1212
// <summary></summary>
1313
// ***********************************************************************
14+
1415
using System;
1516
using System.Collections.Generic;
17+
using System.Diagnostics.CodeAnalysis;
18+
using System.Linq;
1619

1720
namespace IronyModManager.IO.Mods
1821
{
1922
/// <summary>
2023
/// Class Constants.
2124
/// </summary>
25+
[SuppressMessage("ReSharper", "InconsistentNaming")]
2226
internal class Constants
2327
{
2428
#region Fields

0 commit comments

Comments
 (0)