mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
Fixes hidden detection for directory paths with trailing separators.
This commit is contained in:
1 parent
b46dce745b
commit
7f4c8cc8b9
2 files changed
+19
-1
No files matched your search
+3
-1
@@ -62,7 +62,9 @@ internal class DirectoryProviderService : IDirectoryProviderService
|
||||
// The hidden flag is metadata, so it follows the same read properties permission as the other metadata accessors.
|
||||
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false))
|
||||
return false;
|
||||
return (GetAttributes(path.Path) & FileAttributes.Hidden) == FileAttributes.Hidden;
|
||||
// Child directory paths carry a trailing separator, which prevents the Unix file system from reporting the dot-prefixed hidden entry.
|
||||
string directoryPath = path.Path.EndsWith(_fileSystem.Path.DirectorySeparatorChar) ? path.Path[..^1] : path.Path;
|
||||
return (GetAttributes(directoryPath) & FileAttributes.Hidden) == FileAttributes.Hidden;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+16
@@ -226,6 +226,22 @@ public class DirectoryProviderServiceTests
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsHidden_WhenDirectoryPathEndsWithSeparator_ShouldCheckAttributesWithoutSeparator()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create(_pathHidden2);
|
||||
_mockFileSystem.Path.DirectorySeparatorChar.Returns(_dirSeparator);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false).Returns(true);
|
||||
_mockFileSystem.File.GetAttributes(_pathHidden1).Returns(FileAttributes.Directory | FileAttributes.Hidden);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsHidden(path);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsHidden_WhenDirectoryDoesNotHaveHiddenAttribute_ShouldReturnFalse()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user