mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 02:01:10 +00:00
Adds unlit color to hidden file system browser dialog elements.
This commit is contained in:
1 parent
3f7cc2c60f
commit
b46dce745b
58 files changed
+855
-360
No files matched your search
+4
-4
@@ -26,10 +26,10 @@ public static class DirectoryMapping
|
||||
Name = domainEntity.Name,
|
||||
Path = domainEntity.Id.Path,
|
||||
ItemType = domainEntity.Type,
|
||||
IsHidden = domainEntity.IsHidden,
|
||||
IsExpanded = false,
|
||||
ChildrenLoaded = false,
|
||||
Children = domainEntity.Items.Select(item => item.ToTreeNodeResponse())
|
||||
.ToList()
|
||||
Children = [.. domainEntity.Items.Select(item => item.ToTreeNodeResponse())]
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ public static class DirectoryMapping
|
||||
domainEntity.Name,
|
||||
domainEntity.DateCreated.Value,
|
||||
domainEntity.DateModified.Value,
|
||||
domainEntity.Items.Select(fileSystemItem => fileSystemItem.ToFileSystemItemDto())
|
||||
.ToList()
|
||||
[.. domainEntity.Items.Select(fileSystemItem => fileSystemItem.ToFileSystemItemDto())],
|
||||
domainEntity.IsHidden
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -28,7 +28,8 @@ public static class FileSystemItemMapping
|
||||
domainEntity.Id.Path,
|
||||
domainEntity.Name,
|
||||
DateTime.Now,
|
||||
DateTime.Now
|
||||
DateTime.Now,
|
||||
domainEntity.IsHidden
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ public static class FileMapping
|
||||
Name = domainEntity.Name,
|
||||
Path = domainEntity.Id.Path,
|
||||
ItemType = domainEntity.Type,
|
||||
IsHidden = domainEntity.IsHidden,
|
||||
IsExpanded = false,
|
||||
ChildrenLoaded = false
|
||||
};
|
||||
@@ -52,7 +53,8 @@ public static class FileMapping
|
||||
domainEntity.Name,
|
||||
domainEntity.DateCreated.HasValue ? domainEntity.DateCreated.Value : default,
|
||||
domainEntity.DateModified.HasValue ? domainEntity.DateModified.Value : default,
|
||||
domainEntity.Size
|
||||
domainEntity.Size,
|
||||
domainEntity.IsHidden
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,12 @@ namespace Lumina.Contracts.DTO.FileSystemManagement;
|
||||
/// <param name="Name">The name of the file system item.</param>
|
||||
/// <param name="DateCreated">The creation date of the file system item.</param>
|
||||
/// <param name="DateModified">The modification date of the file system item.</param>
|
||||
/// <param name="IsHidden">Whether the file system item is hidden.</param>
|
||||
[DebuggerDisplay("Name: {Name}")]
|
||||
public record FileSystemItemDto(
|
||||
string Path,
|
||||
string Name,
|
||||
DateTime DateCreated,
|
||||
DateTime DateModified
|
||||
DateTime DateModified,
|
||||
bool IsHidden
|
||||
);
|
||||
+5
@@ -27,6 +27,11 @@ public class FileSystemTreeNodeResponse
|
||||
/// </summary>
|
||||
public FileSystemItemType ItemType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the file or directory is hidden.
|
||||
/// </summary>
|
||||
public bool IsHidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the node is expanded.
|
||||
/// </summary>
|
||||
|
||||
+4
-2
@@ -15,11 +15,13 @@ namespace Lumina.Contracts.Responses.FileSystemManagement.Directories;
|
||||
/// <param name="DateCreated">The creation date of the directory.</param>
|
||||
/// <param name="DateModified">The modification date of the directory.</param>
|
||||
/// <param name="Items">The children items of the directory.</param>
|
||||
/// <param name="IsHidden">Whether the directory is hidden.</param>
|
||||
[DebuggerDisplay("Name: {Name} (Directory)")]
|
||||
public record DirectoryResponse(
|
||||
string Path,
|
||||
string Name,
|
||||
DateTime DateCreated,
|
||||
DateTime DateModified,
|
||||
List<FileSystemItemDto> Items
|
||||
) : FileSystemItemDto(Path, Name, DateCreated, DateModified);
|
||||
List<FileSystemItemDto> Items,
|
||||
bool IsHidden
|
||||
) : FileSystemItemDto(Path, Name, DateCreated, DateModified, IsHidden);
|
||||
@@ -14,11 +14,13 @@ namespace Lumina.Contracts.Responses.FileSystemManagement.Files;
|
||||
/// <param name="DateCreated">The creation date of the file.</param>
|
||||
/// <param name="DateModified">The modification date of the file.</param>
|
||||
/// <param name="Size">The size of the file, in bytes.</param>
|
||||
/// <param name="IsHidden">Whether the file is hidden.</param>
|
||||
[DebuggerDisplay("Name: {Name} (File, Size: {Size} bytes)")]
|
||||
public record FileResponse(
|
||||
string Path,
|
||||
string Name,
|
||||
DateTime DateCreated,
|
||||
DateTime DateModified,
|
||||
long Size
|
||||
) : FileSystemItemDto(Path, Name, DateCreated, DateModified);
|
||||
long Size,
|
||||
bool IsHidden
|
||||
) : FileSystemItemDto(Path, Name, DateCreated, DateModified, IsHidden);
|
||||
+14
-4
@@ -53,6 +53,7 @@ public sealed class Directory : FileSystemItem
|
||||
/// <param name="dateCreated">The date and time the directory was created. Can be optional if unknown.</param>
|
||||
/// <param name="dateModified">The date and time the directory was last modified. Can be optional if unknown.</param>
|
||||
/// <param name="status">The status of the file system item.</param>
|
||||
/// <param name="isHidden">Whether the directory is hidden.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Directory"/>, or an error message.
|
||||
/// </returns>
|
||||
@@ -61,9 +62,10 @@ public sealed class Directory : FileSystemItem
|
||||
string name,
|
||||
Optional<DateTime> dateCreated,
|
||||
Optional<DateTime> dateModified,
|
||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible)
|
||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible,
|
||||
bool isHidden = false)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
// TODO: enforce invariants.
|
||||
Result<FileSystemPathId> createPathResult = FileSystemPathId.Create(path);
|
||||
if (createPathResult.IsFailure)
|
||||
return createPathResult.Errors;
|
||||
@@ -75,6 +77,9 @@ public sealed class Directory : FileSystemItem
|
||||
Result<Updated> setStatusResult = newDirectory.SetStatus(status);
|
||||
if (setStatusResult.IsFailure)
|
||||
return setStatusResult.Errors;
|
||||
Result<Updated> setHiddenStateResult = newDirectory.SetHiddenState(isHidden);
|
||||
if (setHiddenStateResult.IsFailure)
|
||||
return setHiddenStateResult.Errors;
|
||||
return newDirectory;
|
||||
}
|
||||
|
||||
@@ -85,6 +90,7 @@ public sealed class Directory : FileSystemItem
|
||||
/// <param name="dateCreated">The date and time the directory was created. Can be optional if unknown.</param>
|
||||
/// <param name="dateModified">The date and time the directory was last modified. Can be optional if unknown.</param>
|
||||
/// <param name="status">The status of the file system item.</param>
|
||||
/// <param name="isHidden">Whether the directory is hidden.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Directory"/>, or an error message.
|
||||
/// </returns>
|
||||
@@ -93,9 +99,10 @@ public sealed class Directory : FileSystemItem
|
||||
string name,
|
||||
Optional<DateTime> dateCreated,
|
||||
Optional<DateTime> dateModified,
|
||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible)
|
||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible,
|
||||
bool isHidden = false)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
// TODO: enforce invariants.
|
||||
Directory newDirectory = new(
|
||||
id,
|
||||
name,
|
||||
@@ -104,6 +111,9 @@ public sealed class Directory : FileSystemItem
|
||||
Result<Updated> setStatusResult = newDirectory.SetStatus(status);
|
||||
if (setStatusResult.IsFailure)
|
||||
return setStatusResult.Errors;
|
||||
Result<Updated> setHiddenStateResult = newDirectory.SetHiddenState(isHidden);
|
||||
if (setHiddenStateResult.IsFailure)
|
||||
return setHiddenStateResult.Errors;
|
||||
return newDirectory;
|
||||
}
|
||||
|
||||
|
||||
+12
-2
@@ -54,6 +54,7 @@ public sealed class File : FileSystemItem
|
||||
/// <param name="dateModified">The date and time the file was last modified. Can be optional if unknown.</param>
|
||||
/// <param name="size">The size of the file in bytes.</param>
|
||||
/// <param name="status">The status of the file system item.</param>
|
||||
/// <param name="isHidden">Whether the file is hidden.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="File"/>, or an error message.
|
||||
/// </returns>
|
||||
@@ -63,7 +64,8 @@ public sealed class File : FileSystemItem
|
||||
Optional<DateTime> dateCreated,
|
||||
Optional<DateTime> dateModified,
|
||||
long size,
|
||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible)
|
||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible,
|
||||
bool isHidden = false)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
Result<FileSystemPathId> createPathResult = FileSystemPathId.Create(path);
|
||||
@@ -78,6 +80,9 @@ public sealed class File : FileSystemItem
|
||||
Result<Updated> setStatusResult = newFile.SetStatus(status);
|
||||
if (setStatusResult.IsFailure)
|
||||
return setStatusResult.Errors;
|
||||
Result<Updated> setHiddenStateResult = newFile.SetHiddenState(isHidden);
|
||||
if (setHiddenStateResult.IsFailure)
|
||||
return setHiddenStateResult.Errors;
|
||||
return newFile;
|
||||
}
|
||||
|
||||
@@ -90,6 +95,7 @@ public sealed class File : FileSystemItem
|
||||
/// <param name="dateModified">The date and time the file was last modified. Can be optional if unknown.</param>
|
||||
/// <param name="size">The size of the file in bytes.</param>
|
||||
/// <param name="status">The status of the file system item.</param>
|
||||
/// <param name="isHidden">Whether the file is hidden.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="File"/>, or an error message.
|
||||
/// </returns>
|
||||
@@ -99,7 +105,8 @@ public sealed class File : FileSystemItem
|
||||
Optional<DateTime> dateCreated,
|
||||
Optional<DateTime> dateModified,
|
||||
long size,
|
||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible)
|
||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible,
|
||||
bool isHidden = false)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
File newFile = new(
|
||||
@@ -111,6 +118,9 @@ public sealed class File : FileSystemItem
|
||||
Result<Updated> setStatusResult = newFile.SetStatus(status);
|
||||
if (setStatusResult.IsFailure)
|
||||
return setStatusResult.Errors;
|
||||
Result<Updated> setHiddenStateResult = newFile.SetHiddenState(isHidden);
|
||||
if (setHiddenStateResult.IsFailure)
|
||||
return setHiddenStateResult.Errors;
|
||||
return newFile;
|
||||
}
|
||||
|
||||
|
||||
+20
-5
@@ -1,10 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
@@ -36,6 +35,11 @@ public abstract class FileSystemItem : AggregateRoot<FileSystemPathId>
|
||||
/// </summary>
|
||||
public FileSystemItemType Type { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the file system item is hidden.
|
||||
/// </summary>
|
||||
public bool IsHidden { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileSystemItem"/> class.
|
||||
/// </summary>
|
||||
@@ -49,7 +53,7 @@ public abstract class FileSystemItem : AggregateRoot<FileSystemPathId>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the status of the filesystem item.
|
||||
/// Sets the status of the file system item.
|
||||
/// </summary>
|
||||
/// <param name="status">The status to be set.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
@@ -60,7 +64,18 @@ public abstract class FileSystemItem : AggregateRoot<FileSystemPathId>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the parent of the filesystem item.
|
||||
/// Sets the hidden state of the file system item.
|
||||
/// </summary>
|
||||
/// <param name="isHidden">Whether the file system item is hidden.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public Result<Updated> SetHiddenState(bool isHidden)
|
||||
{
|
||||
IsHidden = isHidden;
|
||||
return Result.Updated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the parent of the file system item.
|
||||
/// </summary>
|
||||
/// <param name="parent">The file system item to be set as parent.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
|
||||
+15
-4
@@ -1,10 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -54,6 +52,19 @@ internal class DirectoryProviderService : IDirectoryProviderService
|
||||
.AsEnumerable());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the directory at the specified path is hidden.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the directory to check.</param>
|
||||
/// <returns><see langword="true"/> when the directory is hidden, otherwise <see langword="false"/>, including when its attributes cannot be read.</returns>
|
||||
public bool IsHidden(FileSystemPathId path)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the attributes of a file system item identified by <paramref name="path"/>.
|
||||
/// </summary>
|
||||
|
||||
+13
-10
@@ -1,12 +1,11 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
@@ -76,13 +75,15 @@ public class DirectoryService : IDirectoryService
|
||||
Result<string> dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(subPath);
|
||||
Result<Optional<DateTime>> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(subPath);
|
||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(subPath);
|
||||
// When hidden elements are excluded, the provider already filtered them out, so only an inclusive listing needs the attribute.
|
||||
bool isHidden = shouldIncludeHiddenElements && _environmentContext.DirectoryProviderService.IsHidden(subPath);
|
||||
|
||||
// If any error occurred, mark the directory as inaccessible.
|
||||
if (dirNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure)
|
||||
{
|
||||
Result<Directory> errorDirResult = Directory.Create(subPath, !dirNameResult.IsFailure ? dirNameResult.Value : null!,
|
||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None());
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), isHidden: isHidden);
|
||||
if (errorDirResult.IsFailure)
|
||||
return errorDirResult.Errors;
|
||||
Result<Updated> setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
@@ -92,7 +93,7 @@ public class DirectoryService : IDirectoryService
|
||||
}
|
||||
else
|
||||
{
|
||||
Result<Directory> subDirectoryResult = Directory.Create(subPath, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value);
|
||||
Result<Directory> subDirectoryResult = Directory.Create(subPath, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, isHidden: isHidden);
|
||||
if (subDirectoryResult.IsFailure)
|
||||
return subDirectoryResult.Errors;
|
||||
result.Add(subDirectoryResult.Value);
|
||||
@@ -141,12 +142,13 @@ public class DirectoryService : IDirectoryService
|
||||
Result<string> dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(newDirectoryPathResult.Value);
|
||||
Result<Optional<DateTime>> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(newDirectoryPathResult.Value);
|
||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(newDirectoryPathResult.Value);
|
||||
bool isHidden = _environmentContext.DirectoryProviderService.IsHidden(newDirectoryPathResult.Value);
|
||||
// If any error occurred, mark the directory as inaccessible.
|
||||
if (dirNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure)
|
||||
{
|
||||
Result<Directory> errorDirResult = Directory.Create(newDirectoryPathResult.Value, !dirNameResult.IsFailure ? dirNameResult.Value : null!,
|
||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None());
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), isHidden: isHidden);
|
||||
if (errorDirResult.IsFailure)
|
||||
return errorDirResult.Errors;
|
||||
Result<Updated> setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
@@ -155,7 +157,7 @@ public class DirectoryService : IDirectoryService
|
||||
return errorDirResult;
|
||||
}
|
||||
else
|
||||
return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value);
|
||||
return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, isHidden: isHidden);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,12 +293,13 @@ public class DirectoryService : IDirectoryService
|
||||
Result<string> dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(newDirectoryPathResult.Value);
|
||||
Result<Optional<DateTime>> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(newDirectoryPathResult.Value);
|
||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(newDirectoryPathResult.Value);
|
||||
bool isHidden = _environmentContext.DirectoryProviderService.IsHidden(newDirectoryPathResult.Value);
|
||||
// If any error occurred, mark the directory as inaccessible.
|
||||
if (dirNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure)
|
||||
{
|
||||
Result<Directory> errorDirResult = Directory.Create(newDirectoryPathResult.Value, !dirNameResult.IsFailure ? dirNameResult.Value : null!,
|
||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None());
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), isHidden: isHidden);
|
||||
if (errorDirResult.IsFailure)
|
||||
return errorDirResult.Errors;
|
||||
Result<Updated> setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
@@ -305,7 +308,7 @@ public class DirectoryService : IDirectoryService
|
||||
return errorDirResult;
|
||||
}
|
||||
else
|
||||
return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value);
|
||||
return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, isHidden: isHidden);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-3
@@ -1,9 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -52,6 +51,19 @@ internal class FileProviderService : IFileProviderService
|
||||
.AsEnumerable());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the file at the specified path is hidden.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the file to check.</param>
|
||||
/// <returns><see langword="true"/> when the file is hidden, otherwise <see langword="false"/>, including when its attributes cannot be read.</returns>
|
||||
public bool IsHidden(FileSystemPathId path)
|
||||
{
|
||||
// The hidden flag is metadata, so it follows the same read properties permission as the other metadata accessors.
|
||||
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties))
|
||||
return false;
|
||||
return (GetAttributes(path.Path) & FileAttributes.Hidden) == FileAttributes.Hidden;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the attributes of a file system item identified by <paramref name="path"/>.
|
||||
/// </summary>
|
||||
|
||||
+13
-8
@@ -78,12 +78,14 @@ public class FileService : IFileService
|
||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(filePath);
|
||||
Result<long?> sizeResult = _environmentContext.FileProviderService.GetSize(filePath);
|
||||
long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0;
|
||||
// When hidden elements are excluded, the provider already filtered them out, so only an inclusive listing needs the attribute.
|
||||
bool isHidden = shouldIncludeHiddenElements && _environmentContext.FileProviderService.IsHidden(filePath);
|
||||
// If any of the details returned an error, set the inaccessible status.
|
||||
if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure)
|
||||
{
|
||||
Result<File> errorFileResult = File.Create(filePath, !fileNameResult.IsFailure ? fileNameResult.Value : null!,
|
||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size);
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size, isHidden: isHidden);
|
||||
if (errorFileResult.IsFailure)
|
||||
return errorFileResult.Errors;
|
||||
Result<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
@@ -93,7 +95,7 @@ public class FileService : IFileService
|
||||
}
|
||||
else
|
||||
{
|
||||
Result<File> fileResult = File.Create(filePath, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
||||
Result<File> fileResult = File.Create(filePath, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size, isHidden: isHidden);
|
||||
if (fileResult.IsFailure)
|
||||
return fileResult.Errors;
|
||||
result.Add(fileResult.Value);
|
||||
@@ -150,12 +152,13 @@ public class FileService : IFileService
|
||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(copyFileResult.Value);
|
||||
Result<long?> sizeResult = _environmentContext.FileProviderService.GetSize(copyFileResult.Value);
|
||||
long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0;
|
||||
bool isHidden = _environmentContext.FileProviderService.IsHidden(copyFileResult.Value);
|
||||
// If any of the details returned an error, set the inaccessible status.
|
||||
if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure)
|
||||
{
|
||||
Result<File> errorFileResult = File.Create(copyFileResult.Value, !fileNameResult.IsFailure ? fileNameResult.Value : null!,
|
||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size);
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size, isHidden: isHidden);
|
||||
if (errorFileResult.IsFailure)
|
||||
return errorFileResult.Errors;
|
||||
Result<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
@@ -164,7 +167,7 @@ public class FileService : IFileService
|
||||
return errorFileResult;
|
||||
}
|
||||
else
|
||||
return File.Create(copyFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
||||
return File.Create(copyFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size, isHidden: isHidden);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,12 +219,13 @@ public class FileService : IFileService
|
||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(moveFileResult.Value);
|
||||
Result<long?> sizeResult = _environmentContext.FileProviderService.GetSize(moveFileResult.Value);
|
||||
long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0;
|
||||
bool isHidden = _environmentContext.FileProviderService.IsHidden(moveFileResult.Value);
|
||||
// If any of the details returned an error, set the inaccessible status.
|
||||
if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure)
|
||||
{
|
||||
Result<File> errorFileResult = File.Create(moveFileResult.Value, !fileNameResult.IsFailure ? fileNameResult.Value : null!,
|
||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size);
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size, isHidden: isHidden);
|
||||
if (errorFileResult.IsFailure)
|
||||
return errorFileResult.Errors;
|
||||
Result<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
@@ -230,7 +234,7 @@ public class FileService : IFileService
|
||||
return errorFileResult;
|
||||
}
|
||||
else
|
||||
return File.Create(moveFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
||||
return File.Create(moveFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size, isHidden: isHidden);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,12 +280,13 @@ public class FileService : IFileService
|
||||
Result<Optional<DateTime>> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(newFilePathResult.Value);
|
||||
Result<long?> sizeResult = _environmentContext.FileProviderService.GetSize(newFilePathResult.Value);
|
||||
long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0;
|
||||
bool isHidden = _environmentContext.FileProviderService.IsHidden(newFilePathResult.Value);
|
||||
// If any of the details returned an error, set the inaccessible status.
|
||||
if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure)
|
||||
{
|
||||
Result<File> errorFileResult = File.Create(newFilePathResult.Value, !fileNameResult.IsFailure ? fileNameResult.Value : null!,
|
||||
!dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size);
|
||||
!dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional<DateTime>.None(), size, isHidden: isHidden);
|
||||
if (errorFileResult.IsFailure)
|
||||
return errorFileResult.Errors;
|
||||
Result<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
@@ -290,7 +295,7 @@ public class FileService : IFileService
|
||||
return errorFileResult;
|
||||
}
|
||||
else
|
||||
return File.Create(newFilePathResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
||||
return File.Create(newFilePathResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size, isHidden: isHidden);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -21,6 +21,13 @@ public interface IDirectoryProviderService
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of directory paths or an error.</returns>
|
||||
Result<IEnumerable<FileSystemPathId>> GetSubdirectoryPaths(FileSystemPathId path, bool shouldIncludeHiddenElements);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the directory at the specified path is hidden.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the directory to check.</param>
|
||||
/// <returns><see langword="true"/> when the directory is hidden, otherwise <see langword="false"/>, including when its attributes cannot be read.</returns>
|
||||
bool IsHidden(FileSystemPathId path);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a directory with the specified path exists.
|
||||
/// </summary>
|
||||
|
||||
+7
@@ -21,6 +21,13 @@ public interface IFileProviderService
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of file paths, or an error.</returns>
|
||||
Result<IEnumerable<FileSystemPathId>> GetFilePaths(FileSystemPathId path, bool shouldIncludeHiddenElements);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the file at the specified path is hidden.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the file to check.</param>
|
||||
/// <returns><see langword="true"/> when the file is hidden, otherwise <see langword="false"/>, including when its attributes cannot be read.</returns>
|
||||
bool IsHidden(FileSystemPathId path);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the contents of a file at the specified path.
|
||||
/// </summary>
|
||||
|
||||
+2
-2
@@ -37,8 +37,8 @@ public class GetDirectoriesEndpointSummary : Summary<GetDirectoriesEndpoint, Get
|
||||
|
||||
Response(200, "The list of directories for the specified path is returned.",
|
||||
example: new DirectoryResponse[] {
|
||||
new(Path: "/media/movies/The Matrix (1999)/", Name: "The Matrix", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Items: []),
|
||||
new(Path: "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/", Name: "The Lord of the Rings - The Fellowship of the Ring (2001)", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Items: [])
|
||||
new(Path: "/media/movies/The Matrix (1999)/", Name: "The Matrix", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Items: [], IsHidden: false),
|
||||
new(Path: "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/", Name: "The Lord of the Rings - The Fellowship of the Ring (2001)", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Items: [], IsHidden: false)
|
||||
});
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ public class GetDrivesEndpointSummary : Summary<GetDrivesEndpoint, EmptyRequest>
|
||||
|
||||
Response(200, "The list of file system drives is returned.",
|
||||
example: new FileSystemTreeNodeResponse[] {
|
||||
new() { Path = "C:\\", Name = "C:\\", ItemType = FileSystemItemType.Root, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
||||
new() { Path = "D:\\", Name = "D:\\", ItemType = FileSystemItemType.Root, IsExpanded = false, ChildrenLoaded = false, Children = [] }
|
||||
new() { Path = "C:\\", Name = "C:\\", ItemType = FileSystemItemType.Root, IsHidden = false, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
||||
new() { Path = "D:\\", Name = "D:\\", ItemType = FileSystemItemType.Root, IsHidden = false, IsExpanded = false, ChildrenLoaded = false, Children = [] }
|
||||
});
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Files;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -38,8 +37,8 @@ public class GetFilesEndpointSummary : Summary<GetFilesEndpoint, GetFilesRequest
|
||||
|
||||
Response(200, "The list of files is returned.",
|
||||
example: new FileResponse[] {
|
||||
new(Path: "/media/movies/The Matrix (1999)/The Matrix.mkv", Name: "The Matrix.mkv", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Size: 754045401),
|
||||
new(Path: "/media/movies/The Matrix (1999)/The Matrix.en.srt", Name: "The Matrix.en.srt", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Size: 6897)
|
||||
new(Path: "/media/movies/The Matrix (1999)/The Matrix.mkv", Name: "The Matrix.mkv", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Size: 754045401, IsHidden: false),
|
||||
new(Path: "/media/movies/The Matrix (1999)/The Matrix.en.srt", Name: "The Matrix.en.srt", DateCreated: DateTime.UtcNow, DateModified: DateTime.UtcNow.AddMinutes(-10), Size: 6897, IsHidden: false)
|
||||
});
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
|
||||
+3
-3
@@ -37,9 +37,9 @@ public class GetTreeFilesEndpointSummary : Summary<GetTreeFilesEndpoint, GetTree
|
||||
|
||||
Response(200, "The tree structure of files is returned.",
|
||||
example: new FileSystemTreeNodeResponse[] {
|
||||
new() { Path = "/media/movies/The Matrix (1999)/The Matrix.mkv", Name = "The Matrix.mkv", ItemType = FileSystemItemType.File, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
||||
new() { Path = "/media/movies/The Matrix (1999)/The Matrix.en.srt", Name = "The Matrix.en.srt", ItemType = FileSystemItemType.File, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
||||
new() { Path = "/media/movies/The Matrix (1999)/poster.jpg", Name = "poster.jpg", ItemType = FileSystemItemType.File, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
||||
new() { Path = "/media/movies/The Matrix (1999)/The Matrix.mkv", Name = "The Matrix.mkv", ItemType = FileSystemItemType.File, IsHidden = false, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
||||
new() { Path = "/media/movies/The Matrix (1999)/The Matrix.en.srt", Name = "The Matrix.en.srt", ItemType = FileSystemItemType.File, IsHidden = false, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
||||
new() { Path = "/media/movies/The Matrix (1999)/poster.jpg", Name = "poster.jpg", ItemType = FileSystemItemType.File, IsHidden = false, IsExpanded = false, ChildrenLoaded = false, Children = [] },
|
||||
});
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -30,4 +30,9 @@ public abstract class FileSystemItemDto
|
||||
/// Gets or sets the modification date of the file system item.
|
||||
/// </summary>
|
||||
public DateTime DateModified { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the file system item is hidden.
|
||||
/// </summary>
|
||||
public bool IsHidden { get; set; }
|
||||
}
|
||||
@@ -27,6 +27,11 @@ public class FileSystemTreeNodeDto
|
||||
/// </summary>
|
||||
public FileSystemItemType ItemType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the file or directory is hidden.
|
||||
/// </summary>
|
||||
public bool IsHidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the node is expanded.
|
||||
/// </summary>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user