8000 Assimilate PosixPathHelper into FilePath · dotjosh/libgit2sharp@db5d0d0 · GitHub
[go: up one dir, main page]

Skip to content

Commit db5d0d0

Browse files
dahlbyknulltoken
authored andcommitted
Assimilate PosixPathHelper into FilePath
1 parent 1d250da commit db5d0d0

File tree

3 files changed

+17
-45
lines changed

3 files changed

+17
-45
lines changed

LibGit2Sharp/Core/FilePath.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
namespace LibGit2Sharp.Core
1+
using System.IO;
2+
3+
namespace LibGit2Sharp.Core
24
{
35
internal class FilePath
46
{
7+
private const char posixDirectorySeparatorChar = '/';
8+
59
private readonly string native;
610
private readonly string posix;
711

812
private FilePath(string path)
913
{
10-
native = PosixPathHelper.ToNative(path);
11-
posix = PosixPathHelper.ToPosix(path);
14+
native = Replace(path, posixDirectorySeparatorChar, Path.DirectorySeparatorChar);
15+
posix = Replace(path, Path.DirectorySeparatorChar, posixDirectorySeparatorChar);
1216
}
1317

1418
public string Native
@@ -30,5 +34,15 @@ public static implicit operator FilePath(string path)
3034
{
3135
return path == null ? null : new FilePath(path);
3236
}
37+
38+
private static string Replace(string path, char oldChar, char newChar)
39+
{
40+
if (oldChar == newChar)
41+
{
42+
return path;
43+
}
44+
45+
return path == null ? null : path.Replace(oldChar, newChar);
46+
}
3347
}
3448
}

LibGit2Sharp/Core/PosixPathHelper.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@
7777
<Compile Include="Core\NativeMethods.cs" />
7878
<Compile Include="Core\SafeHandleExtensions.cs" />
7979
<Compile Include="Core\ObjectSafeWrapper.cs" />
80-
<Compile Include="Core\PosixPathHelper.cs">
81-
<SubType>Code</SubType>
82-
</Compile>
8380
<Compile Include="Core\RemoteSafeHandle.cs" />
8481
<Compile Include="Core\RevWalkerSafeHandle.cs">
8582
<SubType>Code</SubType>

0 commit comments

Comments
 (0)
0