Skip to content

Commit 82456d2

Browse files
committed
rename to baseDirectory
1 parent f4505a5 commit 82456d2

5 files changed

Lines changed: 19 additions & 19 deletions

File tree

src/PetroglyphTools/PG.StarWarsGame.Engine.FileSystem/IO/FileExistStrategies/FileExistsStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal abstract class FileExistsStrategy(IFileSystem fileSystem) : IDisposable
88
{
99
protected readonly IFileSystem FileSystem = fileSystem;
1010

11-
public abstract bool FileExists(ReadOnlySpan<char> gameDirectory, ref ValueStringBuilder stringBuilder);
11+
public abstract bool FileExists(ReadOnlySpan<char> baseDirectory, ref ValueStringBuilder stringBuilder);
1212

1313
public virtual void Dispose() { }
1414
}

src/PetroglyphTools/PG.StarWarsGame.Engine.FileSystem/IO/FileExistStrategies/VirtualFileExistsStrategy.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ public override void Dispose()
2020
underlying.Dispose();
2121
}
2222

23-
public override bool FileExists(ReadOnlySpan<char> gameDirectory, ref ValueStringBuilder stringBuilder)
23+
public override bool FileExists(ReadOnlySpan<char> baseDirectory, ref ValueStringBuilder stringBuilder)
2424
{
2525
var filePath = stringBuilder.AsSpan();
2626

27-
if (!IsUnderGameDirectory(filePath, gameDirectory))
28-
return underlying.FileExists(gameDirectory, ref stringBuilder);
27+
if (!IsUnderBaseDirectory(filePath, baseDirectory))
28+
return underlying.FileExists(baseDirectory, ref stringBuilder);
2929

3030
var lastSep = filePath.LastIndexOf(Path.DirectorySeparatorChar);
3131
if (lastSep <= 0)
32-
return underlying.FileExists(gameDirectory, ref stringBuilder);
32+
return underlying.FileExists(baseDirectory, ref stringBuilder);
3333

3434
var dirSpan = filePath.Slice(0, lastSep);
3535
var fileName = filePath.Slice(lastSep + 1);
3636
if (fileName.IsEmpty)
37-
return underlying.FileExists(gameDirectory, ref stringBuilder);
37+
return underlying.FileExists(baseDirectory, ref stringBuilder);
3838

3939
var dirKey = dirSpan.ToString();
4040
if (!_store.TryGetValue(dirKey, out var virtualDir))
@@ -155,7 +155,7 @@ public override bool FileExists(ReadOnlySpan<char> gameDirectory, ref ValueStrin
155155
}
156156
}
157157

158-
private bool IsUnderGameDirectory(ReadOnlySpan<char> path, ReadOnlySpan<char> gameDirectory)
158+
private bool IsUnderBaseDirectory(ReadOnlySpan<char> path, ReadOnlySpan<char> gameDirectory)
159159
{
160160
return !gameDirectory.IsEmpty && FileSystem.Path.IsChildOf(gameDirectory, path);
161161
}

