mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 10:11:10 +00:00
Adds hidden elements option to file system browser directories and paths
This commit is contained in:
1 parent
15a1881495
commit
b3db46ed5f
18 files changed
+217
-59
No files matched your search
+4
-3
@@ -1,4 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
@@ -30,8 +30,9 @@ public interface IPathService
|
||||
/// Checks if <paramref name="path"/> exists.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to be checked.</param>
|
||||
/// <param name="includeHiddenElements">Whether to include hidden file system elements or not.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="path"/> exists, <see langword="false"/> otherwise.</returns>
|
||||
bool Exists(string path);
|
||||
bool Exists(string path, bool includeHiddenElements = true);
|
||||
|
||||
/// <summary>
|
||||
/// Tries to combine <paramref name="path"/> with <paramref name="name"/>.
|
||||
@@ -68,4 +69,4 @@ public interface IPathService
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> containing the root of <paramref name="path"/>, or an error.</returns>
|
||||
ErrorOr<PathSegment> GetPathRoot(string path);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -53,13 +53,14 @@ public class PathService : IPathService
|
||||
/// Checks if <paramref name="path"/> exists.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to be checked.</param>
|
||||
/// <param name="includeHiddenElements">Whether to include hidden file system elements or not.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="path"/> exists, <see langword="false"/> otherwise.</returns>
|
||||
public bool Exists(string path)
|
||||
public bool Exists(string path, bool includeHiddenElements = true)
|
||||
{
|
||||
ErrorOr<FileSystemPathId> newPathResult = FileSystemPathId.Create(path);
|
||||
if (newPathResult.IsError)
|
||||
return false;
|
||||
return _platformContext.PathStrategy.Exists(newPathResult.Value);
|
||||
return _platformContext.PathStrategy.Exists(newPathResult.Value, includeHiddenElements);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+4
-3
@@ -1,4 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
@@ -27,8 +27,9 @@ public interface IPathStrategy
|
||||
/// Checks if <paramref name="path"/> exists.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to be checked.</param>
|
||||
/// <param name="includeHiddenElements">Whether to include hidden file system elements or not.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="path"/> exists, <see langword="false"/> otherwise.</returns>
|
||||
bool Exists(FileSystemPathId path);
|
||||
bool Exists(FileSystemPathId path, bool includeHiddenElements = true);
|
||||
|
||||
/// <summary>
|
||||
/// Tries to combine <paramref name="path"/> with <paramref name="name"/>.
|
||||
@@ -65,4 +66,4 @@ public interface IPathStrategy
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> containing the root of <paramref name="path"/>, or an error.</returns>
|
||||
ErrorOr<PathSegment> GetPathRoot(FileSystemPathId path);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+19
-2
@@ -4,6 +4,7 @@ using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -58,10 +59,26 @@ public class UnixPathStrategy : IUnixPathStrategy
|
||||
/// Checks if <paramref name="path"/> exists.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to be checked.</param>
|
||||
/// <param name="includeHiddenElements">Whether to include hidden file system elements or not.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="path"/> exists, <see langword="false"/> otherwise.</returns>
|
||||
public bool Exists(FileSystemPathId path)
|
||||
public bool Exists(FileSystemPathId path, bool includeHiddenElements = true)
|
||||
{
|
||||
return _fileSystem.Path.Exists(path.Path);
|
||||
if (!_fileSystem.Path.Exists(path.Path))
|
||||
return false;
|
||||
bool isHidden;
|
||||
if (_fileSystem.Directory.Exists(path.Path))
|
||||
{
|
||||
IDirectoryInfo dirInfo = _fileSystem.DirectoryInfo.New(path.Path);
|
||||
isHidden = (dirInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden;
|
||||
}
|
||||
else if (_fileSystem.File.Exists(path.Path))
|
||||
{
|
||||
IFileInfo fileInfo = _fileSystem.FileInfo.New(path.Path);
|
||||
isHidden = (fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden;
|
||||
}
|
||||
else // path exists but is neither a file nor a directory (drive, etc)
|
||||
return true;
|
||||
return includeHiddenElements || !isHidden;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+19
-2
@@ -4,6 +4,7 @@ using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -57,10 +58,26 @@ public class WindowsPathStrategy : IWindowsPathStrategy
|
||||
/// Checks if <paramref name="path"/> exists.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to be checked.</param>
|
||||
/// <param name="includeHiddenElements">Whether to include hidden file system elements or not.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="path"/> exists, <see langword="false"/> otherwise.</returns>
|
||||
public bool Exists(FileSystemPathId path)
|
||||
public bool Exists(FileSystemPathId path, bool includeHiddenElements = true)
|
||||
{
|
||||
return _fileSystem.Path.Exists(path.Path);
|
||||
if (!_fileSystem.Path.Exists(path.Path))
|
||||
return false;
|
||||
bool isHidden;
|
||||
if (_fileSystem.Directory.Exists(path.Path))
|
||||
{
|
||||
IDirectoryInfo dirInfo = _fileSystem.DirectoryInfo.New(path.Path);
|
||||
isHidden = (dirInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden;
|
||||
}
|
||||
else if (_fileSystem.File.Exists(path.Path))
|
||||
{
|
||||
IFileInfo fileInfo = _fileSystem.FileInfo.New(path.Path);
|
||||
isHidden = (fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden;
|
||||
}
|
||||
else // path exists but is neither a file nor a directory (drive, etc)
|
||||
return true;
|
||||
return includeHiddenElements || !isHidden;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user