diff --git a/StabilityMatrix.Core/Models/FileInterfaces/DirectoryPath.cs b/StabilityMatrix.Core/Models/FileInterfaces/DirectoryPath.cs index 201d592e..37a8f8fc 100644 --- a/StabilityMatrix.Core/Models/FileInterfaces/DirectoryPath.cs +++ b/StabilityMatrix.Core/Models/FileInterfaces/DirectoryPath.cs @@ -1,10 +1,13 @@ -namespace StabilityMatrix.Core.Models.FileInterfaces; +using System.Diagnostics.CodeAnalysis; +namespace StabilityMatrix.Core.Models.FileInterfaces; + +[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] public class DirectoryPath : FileSystemPath, IPathObject { - private DirectoryInfo? _info; + private DirectoryInfo? info; // ReSharper disable once MemberCanBePrivate.Global - public DirectoryInfo Info => _info ??= new DirectoryInfo(FullPath); + public DirectoryInfo Info => info ??= new DirectoryInfo(FullPath); public bool IsSymbolicLink { @@ -70,6 +73,18 @@ public class DirectoryPath : FileSystemPath, IPathObject /// Deletes the directory asynchronously. public Task DeleteAsync(bool recursive) => Task.Run(() => Delete(recursive)); + + /// + /// Join with other paths to form a new directory path. + /// + public DirectoryPath JoinDir(params DirectoryPath[] paths) => + new(Path.Combine(FullPath, Path.Combine(paths.Select(path => path.FullPath).ToArray()))); + + /// + /// Join with other paths to form a new file path. + /// + public FilePath JoinFile(params FileSystemPath[] paths) => + new(Path.Combine(FullPath, Path.Combine(paths.Select(path => path.FullPath).ToArray()))); public override string ToString() => FullPath;