diff --git a/src/Lumina.Application/Properties/AssemblyInfo.cs b/src/Lumina.Application/Properties/AssemblyInfo.cs
index 543b6e1e..8dfab440 100644
--- a/src/Lumina.Application/Properties/AssemblyInfo.cs
+++ b/src/Lumina.Application/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-using System.Reflection;
+using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -16,4 +16,5 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("EACBCFD4-0FDD-4819-B2F2-056C812B2A3F")]
-[assembly: InternalsVisibleTo("Lumina.Application.UnitTests")]
\ No newline at end of file
+[assembly: InternalsVisibleTo("Lumina.Application.UnitTests")]
+[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
diff --git a/src/Lumina.Contracts/Enums/PhotoLibrary/ImageType.cs b/src/Lumina.Contracts/Enums/PhotoLibrary/ImageType.cs
index 22d4c4e0..6ba8a7e9 100644
--- a/src/Lumina.Contracts/Enums/PhotoLibrary/ImageType.cs
+++ b/src/Lumina.Contracts/Enums/PhotoLibrary/ImageType.cs
@@ -1,24 +1,87 @@
-namespace Lumina.Contracts.Enums.PhotoLibrary;
+namespace Lumina.Contracts.Enums.PhotoLibrary;
///
/// Enumeration for known image types.
///
public enum ImageType
{
+ ///
+ /// No image type specified.
+ ///
None,
+
+ ///
+ /// Bitmap image format.
+ ///
BMP,
+
+ ///
+ /// Graphics Interchange Format (GIF).
+ ///
GIF,
+
+ ///
+ /// Portable Network Graphics (PNG) format.
+ ///
PNG,
+
+ ///
+ /// Tagged Image File Format (TIFF).
+ ///
TIFF,
+
+ ///
+ /// Joint Photographic Experts Group (JPEG) format.
+ ///
JPEG,
+
+ ///
+ /// Canon-specific JPEG format.
+ ///
JPEG_CANON,
+
+ ///
+ /// Unknown JPEG format.
+ ///
JPEG_UNKNOWN,
+
+ ///
+ /// Macintosh Picture (PICT) format.
+ ///
PICT,
+
+ ///
+ /// Icon (ICO) format.
+ ///
ICO,
+
+ ///
+ /// Photoshop Document (PSD) format.
+ ///
PSD,
+
+ ///
+ /// JPEG 2000 format.
+ ///
JPEG2000,
+
+ ///
+ /// AV1 Image File Format (AVIF).
+ ///
AVIF,
+
+ ///
+ /// Web Picture (WEBP) format.
+ ///
WEBP,
+
+ ///
+ /// Truevision TGA format.
+ ///
TGA,
- SVG,
-}
\ No newline at end of file
+
+ ///
+ /// Scalable Vector Graphics (SVG) format.
+ ///
+ SVG
+}
diff --git a/src/Lumina.DataAccess/Properties/AssemblyInfo.cs b/src/Lumina.DataAccess/Properties/AssemblyInfo.cs
index d1a3fa3c..d518cb91 100644
--- a/src/Lumina.DataAccess/Properties/AssemblyInfo.cs
+++ b/src/Lumina.DataAccess/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-using System.Reflection;
+using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -16,4 +16,5 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("F50EC9A6-696C-461E-B2F1-95B70BFE3DBF")]
-[assembly: InternalsVisibleTo("Lumina.DataAccess.UnitTests")]
\ No newline at end of file
+[assembly: InternalsVisibleTo("Lumina.DataAccess.UnitTests")]
+[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
diff --git a/src/Lumina.Domain/Common/DependencyInjection/DomainLayerServices.cs b/src/Lumina.Domain/Common/DependencyInjection/DomainLayerServices.cs
index 326cf2cf..d662bad7 100644
--- a/src/Lumina.Domain/Common/DependencyInjection/DomainLayerServices.cs
+++ b/src/Lumina.Domain/Common/DependencyInjection/DomainLayerServices.cs
@@ -1,10 +1,12 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
using Microsoft.Extensions.DependencyInjection;
+using System;
using System.IO.Abstractions;
+using System.Runtime.InteropServices;
#endregion
namespace Lumina.Domain.Common.DependencyInjection;
@@ -38,8 +40,9 @@ public static class DomainLayerServices
services.AddScoped();
services.AddScoped();
services.AddScoped();
+ services.AddScoped();
services.AddSingleton();
return services;
}
#endregion
-}
\ No newline at end of file
+}
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/DirectoryService.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/DirectoryService.cs
index 5582c26b..8866b082 100644
--- a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/DirectoryService.cs
+++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/DirectoryService.cs
@@ -143,9 +143,9 @@ public class DirectoryService : IDirectoryService
ErrorOr newDirectoryPathResult = _environmentContext.DirectoryProviderService.CreateDirectory(path, name);
if (newDirectoryPathResult.IsError)
return newDirectoryPathResult.Errors;
- ErrorOr dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(path);
- ErrorOr> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(path);
- ErrorOr> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(path);
+ ErrorOr dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(newDirectoryPathResult.Value);
+ ErrorOr> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(newDirectoryPathResult.Value);
+ ErrorOr> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(newDirectoryPathResult.Value);
// if any error occurred, mark directory as Inaccessible
if (dirNameResult.IsError || dateModifiedResult.IsError || dateCreatedResult.IsError)
{
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileProviderService.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileProviderService.cs
index 8978437b..0e09a06c 100644
--- a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileProviderService.cs
+++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileProviderService.cs
@@ -159,18 +159,17 @@ internal class FileProviderService : IFileProviderService
// check if the source file exists
if (!_fileSystem.File.Exists(sourceFilePath.Path))
return Errors.FileManagement.FileNotFound;
- string destinationFilePath;
string fileName = _fileSystem.Path.GetFileName(sourceFilePath.Path);
+ string destinationFilePath = _fileSystem.Path.Combine(destinationDirectoryPath.Path, fileName);
// when copying a file to the same location, just copy it with a new name
if (_fileSystem.Path.GetDirectoryName(sourceFilePath.Path) == destinationDirectoryPath.Path)
- destinationFilePath = CreateUniqueFilePath(destinationDirectoryPath.Path);
+ destinationFilePath = CreateUniqueFilePath(destinationFilePath);
else
{
// check if there is already a file with the same name as the copied file, in the destination directory
- if (_fileSystem.File.Exists(destinationDirectoryPath.Path + fileName))
+ if (_fileSystem.File.Exists(destinationFilePath))
if (!overrideExisting)
return Errors.FileManagement.FileAlreadyExists;
- destinationFilePath = destinationDirectoryPath.Path + fileName;
}
try
{
@@ -218,7 +217,7 @@ internal class FileProviderService : IFileProviderService
try
{
string fileName = _fileSystem.Path.GetFileName(sourceFilePath.Path);
- string destinationFilePath = destinationDirectoryPath.Path + fileName;
+ string destinationFilePath = _fileSystem.Path.Combine(destinationDirectoryPath.Path, fileName);
// if the destination file does not exist, perform a simple move
if (!_fileSystem.File.Exists(destinationFilePath))
_fileSystem.File.Move(sourceFilePath.Path, destinationFilePath);
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileService.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileService.cs
index 82b66d63..33be3f02 100644
--- a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileService.cs
+++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileService.cs
@@ -117,6 +117,8 @@ public class FileService : IFileService
/// An containing either a copied file, or an error.
public ErrorOr CopyFile(string sourceFilePath, string destinationDirectoryPath, bool? overrideExisting)
{
+ if (string.IsNullOrWhiteSpace(destinationDirectoryPath))
+ return Errors.FileManagement.InvalidPath;
// make sure the paths are in the expected format
if (!destinationDirectoryPath.EndsWith(_platformContext.PathStrategy.PathSeparator))
destinationDirectoryPath += _platformContext.PathStrategy.PathSeparator;
@@ -181,6 +183,8 @@ public class FileService : IFileService
/// An containing either a moved file, or an error.
public ErrorOr MoveFile(string sourceFilePath, string destinationDirectoryPath, bool? overrideExisting)
{
+ if (string.IsNullOrWhiteSpace(destinationDirectoryPath))
+ return Errors.FileManagement.InvalidPath;
// make sure the paths are in the expected format
if (!destinationDirectoryPath.EndsWith(_platformContext.PathStrategy.PathSeparator))
destinationDirectoryPath += _platformContext.PathStrategy.PathSeparator;
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileSystemPermissionsService.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileSystemPermissionsService.cs
index 820b7943..96d64258 100644
--- a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileSystemPermissionsService.cs
+++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileSystemPermissionsService.cs
@@ -1,4 +1,4 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
@@ -16,7 +16,7 @@ namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.S
///
/// Service for file system permissions.
///
-internal class FileSystemPermissionsService : IFileSystemPermissionsService
+internal class FileSystemPermissionsService : IFileSystemPermissionsService // TODO: refactor towards abstractions that could allow testing
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IPlatformContextManager _platformContextManager;
@@ -210,4 +210,4 @@ internal class FileSystemPermissionsService : IFileSystemPermissionsService
return allowAccess;
}
#endregion
-}
\ No newline at end of file
+}
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileTypeService.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileTypeService.cs
index 27142814..a05f8b57 100644
--- a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileTypeService.cs
+++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/FileTypeService.cs
@@ -23,7 +23,7 @@ public class FileTypeService : IFileTypeService
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFileSystem _fileSystem;
private readonly IFileSystemPermissionsService _fileSystemPermissionsService;
- private const int BUFFER_SIZE = 16; // 16 bytes should be more than enough for common images header types
+ private const int BUFFER_SIZE = 18; // 18 bytes should be more than enough for common images header types
#endregion
#region ====================================================================== CTOR =====================================================================================
@@ -119,7 +119,7 @@ public class FileTypeService : IFileTypeService
if (buffer.Length < 18)
return false;
byte imageType = buffer[2];
- return imageType is 1 or 2 or 10;
+ return imageType is 1 or 2 or 3 or 9 or 10 or 11;
}
///
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/PathService.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/PathService.cs
index b3507eec..cb3cf783 100644
--- a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/PathService.cs
+++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Services/PathService.cs
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
+using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using System.Collections.Generic;
@@ -69,6 +70,8 @@ public class PathService : IPathService
/// An containing the combined path, or an error.
public ErrorOr CombinePath(string path, string name)
{
+ if (string.IsNullOrWhiteSpace(path) || string.IsNullOrWhiteSpace(name))
+ return Errors.FileManagement.InvalidPath;
ErrorOr newPathResult = FileSystemPathId.Create(path);
if (newPathResult.IsError)
return newPathResult.Errors;
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Path/WindowsPathStrategy.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Path/WindowsPathStrategy.cs
index bb375722..a0c60c23 100644
--- a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Path/WindowsPathStrategy.cs
+++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Path/WindowsPathStrategy.cs
@@ -4,7 +4,6 @@ using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using System;
using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
using System.IO.Abstractions;
using System.Linq;
using System.Text.RegularExpressions;
@@ -50,7 +49,7 @@ public class WindowsPathStrategy : IWindowsPathStrategy
return false;
// regular expression to match valid absolute paths
// this allows drive letters (e.g., C:\) and UNC paths (e.g., \\server\share)
- string pathPattern = @"^[a-zA-Z]:\\(?:[a-zA-Z0-9\s()._-]+\\)*[a-zA-Z0-9\s()._-]*\\?$";
+ string pathPattern = @"^(?:[a-zA-Z]:\\|\\\\[a-zA-Z0-9\s()._-]+\\[a-zA-Z0-9\s()._-]+)(?:[a-zA-Z0-9\s()._-]+\\)*[a-zA-Z0-9\s()._-]*\\?$";
return Regex.IsMatch(path.Path, pathPattern);
}
@@ -89,8 +88,8 @@ public class WindowsPathStrategy : IWindowsPathStrategy
/// An containing the path segments, or an error.
public ErrorOr> ParsePath(FileSystemPathId path)
{
- // Windows paths usually start with a drive letter and colon, e.g., "C:"
- if (!path.Path.Contains(':') || !path.Path.Contains(PathSeparator) || !char.IsLetter(path.Path[0]) || path.Path[1] != ':' || path.Path[2] != PathSeparator)
+ // Windows paths usually start with a drive letter and colon, e.g., "C:", or "\\" (UNC paths)
+ if (!(path.Path.StartsWith(@"\\") || (path.Path.Length >= 3 && char.IsLetter(path.Path[0]) && path.Path[1] == ':' && path.Path[2] == PathSeparator)))
return Errors.FileManagement.InvalidPath;
IEnumerable> getPathSegmentsResults = GetPathSegments();
foreach (ErrorOr getPathSegmentsResult in getPathSegmentsResults)
@@ -99,20 +98,39 @@ public class WindowsPathStrategy : IWindowsPathStrategy
return ErrorOrFactory.From(getPathSegmentsResults.Select(getPathSegmentsResult => getPathSegmentsResult.Value));
IEnumerable> GetPathSegments()
{
- // the drive segment
- yield return PathSegment.Create(path.Path[..2], isDirectory: false, isDrive: true);
- // extract the other segments
- string[] segments = path.Path[3..].Split(new[] { PathSeparator }, StringSplitOptions.RemoveEmptyEntries);
- for (int i = 0; i < segments.Length; i++)
+ if (path.Path.StartsWith(@"\\"))
{
- string segment = segments[i];
- bool isDirectory;
- if (segment.Contains('.'))
- isDirectory = i != segments.Length - 1 || path.Path.EndsWith(PathSeparator); // check if it's the last segment or if the next segment also contains a path delimiter
- else
- isDirectory = true;
- yield return PathSegment.Create(segment, isDirectory, isDrive: false);
+ // handle UNC path
+ yield return PathSegment.Create(@"\\", isDirectory: false, isDrive: true);
+
+ string[] segments = path.Path[2..].Split(new[] { PathSeparator }, StringSplitOptions.RemoveEmptyEntries);
+ for (int i = 0; i < segments.Length; i++)
+ yield return CreatePathSegment(segments[i], i, segments.Length);
}
+ else // handle regular Windows path
+ {
+ // the drive segment
+ yield return PathSegment.Create(path.Path[..2], isDirectory: false, isDrive: true);
+ // extract the other segments
+ string[] segments = path.Path[3..].Split(new[] { PathSeparator }, StringSplitOptions.RemoveEmptyEntries);
+ for (int i = 0; i < segments.Length; i++)
+ {
+ string segment = segments[i];
+ bool isDirectory;
+ if (segment.Contains('.'))
+ isDirectory = i != segments.Length - 1 || path.Path.EndsWith(PathSeparator); // check if it's the last segment or if the next segment also contains a path delimiter
+ else
+ isDirectory = true;
+ yield return PathSegment.Create(segment, isDirectory, isDrive: false);
+ }
+ }
+ }
+ ErrorOr CreatePathSegment(string segment, int index, int totalSegments)
+ {
+ bool isDirectory = segment.Contains('.')
+ ? index != totalSegments - 1 || path.Path.EndsWith(PathSeparator)
+ : true;
+ return PathSegment.Create(segment, isDirectory, isDrive: false);
}
}
@@ -126,22 +144,30 @@ public class WindowsPathStrategy : IWindowsPathStrategy
// validation: ensure the path is not null or empty
if (!IsValidPath(path))
return Errors.FileManagement.InvalidPath;
- // if path is just a drive letter followed by ":\", return null
- if (Regex.IsMatch(path.Path, @"^[a-zA-Z]:\\?$"))
+ // trim trailing backslash for consistent processing
+ string tempPath = path.Path.TrimEnd(PathSeparator);
+ // check for UNC path
+ if (tempPath.StartsWith(@"\\"))
+ {
+ string[] parts = tempPath.Split(PathSeparator, StringSplitOptions.RemoveEmptyEntries);
+ if (parts.Length <= 2)
+ return Errors.FileManagement.CannotNavigateUp;
+ // if it's a single-level UNC path, return the UNC root
+ if (parts.Length == 3)
+ return ParsePath(FileSystemPathId.Create($@"\\{parts[0]}\{parts[1]}").Value);
+ } // check for drive root (both with and without trailing backslash)
+ else if ((tempPath.Length == 2 && tempPath[1] == ':') || (tempPath.Length == 3 && tempPath[1] == ':' && tempPath[2] == PathSeparator))
return Errors.FileManagement.CannotNavigateUp;
- // trim trailing slash for consistent processing
- string tempPath = path.Path;
- if (tempPath.EndsWith('\\'))
- tempPath = tempPath.TrimEnd(PathSeparator);
- // find the last occurrence of a slash
+ // find the last occurrence of a backslash
int lastIndex = tempPath.LastIndexOf(PathSeparator);
- // if there's no slash found (shouldn't happen due to previous steps), or if we are at the root level after trimming, return error
- if (lastIndex < 0)
- return Errors.FileManagement.CannotNavigateUp;
- // if we are at the drive root level after trimming, return drive root, otherwise, return the path up to the last slash
- ErrorOr newPathResult = FileSystemPathId.Create(lastIndex == 2 && tempPath[1] == ':' ? tempPath[..3] : tempPath[..lastIndex]);
+ // if there's no backslash found or it's at the root level, return the root
+ if (lastIndex <= 2)
+ return ParsePath(FileSystemPathId.Create(tempPath[..3]).Value);
+ // return the path up to the last backslash
+ ErrorOr newPathResult = FileSystemPathId.Create(tempPath[..lastIndex]);
if (newPathResult.IsError)
return newPathResult.Errors;
+
return ParsePath(newPathResult.Value);
}
@@ -163,28 +189,30 @@ public class WindowsPathStrategy : IWindowsPathStrategy
{
if (!IsValidPath(path))
return Errors.FileManagement.InvalidPath;
- // check if the path starts with a drive letter (e.g., "C:")
- if (path.Path.Length >= 2 && char.IsLetter(path.Path[0]) && path.Path[1] == ':')
+ // handle UNC paths (e.g., \\server\share\folder)
+ if (path.Path.StartsWith(@"\\"))
{
- string root = path.Path[..2];
- if (path.Path.Length > 2 && path.Path[2] == PathSeparator)
- root += PathSeparator;
- return PathSegment.Create(root, isDirectory: true, isDrive: true);
+ // find the position of the second backslash (after \\server)
+ int secondBackslash = path.Path.IndexOf('\\', 2);
+ if (secondBackslash == -1)
+ return Errors.FileManagement.InvalidPath; // invalid UNC path, missing server name
+ // find the position of the third backslash (after \\server\share)
+ int thirdBackslash = path.Path.IndexOf('\\', secondBackslash + 1);
+ if (thirdBackslash == -1)
+ thirdBackslash = path.Path.Length; // no third backslash, use entire path
+ // return the UNC root (\\server\share\)
+ return PathSegment.Create(path.Path[..thirdBackslash] + "\\", isDirectory: true, isDrive: false);
}
- // check for UNC paths (e.g., "\\server\share")
- if (path.Path.StartsWith('\\'))
- {
- ErrorOr> parseResult = ParsePath(path);
- if (parseResult.IsError)
- return parseResult.Errors;
-
- List segments = parseResult.Value.ToList();
- if (segments.Count >= 2)
- {
- string root = $@"\\{segments[0].Name}\{segments[1].Name}\";
- return PathSegment.Create(root, isDirectory: true, isDrive: false);
- }
+ else // handle drive letter paths (e.g., C:\folder)
+ {
+ // check if the path starts with a drive letter followed by a colon (e.g., C:)
+ // path.Path.Length >= 2: Ensure the path is at least 2 characters long
+ // char.IsLetter(path.Path[0]): First character should be a letter
+ // path.Path[1] == ':': Second character should be a colon
+ if (path.Path.Length >= 2 && char.IsLetter(path.Path[0]) && path.Path[1] == ':')
+ return PathSegment.Create(path.Path[..2] + "\\", isDirectory: true, isDrive: true); // return the drive root (e.g., C:\)
}
+ // if we reach here, the path is neither a valid UNC path nor a valid drive path
return Errors.FileManagement.InvalidPath;
}
#endregion
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/IOperatingSystemInfo.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/IOperatingSystemInfo.cs
new file mode 100644
index 00000000..4a6875c4
--- /dev/null
+++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/IOperatingSystemInfo.cs
@@ -0,0 +1,20 @@
+#region ========================================================================= USING =====================================================================================
+using System.Runtime.InteropServices;
+#endregion
+
+namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
+
+///
+/// Interface for checking the type of the current Operating System platform.
+///
+public interface IOperatingSystemInfo
+{
+ #region ===================================================================== METHODS ===================================================================================
+ ///
+ /// Determines if the current Operating System plaform is .
+ ///
+ /// The Operating System platform to check against.
+ /// if tthe current Operating System platform is equal to , otherwise.
+ bool IsOSPlatform(OSPlatform platform);
+ #endregion
+}
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/OperatingSystemInfo.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/OperatingSystemInfo.cs
new file mode 100644
index 00000000..f2404710
--- /dev/null
+++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/OperatingSystemInfo.cs
@@ -0,0 +1,25 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
+#endregion
+
+namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
+
+///
+/// Class for checking the type of the current Operating System platform.
+///
+[ExcludeFromCodeCoverage]
+internal class OperatingSystemInfo : IOperatingSystemInfo
+{
+ #region ===================================================================== METHODS ===================================================================================
+ ///
+ /// Determines if the current Operating System plaform is .
+ ///
+ /// The Operating System platform to check against.
+ /// if tthe current Operating System platform is equal to , otherwise.
+ public bool IsOSPlatform(OSPlatform platform)
+ {
+ return RuntimeInformation.IsOSPlatform(platform);
+ }
+ #endregion
+}
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/PlatformContextManager.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/PlatformContextManager.cs
index d3eb8446..946351df 100644
--- a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/PlatformContextManager.cs
+++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/PlatformContextManager.cs
@@ -1,4 +1,4 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using System;
using System.Runtime.InteropServices;
@@ -14,6 +14,7 @@ public class PlatformContextManager : IPlatformContextManager
#region ================================================================== FIELD MEMBERS ================================================================================
private IPlatformContext? _currentPlatformContext;
private readonly IPlatformContextFactory _platformContextFactory;
+ private readonly IOperatingSystemInfo _operatingSystemInfo;
#endregion
#region ====================================================================== CTOR =====================================================================================
@@ -21,9 +22,11 @@ public class PlatformContextManager : IPlatformContextManager
/// Initializes a new instance of the class.
///
/// Injected factory for creating platform contexts.
- public PlatformContextManager(IPlatformContextFactory platformContextFactory)
+ /// Injected class for checking the platform type of the current Operating System.
+ public PlatformContextManager(IPlatformContextFactory platformContextFactory, IOperatingSystemInfo operatingSystemInfo)
{
_platformContextFactory = platformContextFactory;
+ _operatingSystemInfo = operatingSystemInfo;
}
#endregion
@@ -37,7 +40,7 @@ public class PlatformContextManager : IPlatformContextManager
// set a default context if none is set
if (_currentPlatformContext is null)
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ if (_operatingSystemInfo.IsOSPlatform(OSPlatform.Linux))
SetCurrentPlatform(PlatformType.Unix);
else
SetCurrentPlatform(PlatformType.Windows);
@@ -61,4 +64,4 @@ public class PlatformContextManager : IPlatformContextManager
};
}
#endregion
-}
\ No newline at end of file
+}
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/UnixPlatformContext.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/UnixPlatformContext.cs
index 75e5e7b2..fedf3d70 100644
--- a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/UnixPlatformContext.cs
+++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/UnixPlatformContext.cs
@@ -1,4 +1,4 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
#endregion
@@ -19,7 +19,7 @@ internal class UnixPlatformContext : IUnixPlatformContext
///
/// Gets the path strategy for Unix platforms.
///
- public IPathStrategy PathStrategy { get; private set; }
+ public IPathStrategy PathStrategy { get; }
#endregion
#region ====================================================================== CTOR =====================================================================================
@@ -32,4 +32,4 @@ internal class UnixPlatformContext : IUnixPlatformContext
PathStrategy = unixPathStrategy;
}
#endregion
-}
\ No newline at end of file
+}
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/WindowsPlatformContext.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/WindowsPlatformContext.cs
index 38ccb4cd..93f7f2a4 100644
--- a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/WindowsPlatformContext.cs
+++ b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/Strategies/Platform/WindowsPlatformContext.cs
@@ -1,4 +1,4 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
#endregion
@@ -19,7 +19,7 @@ public class WindowsPlatformContext : IWindowsPlatformContext
///
/// Gets the path strategy for Windows platforms.
///
- public IPathStrategy PathStrategy { get; private set; }
+ public IPathStrategy PathStrategy { get; }
#endregion
#region ====================================================================== CTOR =====================================================================================
@@ -32,4 +32,4 @@ public class WindowsPlatformContext : IWindowsPlatformContext
PathStrategy = windowsPathStrategy;
}
#endregion
-}
\ No newline at end of file
+}
diff --git a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/ValueObjects/FileSystemId.cs b/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/ValueObjects/FileSystemId.cs
deleted file mode 100644
index 40cce931..00000000
--- a/src/Lumina.Domain/Core/Aggregates/FileManagement/FileManagementAggregate/ValueObjects/FileSystemId.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Models.Core;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-#endregion
-
-namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
-
-///
-/// Value Object for the Id of a book.
-///
-[DebuggerDisplay("{Value}")]
-public sealed class FileSystemId : EntityId
-{
- #region ====================================================================== CTOR =====================================================================================
- ///
- /// Initializes a new instance of the class.
- ///
- /// The value representing this object.
- private FileSystemId(Guid value) : base(value)
- {
- }
- #endregion
-
- #region ===================================================================== METHODS ===================================================================================
- ///
- /// Creates a new instance of the class.
- ///
- /// The created instance.
- public static FileSystemId CreateUnique()
- {
- return new FileSystemId(Guid.NewGuid());
- }
-
- ///
- /// Creates a new instance of the class, from a pre-existing .
- ///
- /// The value used to create the instance.
- /// The created instance.
- public static FileSystemId Create(Guid value)
- {
- return new FileSystemId(value);
- }
-
- ///
- public override IEnumerable