Skip to content

Commit 2fcb2b0

Browse files
committed
Upgrade paths library to 0.18.0
1 parent c6114fa commit 2fcb2b0

File tree

8 files changed

+20
-18
lines changed

8 files changed

+20
-18
lines changed

Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
55
<PackageVersion Include="FluentResults" Version="3.15.2" />
66
<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
7-
<PackageVersion Include="NexusMods.Paths" Version="0.10.0" />
8-
<PackageVersion Include="NexusMods.Paths.TestingHelpers" Version="0.10.0" />
7+
<PackageVersion Include="NexusMods.Paths" Version="0.18.0" />
8+
<PackageVersion Include="NexusMods.Paths.TestingHelpers" Version="0.18.0" />
99
<PackageVersion Include="NLog" Version="5.2.8" />
1010
<PackageVersion Include="NLog.Extensions.Logging" Version="5.3.8" />
1111
<PackageVersion Include="OneOf" Version="3.0.271" />

src/GameFinder.StoreHandlers.Steam/Models/AppManifest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ public sealed record AppManifest
220220

221221
#region Helpers
222222

223-
private static readonly RelativePath CommonDirectoryName = "common".ToRelativePath();
224-
private static readonly RelativePath ShaderCacheDirectoryName = "shadercache".ToRelativePath();
225-
private static readonly RelativePath WorkshopDirectoryName = "workshop".ToRelativePath();
226-
private static readonly RelativePath CompatabilityDataDirectoryName = "compatdata".ToRelativePath();
223+
private static readonly RelativePath CommonDirectoryName = "common";
224+
private static readonly RelativePath ShaderCacheDirectoryName = "shadercache";
225+
private static readonly RelativePath WorkshopDirectoryName = "workshop";
226+
private static readonly RelativePath CompatabilityDataDirectoryName = "compatdata";
227227

228228
/// <summary>
229229
/// Parses the file at <see cref="ManifestPath"/> again and returns a new

src/GameFinder.StoreHandlers.Steam/Models/LibraryFolder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public sealed record LibraryFolder
5757
/// </summary>
5858
public Size GetFreeSpaceEstimate() => TotalDiskSize - GetTotalSizeOfInstalledApps();
5959

60-
public static readonly RelativePath SteamAppsDirectoryName = "steamapps".ToRelativePath();
60+
public static readonly RelativePath SteamAppsDirectoryName = "steamapps";
6161

6262
/// <summary>
6363
/// Returns an enumerable for every <c>appmanifest_*.acf</c> file path in the current library.

src/GameFinder.StoreHandlers.Steam/Services/Parsers/AppManifestParser.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static Result<AppManifest> ParseManifestFile(AbsolutePath manifestPath)
102102
appState,
103103
"InstallScripts",
104104
key => DepotId.From(uint.Parse(key)),
105-
x => ParseRelativePath(x, manifestPath.FileSystem));
105+
x => ParseRelativePath(x));
106106

107107
var sharedDepotsResult = ParseBasicDictionary(
108108
appState,
@@ -206,16 +206,16 @@ private static Result<AbsolutePath> ParseInstallationDirectory(KVObject appState
206206
if (parseResult.IsFailed) return parseResult.ToResult();
207207

208208
var rawPath = parseResult.Value;
209-
var sanitizedPath = PathHelpers.Sanitize(rawPath, fileSystem.OS);
210-
var isRelative = PathHelpers.GetRootLength(sanitizedPath, fileSystem.OS) == -1;
209+
var sanitizedPath = PathHelpers.Sanitize(rawPath);
210+
var isRelative = !PathHelpers.IsRooted(sanitizedPath);
211211

212212
if (isRelative)
213213
{
214-
var relativePath = new RelativePath(sanitizedPath);
214+
var relativePath = RelativePath.CreateUnsafe(sanitizedPath);
215215
return Result.Ok(manifestPath.Parent.Combine("common").Combine(relativePath));
216216
}
217217

218-
var absolutePath = fileSystem.FromUnsanitizedFullPath(rawPath);
218+
var absolutePath = fileSystem.FromUnsanitizedFullPath(sanitizedPath);
219219
return absolutePath;
220220
}
221221

src/GameFinder.StoreHandlers.Steam/Services/Parsers/ParserHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ internal static bool ParseBool(KVValue value)
179179
internal static Size ParseSize(KVValue value) => Size.From(ParseUInt64(value));
180180

181181
[MethodImpl(MethodImplOptions.AggressiveInlining)]
182-
internal static RelativePath ParseRelativePath(KVValue value, IFileSystem fileSystem) => new(PathHelpers.Sanitize(ParseString(value), fileSystem.OS));
182+
internal static RelativePath ParseRelativePath(KVValue value) => ParseString(value);
183183

184184
[MethodImpl(MethodImplOptions.AggressiveInlining)]
185185
internal static AbsolutePath ParseAbsolutePath(KVValue value, IFileSystem fileSystem) => fileSystem.FromUnsanitizedFullPath(ParseString(value));

src/GameFinder.StoreHandlers.Steam/Services/SteamLocationFinder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ public static class SteamLocationFinder
2222
/// The name of the <c>config</c> directory.
2323
/// </summary>
2424
/// <seealso cref="GetLibraryFoldersFilePath"/>
25-
public static readonly RelativePath ConfigDirectoryName = "config".ToRelativePath();
25+
public static readonly RelativePath ConfigDirectoryName = "config";
2626

2727
/// <summary>
2828
/// The name of the <c>libraryfolders.vdf</c> file.
2929
/// </summary>
3030
/// <seealso cref="GetLibraryFoldersFilePath"/>
31-
public static readonly RelativePath LibraryFoldersFileName = "libraryfolders.vdf".ToRelativePath();
31+
public static readonly RelativePath LibraryFoldersFileName = "libraryfolders.vdf";
3232

3333
/// <summary>
3434
/// The name of the <c>userdata</c> directory.
3535
/// </summary>
3636
/// <seealso cref="GetUserDataDirectoryPath"/>
37-
public static readonly RelativePath UserDataDirectoryName = "userdata".ToRelativePath();
37+
public static readonly RelativePath UserDataDirectoryName = "userdata";
3838

3939
/// <summary>
4040
/// The registry key used to find Steam.

src/GameFinder.StoreHandlers.Xbox/XboxHandler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ internal static (List<AbsolutePath> paths, List<ErrorMessage> errors) GetAppFold
111111
var paths = new List<AbsolutePath>();
112112
var errors = new List<ErrorMessage>();
113113

114-
foreach (var rootDirectory in fileSystem.EnumerateRootDirectories())
114+
var rootDirectories = fileSystem.EnumerateRootDirectories().ToArray();
115+
116+
foreach (var rootDirectory in rootDirectories)
115117
{
116118
if (!fileSystem.DirectoryExists(rootDirectory)) continue;
117119

tests/GameFinder.StoreHandlers.Steam.Tests/ArrangeHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static AppManifest CreateAppManifest(AbsolutePath manifestPath)
9494
.ToDictionary(depot => depot.DepotId, depot => depot),
9595
InstallScripts = fixture
9696
.CreateMany<DepotId>()
97-
.Select(depotId => (depotId, fixture.Create<string>().ToRelativePath()))
97+
.Select(depotId => (depotId, RelativePath.FromUnsanitizedInput(fixture.Create<string>())))
9898
.ToDictionary(kv => kv.Item1, kv => kv.Item2),
9999
SharedDepots = fixture
100100
.CreateMany<DepotId>()

0 commit comments

Comments
 (0)