Skip to content

Commit

Permalink
Simplify target paths by leveraging newest dir behavior in dotnet-file
Browse files Browse the repository at this point in the history
The trailing '/' on the URL now means "construct target path from here on", so we don't get duplicated directory structure.
  • Loading branch information
kzu committed Oct 21, 2024
1 parent 1b604d1 commit f928d46
Show file tree
Hide file tree
Showing 70 changed files with 131 additions and 125 deletions.
190 changes: 94 additions & 96 deletions .netconfig

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public IList<string> GetAccounts(string service)
if (typeId == CFArrayGetTypeID())
{
int len = (int)CFArrayGetCount(resultPtr);
// NOTE: removed len from HashSet ctor since it's not supported in NS2.0
var accounts = new HashSet<string>();
for (int i = 0; i < len; i++)
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
35 changes: 35 additions & 0 deletions src/Core/Interop/Posix/PosixFileSystem.Custom.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace GitCredentialManager.Interop.Posix;

// NOTE: delete the existing TryResolve* in the sync'ed file, make the class partial,
// and this implementation will fix the build when upgrading. Note that links will
// actually not be supported.
partial class PosixFileSystem
{
#if NETSTANDARD2_0
private static bool TryResolveFileLink(string path, out string target)
{
target = null;
return false;
}

private static bool TryResolveDirectoryLink(string path, out string target)
{
target = null;
return false;
}
#elif !NETFRAMEWORK
private static bool TryResolveFileLink(string path, out string target)
{
FileSystemInfo fsi = Polyfills.FileResolveLinkTarget(path, true);
target = fsi?.FullName;
return fsi != null;
}

private static bool TryResolveDirectoryLink(string path, out string target)
{
FileSystemInfo fsi = Polyfills.DirectoryResolveLinkTarget(path, true);
target = fsi?.FullName;
return fsi != null;
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace GitCredentialManager.Interop.Posix
{
public abstract class PosixFileSystem : FileSystem
public abstract partial class PosixFileSystem : FileSystem
{
/// <summary>
/// Recursively resolve a symbolic link.
Expand Down Expand Up @@ -56,33 +56,5 @@ protected internal static string ResolveSymbolicLinks(string path)
return Path.Combine("/", partialPath);
#endif
}

#if NETSTANDARD2_0
private static bool TryResolveFileLink(string path, out string target)
{
target = null;
return false;
}

private static bool TryResolveDirectoryLink(string path, out string target)
{
target = null;
return false;
}
#elif !NETFRAMEWORK
private static bool TryResolveFileLink(string path, out string target)
{
FileSystemInfo fsi = File.ResolveLinkTarget(path, true);
target = fsi?.FullName;
return fsi != null;
}

private static bool TryResolveDirectoryLink(string path, out string target)
{
FileSystemInfo fsi = Directory.ResolveLinkTarget(path, true);
target = fsi?.FullName;
return fsi != null;
}
#endif
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f928d46

Please sign in to comment.