src/PetroglyphTools/PG.StarWarsGame.Engine.FileSystem/IO/FileExistStrategies/WindowsFileExistsStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace PG.StarWarsGame.Engine.IO.FileExistStrategies;
1414
/// </summary>
1515
internal sealed class WindowsFileExistsStrategy(IFileSystem fileSystem) : FileExistsStrategy(fileSystem)
1616
{
17-
public override bool FileExists(ReadOnlySpan<char> gameDirectory, ref ValueStringBuilder stringBuilder)
17+
public override bool FileExists(ReadOnlySpan<char> baseDirectory, ref ValueStringBuilder stringBuilder)
1818
{
1919
// We *could* also use the slightly faster GetFileAttributesA. However, CreateFileA and
2020
// GetFileAttributesA are implemented entirely independently in Windows; the game uses

src/PetroglyphTools/PG.StarWarsGame.Engine.FileSystem/IO/FileExistStrategies/WineFileExistsStrategy.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace PG.StarWarsGame.Engine.IO.FileExistStrategies;
1010

1111
internal sealed class WineFileExistsStrategy(IFileSystem fileSystem) : FileExistsStrategy(fileSystem)
1212
{
13-
public override bool FileExists(ReadOnlySpan<char> gameDirectory, ref ValueStringBuilder stringBuilder)
13+
public override bool FileExists(ReadOnlySpan<char> baseDirectory, ref ValueStringBuilder stringBuilder)
1414
{
1515
var pathString = stringBuilder.AsSpan().ToString();
1616
if (pathString.Length == 0)
@@ -35,17 +35,17 @@ public override bool FileExists(ReadOnlySpan<char> gameDirectory, ref ValueStrin
3535
return false;
3636
var parentDirInput = pathString.Substring(0, parentLen);
3737

38-
var resolvedParent = ResolveDirectory(parentDirInput, gameDirectory, rootLen);
38+
var resolvedParent = ResolveDirectory(parentDirInput, baseDirectory, rootLen);
3939
if (resolvedParent is null)
4040
return false;
4141

4242
return ResolveLeafIn(resolvedParent, fileName, ref stringBuilder);
4343
}
4444

45-
private string? ResolveDirectory(string dirInput, ReadOnlySpan<char> gameDirectory, int rootLen)
45+
private string? ResolveDirectory(string dirInput, ReadOnlySpan<char> baseDirectory, int rootLen)
4646
{
4747
var path = dirInput.AsSpan();
48-
var knownGoodPrefixLength = LowLevelPath.GetCommonDirectoryPrefixLength(path, gameDirectory);
48+
var knownGoodPrefixLength = LowLevelPath.GetCommonDirectoryPrefixLength(path, baseDirectory);
4949

5050
int prefixEnd;
5151
if (knownGoodPrefixLength > rootLen)

src/PetroglyphTools/PG.StarWarsGame.Engine.FileSystem/IO/PetroglyphFileSystem.Exist.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ namespace PG.StarWarsGame.Engine.IO;
99
public sealed partial class PetroglyphFileSystem
1010
{
1111
/// <summary>
12-
/// Resolves <paramref name="filePath"/> against <paramref name="gameDirectory"/>, normalizes
12+
/// Resolves <paramref name="filePath"/> against <paramref name="baseDirectory"/>, normalizes
1313
/// the path, and dispatches the lookup to the active <c>FileExists</c> strategy.
1414
/// </summary>
1515
/// <remarks>
1616
/// Fully-qualified inputs are taken as-is; relative inputs are joined to
17-
/// <paramref name="gameDirectory"/> first. The buffer is then unified to the host's native
17+
/// <paramref name="baseDirectory"/> first. The buffer is then unified to the host's native
1818
/// directory separator and dot segments (<c>.</c> and <c>..</c>) are resolved, after which
1919
/// the active strategy answers the lookup. On <see langword="true" /> the buffer contains
2020
/// the resolved on-disk path; on <see langword="false" /> the buffer content is unspecified.
@@ -24,28 +24,28 @@ public sealed partial class PetroglyphFileSystem
2424
/// A scratch buffer used to build and return the resolved path. The caller owns the buffer's
2525
/// lifetime and is responsible for disposing it.
2626
/// </param>
27-
/// <param name="gameDirectory">
28-
/// The game directory used as the base when <paramref name="filePath"/> is relative.
27+
/// <param name="baseDirectory">
28+
/// The base directory used as the base when <paramref name="filePath"/> is relative.
2929
/// </param>
3030
/// <returns>
3131
/// <see langword="true" /> if the file exists; otherwise, <see langword="false" />.
3232
/// </returns>
33-
internal bool FileExists(ReadOnlySpan<char> filePath, ref ValueStringBuilder stringBuilder, ReadOnlySpan<char> gameDirectory)
33+
internal bool FileExists(ReadOnlySpan<char> filePath, ref ValueStringBuilder stringBuilder, ReadOnlySpan<char> baseDirectory)
3434
{
3535
stringBuilder.Length = 0;
3636

3737
if (IsPathFullyQualified_Exists(filePath))
3838
stringBuilder.Append(filePath);
3939
else
40-
JoinPath(gameDirectory, filePath, ref stringBuilder);
40+
JoinPath(baseDirectory, filePath, ref stringBuilder);
4141

4242
// Canonicalize once for every strategy: unify separators to the host's native form, then
4343
// strip "." / ".." and trailing/duplicated separators. After this the buffer is ready to
4444
// hand directly to host FS APIs.
4545
NormalizePath(ref stringBuilder);
4646
NormalizeDotSegmentsInPlace(ref stringBuilder);
4747

48-
return _strategy.FileExists(gameDirectory, ref stringBuilder);
48+
return _strategy.FileExists(baseDirectory, ref stringBuilder);
4949
}
5050

5151
internal void NormalizeDotSegmentsInPlace(ref ValueStringBuilder sb)

0 commit comments

Comments
 (0)