mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
Implements directory browser dialog, part 4: back/forward/up navigation
This commit is contained in:
1 parent
c29d829c91
commit
beb66ac65e
7 files changed
+167
-30
No files matched your search
+3
-1
@@ -48,6 +48,7 @@ internal class DirectoryProviderService : IDirectoryProviderService
|
||||
return Errors.Permission.UnauthorizedAccess;
|
||||
return ErrorOrFactory.From(_fileSystem.Directory.GetDirectories(path.Path)
|
||||
.OrderBy(path => path)
|
||||
.Select(path => path.EndsWith(_fileSystem.Path.DirectorySeparatorChar) ? path : path + _fileSystem.Path.DirectorySeparatorChar)
|
||||
.Select(path => FileSystemPathId.Create(path))
|
||||
.Where(errorOrPathId => !errorOrPathId.IsError)
|
||||
.Select(errorOrPathId => errorOrPathId.Value)
|
||||
@@ -72,7 +73,8 @@ internal class DirectoryProviderService : IDirectoryProviderService
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a file name or an error.</returns>
|
||||
public ErrorOr<string> GetFileName(FileSystemPathId path)
|
||||
{
|
||||
return _fileSystem.Path.GetFileName(path.Path);
|
||||
string inputPath = path.Path.EndsWith(_fileSystem.Path.DirectorySeparatorChar) ? path.Path[..^1] : path.Path;
|
||||
return _fileSystem.Path.GetFileName(inputPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+2
-2
@@ -82,7 +82,7 @@ public class UnixPathStrategy : IUnixPathStrategy
|
||||
// if the name begins with a directory separator, remove it
|
||||
name = name.TrimStart(PathSeparator);
|
||||
// combine the two parts with the Unix directory separator character
|
||||
return FileSystemPathId.Create(subpath + PathSeparator + name);
|
||||
return FileSystemPathId.Create(subpath + PathSeparator + name + PathSeparator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -121,7 +121,7 @@ public class UnixPathStrategy : IUnixPathStrategy
|
||||
return Errors.FileManagement.InvalidPath;
|
||||
// trim trailing slash for consistent processing
|
||||
string tempPath = path.Path;
|
||||
if (tempPath.EndsWith("/"))
|
||||
if (tempPath.EndsWith('/'))
|
||||
tempPath = tempPath.TrimEnd(PathSeparator);
|
||||
// find the last occurrence of a slash
|
||||
var lastIndex = tempPath.LastIndexOf(PathSeparator);
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public class WindowsPathStrategy : IWindowsPathStrategy
|
||||
// if the name begins with a directory separator, remove it
|
||||
name = name.TrimStart(PathSeparator);
|
||||
// combine the two parts with the Windows directory separator character
|
||||
return FileSystemPathId.Create(subpath + PathSeparator + name);
|
||||
return FileSystemPathId.Create(subpath + PathSeparator + name + PathSeparator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user