diff --git a/Directory.Packages.props b/Directory.Packages.props index a73c5be55fd6..5589ee9477bd 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -27,6 +27,7 @@ + diff --git a/src/Files.App.Controls/BladeView/BladeView.xaml b/src/Files.App.Controls/BladeView/BladeView.xaml index 28e15f3b4451..82a593fed509 100644 --- a/src/Files.App.Controls/BladeView/BladeView.xaml +++ b/src/Files.App.Controls/BladeView/BladeView.xaml @@ -125,8 +125,8 @@ FontSize="14" Foreground="{TemplateBinding CloseButtonForeground}" Style="{StaticResource ButtonRevealStyle}" - Visibility="{TemplateBinding CloseButtonVisibility}" - TabIndex="0" /> + TabIndex="0" + Visibility="{TemplateBinding CloseButtonVisibility}" /> diff --git a/src/Files.App.Storage/GlobalUsings.cs b/src/Files.App.Storage/GlobalUsings.cs index 4261d51d760c..24e1a2323cd6 100644 --- a/src/Files.App.Storage/GlobalUsings.cs +++ b/src/Files.App.Storage/GlobalUsings.cs @@ -23,7 +23,7 @@ global using global::Files.Core.Storage.Enums; global using global::Files.Core.Storage.EventArguments; global using global::Files.Core.Storage.Extensions; -global using global::Files.Core.Storage.StorageEnumeration; +global using global::OwlCore.Storage; // Files.App.Storage diff --git a/src/Files.App.Storage/Storables/FtpStorage/FtpStorable.cs b/src/Files.App.Storage/Storables/FtpStorage/FtpStorable.cs index 3d9195161558..7987071dab29 100644 --- a/src/Files.App.Storage/Storables/FtpStorage/FtpStorable.cs +++ b/src/Files.App.Storage/Storables/FtpStorage/FtpStorable.cs @@ -5,11 +5,8 @@ namespace Files.App.Storage.Storables { - public abstract class FtpStorable : ILocatableStorable, INestedStorable + public abstract class FtpStorable : IStorableChild { - /// - public virtual string Path { get; protected set; } - /// public virtual string Name { get; protected set; } @@ -23,21 +20,20 @@ public abstract class FtpStorable : ILocatableStorable, INestedStorable protected internal FtpStorable(string path, string name, IFolder? parent) { - Path = FtpHelpers.GetFtpPath(path); + Id = FtpHelpers.GetFtpPath(path); Name = name; - Id = Path; Parent = parent; } /// public Task GetParentAsync(CancellationToken cancellationToken = default) { - return Task.FromResult(Parent); + return Task.FromResult(Parent); } protected AsyncFtpClient GetFtpClient() { - return FtpHelpers.GetFtpClient(Path); + return FtpHelpers.GetFtpClient(Id); } } } diff --git a/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFile.cs b/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFile.cs index 9e0227df56be..35ecb890e9c0 100644 --- a/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFile.cs +++ b/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFile.cs @@ -5,7 +5,7 @@ namespace Files.App.Storage.Storables { - public sealed class FtpStorageFile : FtpStorable, IModifiableFile, ILocatableFile, INestedFile + public sealed class FtpStorageFile : FtpStorable, IChildFile { public FtpStorageFile(string path, string name, IFolder? parent) : base(path, name, parent) @@ -19,9 +19,9 @@ public async Task OpenStreamAsync(FileAccess access, CancellationToken c await ftpClient.EnsureConnectedAsync(cancellationToken); if (access.HasFlag(FileAccess.Write)) - return await ftpClient.OpenWrite(Path, token: cancellationToken); + return await ftpClient.OpenWrite(Id, token: cancellationToken); else if (access.HasFlag(FileAccess.Read)) - return await ftpClient.OpenRead(Path, token: cancellationToken); + return await ftpClient.OpenRead(Id, token: cancellationToken); else throw new ArgumentException($"Invalid {nameof(access)} flag."); } diff --git a/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFolder.cs b/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFolder.cs index 327b3d820013..3a5d838079fa 100644 --- a/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFolder.cs +++ b/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFolder.cs @@ -8,7 +8,7 @@ namespace Files.App.Storage.Storables { - public sealed class FtpStorageFolder : FtpStorable, ILocatableFolder, IModifiableFolder, IFolderExtended, INestedFolder, IDirectCopy, IDirectMove + public sealed class FtpStorageFolder : FtpStorable, IModifiableFolder, IChildFolder, IDirectCopy, IDirectMove, IGetFirstByName { public FtpStorageFolder(string path, string name, IFolder? parent) : base(path, name, parent) @@ -16,52 +16,41 @@ public FtpStorageFolder(string path, string name, IFolder? parent) } /// - public async Task GetFileAsync(string fileName, CancellationToken cancellationToken = default) + public async Task GetFirstByNameAsync(string folderName, CancellationToken cancellationToken = default) { using var ftpClient = GetFtpClient(); await ftpClient.EnsureConnectedAsync(cancellationToken); - var path = FtpHelpers.GetFtpPath(PathHelpers.Combine(Path, fileName)); + var path = FtpHelpers.GetFtpPath(PathHelpers.Combine(Id, folderName)); var item = await ftpClient.GetObjectInfo(path, token: cancellationToken); - if (item is null || item.Type != FtpObjectType.File) + if (item is null) throw new FileNotFoundException(); - return new FtpStorageFile(path, item.Name, this); - } - - /// - public async Task GetFolderAsync(string folderName, CancellationToken cancellationToken = default) - { - using var ftpClient = GetFtpClient(); - await ftpClient.EnsureConnectedAsync(cancellationToken); - - var path = FtpHelpers.GetFtpPath(PathHelpers.Combine(Path, folderName)); - var item = await ftpClient.GetObjectInfo(path, token: cancellationToken); - - if (item is null || item.Type != FtpObjectType.Directory) - throw new DirectoryNotFoundException(); + if (item.Type == FtpObjectType.Directory) + return new FtpStorageFolder(path, item.Name, this); + else + return new FtpStorageFile(path, item.Name, this); - return new FtpStorageFolder(path, item.Name, this); } /// - public async IAsyncEnumerable GetItemsAsync(StorableKind kind = StorableKind.All, [EnumeratorCancellation] CancellationToken cancellationToken = default) + public async IAsyncEnumerable GetItemsAsync(StorableType kind = StorableType.All, [EnumeratorCancellation] CancellationToken cancellationToken = default) { using var ftpClient = GetFtpClient(); await ftpClient.EnsureConnectedAsync(cancellationToken); - if (kind == StorableKind.Files) + if (kind == StorableType.File) { - foreach (var item in await ftpClient.GetListing(Path, cancellationToken)) + foreach (var item in await ftpClient.GetListing(Id, cancellationToken)) { if (item.Type == FtpObjectType.File) yield return new FtpStorageFile(item.FullName, item.Name, this); } } - else if (kind == StorableKind.Folders) + else if (kind == StorableType.Folder) { - foreach (var item in await ftpClient.GetListing(Path, cancellationToken)) + foreach (var item in await ftpClient.GetListing(Id, cancellationToken)) { if (item.Type == FtpObjectType.Directory) yield return new FtpStorageFolder(item.FullName, item.Name, this); @@ -69,7 +58,7 @@ public async IAsyncEnumerable GetItemsAsync(StorableKind kind = } else { - foreach (var item in await ftpClient.GetListing(Path, cancellationToken)) + foreach (var item in await ftpClient.GetListing(Id, cancellationToken)) { if (item.Type == FtpObjectType.File) yield return new FtpStorageFile(item.FullName, item.Name, this); @@ -81,18 +70,24 @@ public async IAsyncEnumerable GetItemsAsync(StorableKind kind = } /// - public async Task DeleteAsync(INestedStorable item, bool permanently = false, CancellationToken cancellationToken = default) + public Task GetFolderWatcherAsync(CancellationToken cancellationToken = default) + { + return Task.FromException(new NotSupportedException()); + } + + /// + public async Task DeleteAsync(IStorableChild item, CancellationToken cancellationToken = default) { using var ftpClient = GetFtpClient(); await ftpClient.EnsureConnectedAsync(cancellationToken); - if (item is ILocatableFile locatableFile) + if (item is IFile locatableFile) { - await ftpClient.DeleteFile(locatableFile.Path, cancellationToken); + await ftpClient.DeleteFile(locatableFile.Id, cancellationToken); } - else if (item is ILocatableFolder locatableFolder) + else if (item is IFolder locatableFolder) { - await ftpClient.DeleteDirectory(locatableFolder.Path, cancellationToken); + await ftpClient.DeleteDirectory(locatableFolder.Id, cancellationToken); } else { @@ -101,7 +96,7 @@ public async Task DeleteAsync(INestedStorable item, bool permanently = false, Ca } /// - public async Task CreateCopyOfAsync(INestedStorable itemToCopy, bool overwrite = default, CancellationToken cancellationToken = default) + public async Task CreateCopyOfAsync(IStorableChild itemToCopy, bool overwrite = default, CancellationToken cancellationToken = default) { if (itemToCopy is IFile sourceFile) { @@ -117,24 +112,24 @@ public async Task CreateCopyOfAsync(INestedStorable itemToCopy, } /// - public async Task MoveFromAsync(INestedStorable itemToMove, IModifiableFolder source, bool overwrite = default, CancellationToken cancellationToken = default) + public async Task MoveFromAsync(IStorableChild itemToMove, IModifiableFolder source, bool overwrite = default, CancellationToken cancellationToken = default) { using var ftpClient = GetFtpClient(); await ftpClient.EnsureConnectedAsync(cancellationToken); var newItem = await CreateCopyOfAsync(itemToMove, overwrite, cancellationToken); - await source.DeleteAsync(itemToMove, true, cancellationToken); + await source.DeleteAsync(itemToMove, cancellationToken); return newItem; } /// - public async Task CreateFileAsync(string desiredName, bool overwrite = default, CancellationToken cancellationToken = default) + public async Task CreateFileAsync(string desiredName, bool overwrite = default, CancellationToken cancellationToken = default) { using var ftpClient = GetFtpClient(); await ftpClient.EnsureConnectedAsync(cancellationToken); - var newPath = $"{Path}/{desiredName}"; + var newPath = $"{Id}/{desiredName}"; if (overwrite && await ftpClient.FileExists(newPath, cancellationToken)) throw new IOException("File already exists."); @@ -159,12 +154,12 @@ public async Task CreateFileAsync(string desiredName, bool overwrit } /// - public async Task CreateFolderAsync(string desiredName, bool overwrite = default, CancellationToken cancellationToken = default) + public async Task CreateFolderAsync(string desiredName, bool overwrite = default, CancellationToken cancellationToken = default) { using var ftpClient = GetFtpClient(); await ftpClient.EnsureConnectedAsync(cancellationToken); - var newPath = $"{Path}/{desiredName}"; + var newPath = $"{Id}/{desiredName}"; if (overwrite && await ftpClient.DirectoryExists(newPath, cancellationToken)) throw new IOException("Directory already exists."); diff --git a/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeFile.cs b/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeFile.cs deleted file mode 100644 index bcddf808d60f..000000000000 --- a/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeFile.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using System.IO; - -namespace Files.App.Storage.Storables -{ - /// - [Obsolete("Use the new WindowsStorable")] - public class NativeFileLegacy : NativeStorableLegacy, ILocatableFile, IModifiableFile, IFileExtended, INestedFile - { - public NativeFileLegacy(FileInfo fileInfo, string? name = null) - : base(fileInfo, name) - { - } - - public NativeFileLegacy(string path, string? name = null) - : this(new FileInfo(path), name) - { - } - - /// - public virtual Task OpenStreamAsync(FileAccess access, CancellationToken cancellationToken = default) - { - return OpenStreamAsync(access, FileShare.None, cancellationToken); - } - - /// - public virtual Task OpenStreamAsync(FileAccess access, FileShare share = FileShare.None, CancellationToken cancellationToken = default) - { - var stream = File.Open(Path, FileMode.Open, access, share); - return Task.FromResult(stream); - } - } -} diff --git a/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeFolder.cs b/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeFolder.cs deleted file mode 100644 index 55dcc6ff675b..000000000000 --- a/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeFolder.cs +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using System.IO; -using System.Runtime.CompilerServices; - -namespace Files.App.Storage.Storables -{ - /// - [Obsolete("Use the new WindowsStorable")] - public class NativeFolderLegacy : NativeStorableLegacy, ILocatableFolder, IModifiableFolder, IMutableFolder, IFolderExtended, INestedFolder, IDirectCopy, IDirectMove - { - public NativeFolderLegacy(DirectoryInfo directoryInfo, string? name = null) - : base(directoryInfo, name) - { - } - - public NativeFolderLegacy(string path, string? name = null) - : this(new DirectoryInfo(path), name) - { - } - - /// - public virtual Task GetFileAsync(string fileName, CancellationToken cancellationToken = default) - { - var path = System.IO.Path.Combine(Path, fileName); - - if (!File.Exists(path)) - throw new FileNotFoundException(); - - return Task.FromResult(new NativeFileLegacy(path)); - } - - /// - public virtual Task GetFolderAsync(string folderName, CancellationToken cancellationToken = default) - { - var path = System.IO.Path.Combine(Path, folderName); - if (!Directory.Exists(path)) - throw new FileNotFoundException(); - - return Task.FromResult(new NativeFolderLegacy(path)); - } - - /// - public virtual async IAsyncEnumerable GetItemsAsync(StorableKind kind = StorableKind.All, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - if (kind == StorableKind.Files) - { - foreach (var item in Directory.EnumerateFiles(Path)) - yield return new NativeFileLegacy(item); - } - else if (kind == StorableKind.Folders) - { - foreach (var item in Directory.EnumerateDirectories(Path)) - yield return new NativeFolderLegacy(item); - } - else - { - foreach (var item in Directory.EnumerateFileSystemEntries(Path)) - { - if (File.Exists(item)) - yield return new NativeFileLegacy(item); - else - yield return new NativeFolderLegacy(item); - } - } - - await Task.CompletedTask; - } - - /// - public virtual Task DeleteAsync(INestedStorable item, bool permanently = false, CancellationToken cancellationToken = default) - { - _ = permanently; - - if (item is ILocatableFile locatableFile) - { - File.Delete(locatableFile.Path); - } - else if (item is ILocatableFolder locatableFolder) - { - Directory.Delete(locatableFolder.Path, true); - } - else - throw new ArgumentException($"Could not delete {item}."); - - return Task.CompletedTask; - } - - /// - public virtual async Task CreateCopyOfAsync(INestedStorable itemToCopy, bool overwrite = default, CancellationToken cancellationToken = default) - { - if (itemToCopy is IFile sourceFile) - { - if (itemToCopy is ILocatableFile sourceLocatableFile) - { - var newPath = System.IO.Path.Combine(Path, itemToCopy.Name); - File.Copy(sourceLocatableFile.Path, newPath, overwrite); - - return new NativeFileLegacy(newPath); - } - - var copiedFile = await CreateFileAsync(itemToCopy.Name, overwrite, cancellationToken); - await sourceFile.CopyContentsToAsync(copiedFile, cancellationToken); - - return copiedFile; - } - else if (itemToCopy is IFolder sourceFolder) - { - // TODO: Implement folder copy - _ = sourceFolder; - throw new NotSupportedException(); - } - - throw new ArgumentException($"Could not copy type {itemToCopy.GetType()}"); - } - - /// - public virtual async Task MoveFromAsync(INestedStorable itemToMove, IModifiableFolder source, bool overwrite = default, CancellationToken cancellationToken = default) - { - if (itemToMove is IFile sourceFile) - { - if (itemToMove is ILocatableFile sourceLocatableFile) - { - var newPath = System.IO.Path.Combine(Path, itemToMove.Name); - File.Move(sourceLocatableFile.Path, newPath, overwrite); - - return new NativeFileLegacy(newPath); - } - else - { - var copiedFile = await CreateFileAsync(itemToMove.Name, overwrite, cancellationToken); - await sourceFile.CopyContentsToAsync(copiedFile, cancellationToken); - await source.DeleteAsync(itemToMove, true, cancellationToken); - - return copiedFile; - } - } - else if (itemToMove is IFolder sourceFolder) - { - throw new NotImplementedException(); - } - - throw new ArgumentException($"Could not move type {itemToMove.GetType()}"); - } - - /// - public virtual async Task CreateFileAsync(string desiredName, bool overwrite = default, CancellationToken cancellationToken = default) - { - var path = System.IO.Path.Combine(Path, desiredName); - if (overwrite || !File.Exists(path)) - await File.Create(path).DisposeAsync(); - - return new NativeFileLegacy(path); - } - - /// - public virtual Task CreateFolderAsync(string desiredName, bool overwrite = default, CancellationToken cancellationToken = default) - { - var path = System.IO.Path.Combine(Path, desiredName); - if (overwrite) - Directory.Delete(path, true); - - _ = Directory.CreateDirectory(path); - return Task.FromResult(new NativeFolderLegacy(path)); - } - } -} diff --git a/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeStorable.cs b/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeStorable.cs deleted file mode 100644 index e91f8f2146cc..000000000000 --- a/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeStorable.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using System.IO; - -namespace Files.App.Storage.Storables -{ - /// - [Obsolete("Use the new WindowsStorable")] - public abstract class NativeStorableLegacy : ILocatableStorable, INestedStorable - where TStorage : FileSystemInfo - { - protected readonly TStorage storage; - - /// - public string Path { get; protected set; } - - /// - public string Name { get; protected set; } - - /// - public virtual string Id { get; } - - protected NativeStorableLegacy(TStorage storage, string? name = null) - { - this.storage = storage; - Path = storage.FullName; - Name = name ?? storage.Name; - Id = storage.FullName; - } - - /// - public virtual Task GetParentAsync(CancellationToken cancellationToken = default) - { - var parent = Directory.GetParent(Path); - if (parent is null) - return Task.FromResult(null); - - return Task.FromResult(new NativeFolderLegacy(parent)); - } - - /// - /// Formats a given . - /// - /// The path to format. - /// A formatted path. - protected static string FormatPath(string path) - { - path = path.Replace("file:///", string.Empty); - - if ('/' != System.IO.Path.DirectorySeparatorChar) - return path.Replace('/', System.IO.Path.DirectorySeparatorChar); - - if ('\\' != System.IO.Path.DirectorySeparatorChar) - return path.Replace('\\', System.IO.Path.DirectorySeparatorChar); - - return path; - } - } -} diff --git a/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeStorageService.cs b/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeStorageService.cs index c827ff71dbd2..b97271818f42 100644 --- a/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeStorageService.cs +++ b/src/Files.App.Storage/Storables/NativeStorageLegacy/NativeStorageService.cs @@ -1,9 +1,7 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.Shared.Helpers; -using System.IO; -using Windows.Storage; +using OwlCore.Storage.System.IO; namespace Files.App.Storage.Storables { @@ -12,40 +10,17 @@ namespace Files.App.Storage.Storables public sealed class NativeStorageLegacyService : IStorageService { /// - public Task GetFileAsync(string id, CancellationToken cancellationToken = default) + public async Task GetFileAsync(string id, CancellationToken cancellationToken = default) { - if (!File.Exists(id)) - throw new FileNotFoundException(); - - return Task.FromResult(new NativeFileLegacy(id)); + await Task.CompletedTask; + return new SystemFile(id); } /// public async Task GetFolderAsync(string id, CancellationToken cancellationToken = default) { - if (!Directory.Exists(id)) - throw new DirectoryNotFoundException(); - - // A special folder should use the localized name - if (PathHelpers.IsSpecialFolder(id)) - { - var storageFolder = await TryGetStorageFolderAsync(id); - return new NativeFolderLegacy(id, storageFolder?.DisplayName); - } - - return new NativeFolderLegacy(id); - - async Task TryGetStorageFolderAsync(string path) - { - try - { - return await StorageFolder.GetFolderFromPathAsync(path); - } - catch (Exception) - { - return null; - } - } + await Task.CompletedTask; + return new SystemFolder(id); } } } diff --git a/src/Files.App.Storage/Storables/WindowsStorageLegacy/WindowsStorable.cs b/src/Files.App.Storage/Storables/WindowsStorageLegacy/WindowsStorable.cs deleted file mode 100644 index 219024a12704..000000000000 --- a/src/Files.App.Storage/Storables/WindowsStorageLegacy/WindowsStorable.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Files.Shared.Helpers; -using Windows.Storage; - -namespace Files.App.Storage.Storables -{ - /// - [Obsolete("Use the new WindowsStorable")] - public abstract class WindowsStorableLegacy : ILocatableStorable, INestedStorable - where TStorage : class, IStorageItem - { - private string? _computedId; - internal readonly TStorage storage; - - /// - public string Path { get; protected internal set; } - - /// - public string Name { get; protected internal set; } - - /// - public virtual string Id => _computedId ??= ChecksumHelpers.CalculateChecksumForPath(Path); - - protected internal WindowsStorableLegacy(TStorage storage) - { - this.storage = storage; - Path = storage.Path; - Name = storage.Name; - } - - /// - public abstract Task GetParentAsync(CancellationToken cancellationToken = default); - } -} diff --git a/src/Files.App.Storage/Storables/WindowsStorageLegacy/WindowsStorageFile.cs b/src/Files.App.Storage/Storables/WindowsStorageLegacy/WindowsStorageFile.cs deleted file mode 100644 index 2dec8679b0d7..000000000000 --- a/src/Files.App.Storage/Storables/WindowsStorageLegacy/WindowsStorageFile.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using System.IO; -using Windows.Storage; - -namespace Files.App.Storage.Storables -{ - /// - [Obsolete("Use the new WindowsStorable")] - public sealed class WindowsStorageFileLegacy : WindowsStorableLegacy, ILocatableFile, IModifiableFile, IFileExtended, INestedFile - { - public WindowsStorageFileLegacy(StorageFile storage) - : base(storage) - { - } - - /// - public Task OpenStreamAsync(FileAccess access, CancellationToken cancellationToken = default) - { - return OpenStreamAsync(access, FileShare.None, cancellationToken); - } - - /// - public async Task OpenStreamAsync(FileAccess access, FileShare share = FileShare.None, CancellationToken cancellationToken = default) - { - var fileAccessMode = GetFileAccessMode(access); - var storageOpenOptions = GetStorageOpenOptions(share); - - var winrtStreamTask = storage.OpenAsync(fileAccessMode, storageOpenOptions).AsTask(cancellationToken); - var winrtStream = await winrtStreamTask; - - return winrtStream.AsStream(); - } - - /// - public override async Task GetParentAsync(CancellationToken cancellationToken = default) - { - var parentFolderTask = storage.GetParentAsync().AsTask(cancellationToken); - var parentFolder = await parentFolderTask; - - return new WindowsStorageFolderLegacy(parentFolder); - } - - private static FileAccessMode GetFileAccessMode(FileAccess access) - { - return access switch - { - FileAccess.Read => FileAccessMode.Read, - FileAccess.Write => FileAccessMode.ReadWrite, - FileAccess.ReadWrite => FileAccessMode.ReadWrite, - _ => throw new ArgumentOutOfRangeException(nameof(access)) - }; - } - - private static StorageOpenOptions GetStorageOpenOptions(FileShare share) - { - return share switch - { - FileShare.Read => StorageOpenOptions.AllowOnlyReaders, - FileShare.Write => StorageOpenOptions.AllowReadersAndWriters, - FileShare.ReadWrite => StorageOpenOptions.AllowReadersAndWriters, - FileShare.Inheritable => StorageOpenOptions.None, - FileShare.Delete => StorageOpenOptions.None, - FileShare.None => StorageOpenOptions.None, - _ => throw new ArgumentOutOfRangeException(nameof(share)) - }; - } - } -} diff --git a/src/Files.App.Storage/Storables/WindowsStorageLegacy/WindowsStorageFolder.cs b/src/Files.App.Storage/Storables/WindowsStorageLegacy/WindowsStorageFolder.cs deleted file mode 100644 index 1599f31fcab3..000000000000 --- a/src/Files.App.Storage/Storables/WindowsStorageLegacy/WindowsStorageFolder.cs +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using System.Runtime.CompilerServices; -using Windows.Storage; - -namespace Files.App.Storage.Storables -{ - /// - [Obsolete("Use the new WindowsStorable")] - public sealed class WindowsStorageFolderLegacy : WindowsStorableLegacy, ILocatableFolder, IFolderExtended, INestedFolder, IDirectCopy, IDirectMove - { - // TODO: Implement IMutableFolder - - public WindowsStorageFolderLegacy(StorageFolder storage) - : base(storage) - { - } - - /// - public async Task GetFileAsync(string fileName, CancellationToken cancellationToken = default) - { - var file = await storage.GetFileAsync(fileName).AsTask(cancellationToken); - return new WindowsStorageFileLegacy(file); - } - - /// - public async Task GetFolderAsync(string folderName, CancellationToken cancellationToken = default) - { - var folder = await storage.GetFolderAsync(folderName).AsTask(cancellationToken); - return new WindowsStorageFolderLegacy(folder); - } - - /// - public async IAsyncEnumerable GetItemsAsync(StorableKind kind = StorableKind.All, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - switch (kind) - { - case StorableKind.Files: - { - var files = await storage.GetFilesAsync().AsTask(cancellationToken); - foreach (var item in files) - { - yield return new WindowsStorageFileLegacy(item); - } - - break; - } - - case StorableKind.Folders: - { - var folders = await storage.GetFoldersAsync().AsTask(cancellationToken); - foreach (var item in folders) - { - yield return new WindowsStorageFolderLegacy(item); - } - - break; - } - - case StorableKind.All: - { - var items = await storage.GetItemsAsync().AsTask(cancellationToken); - foreach (var item in items) - { - if (item is StorageFile storageFile) - yield return new WindowsStorageFileLegacy(storageFile); - - if (item is StorageFolder storageFolder) - yield return new WindowsStorageFolderLegacy(storageFolder); - } - - break; - } - - default: - yield break; - } - } - - /// - public Task DeleteAsync(INestedStorable item, bool permanently = default, CancellationToken cancellationToken = default) - { - return item switch - { - WindowsStorableLegacy storageFile => storageFile.storage - .DeleteAsync(GetWindowsStorageDeleteOption(permanently)) - .AsTask(cancellationToken), - - WindowsStorableLegacy storageFolder => storageFolder.storage - .DeleteAsync(GetWindowsStorageDeleteOption(permanently)) - .AsTask(cancellationToken), - - _ => throw new NotImplementedException() - }; - } - - /// - public async Task CreateCopyOfAsync(INestedStorable itemToCopy, bool overwrite = default, CancellationToken cancellationToken = default) - { - if (itemToCopy is WindowsStorableLegacy sourceFile) - { - var copiedFile = await sourceFile.storage.CopyAsync(storage, itemToCopy.Name, GetWindowsNameCollisionOption(overwrite)).AsTask(cancellationToken); - return new WindowsStorageFileLegacy(copiedFile); - } - - throw new ArgumentException($"Could not copy type {itemToCopy.GetType()}"); - } - - /// - public async Task MoveFromAsync(INestedStorable itemToMove, IModifiableFolder source, bool overwrite = default, CancellationToken cancellationToken = default) - { - if (itemToMove is WindowsStorableLegacy sourceFile) - { - await sourceFile.storage.MoveAsync(storage, itemToMove.Name, GetWindowsNameCollisionOption(overwrite)).AsTask(cancellationToken); - return new WindowsStorageFileLegacy(sourceFile.storage); - } - - throw new ArgumentException($"Could not copy type {itemToMove.GetType()}"); - } - - /// - public async Task CreateFileAsync(string desiredName, bool overwrite = default, CancellationToken cancellationToken = default) - { - var file = await storage.CreateFileAsync(desiredName, GetWindowsCreationCollisionOption(overwrite)).AsTask(cancellationToken); - return new WindowsStorageFileLegacy(file); - } - - /// - public async Task CreateFolderAsync(string desiredName, bool overwrite = default, CancellationToken cancellationToken = default) - { - var folder = await storage.CreateFolderAsync(desiredName, GetWindowsCreationCollisionOption(overwrite)).AsTask(cancellationToken); - return new WindowsStorageFolderLegacy(folder); - } - - /// - public override async Task GetParentAsync(CancellationToken cancellationToken = default) - { - var parentFolder = await storage.GetParentAsync().AsTask(cancellationToken); - return new WindowsStorageFolderLegacy(parentFolder); - } - - private static StorageDeleteOption GetWindowsStorageDeleteOption(bool permanently) - { - return permanently ? StorageDeleteOption.PermanentDelete : StorageDeleteOption.Default; - } - - private static NameCollisionOption GetWindowsNameCollisionOption(bool overwrite) - { - return overwrite ? NameCollisionOption.ReplaceExisting : NameCollisionOption.GenerateUniqueName; - } - - private static CreationCollisionOption GetWindowsCreationCollisionOption(bool overwrite) - { - return overwrite ? CreationCollisionOption.ReplaceExisting : CreationCollisionOption.OpenIfExists; - } - } -} diff --git a/src/Files.App/Data/Contracts/IFileTagsService.cs b/src/Files.App/Data/Contracts/IFileTagsService.cs index 42a1a9324e88..18d532a0f4e8 100644 --- a/src/Files.App/Data/Contracts/IFileTagsService.cs +++ b/src/Files.App/Data/Contracts/IFileTagsService.cs @@ -1,8 +1,6 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.Core.Storage.Storables; - namespace Files.App.Data.Contracts { /// @@ -23,7 +21,7 @@ public interface IFileTagsService /// The tag UIDs to set. /// A that cancels this action. /// A that represents the asynchronous operation. If successful, returns true, otherwise false. - Task SetFileTagAsync(ILocatableStorable storable, string[] tagUids, CancellationToken cancellationToken = default); + Task SetFileTagAsync(IStorable storable, string[] tagUids, CancellationToken cancellationToken = default); /// /// Gets all tags which are used to tag files and folders from the database. diff --git a/src/Files.App/Data/Contracts/IImageService.cs b/src/Files.App/Data/Contracts/IImageService.cs index 2c2c92abd681..1749e489941a 100644 --- a/src/Files.App/Data/Contracts/IImageService.cs +++ b/src/Files.App/Data/Contracts/IImageService.cs @@ -1,7 +1,6 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.Core.Storage; using Files.Shared.Utils; namespace Files.App.Data.Contracts diff --git a/src/Files.App/Data/Contracts/INetworkService.cs b/src/Files.App/Data/Contracts/INetworkService.cs index 48bff58866ec..3ca39642002b 100644 --- a/src/Files.App/Data/Contracts/INetworkService.cs +++ b/src/Files.App/Data/Contracts/INetworkService.cs @@ -8,24 +8,24 @@ public interface INetworkService /// /// Gets enumerated network computers. /// - ObservableCollection Computers { get; } + ObservableCollection Computers { get; } /// /// Gets enumerated network shortcuts. /// - ObservableCollection Shortcuts { get; } + ObservableCollection Shortcuts { get; } /// /// Enumerates network computers. /// /// A collection of network computers - Task> GetComputersAsync(); + Task> GetComputersAsync(); /// /// Enumerates network shortcuts. /// /// A collection of network shortcuts - Task> GetShortcutsAsync(); + Task> GetShortcutsAsync(); /// /// Updates computers to up-to-date. @@ -50,7 +50,7 @@ public interface INetworkService /// /// An item representing the network storage device to disconnect from /// True or false to indicate status - bool DisconnectNetworkDrive(ILocatableFolder drive); + bool DisconnectNetworkDrive(IFolder drive); /// /// Authenticates the specified network share point. diff --git a/src/Files.App/Data/Contracts/IRemovableDrivesService.cs b/src/Files.App/Data/Contracts/IRemovableDrivesService.cs index 6a9d77086ff8..0b9e1b821914 100644 --- a/src/Files.App/Data/Contracts/IRemovableDrivesService.cs +++ b/src/Files.App/Data/Contracts/IRemovableDrivesService.cs @@ -1,8 +1,6 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.Core.Storage.Storables; - namespace Files.App.Data.Contracts { /// @@ -14,7 +12,7 @@ public interface IRemovableDrivesService /// Gets the primary system drive. This item is typically excluded when enumerating removable drives /// /// The location of the drive which the operating system is installed to. - Task GetPrimaryDriveAsync(); + Task GetPrimaryDriveAsync(); /// /// Creates a watcher for storage devices @@ -26,13 +24,13 @@ public interface IRemovableDrivesService /// Enumerates all removable drives /// /// A collection of removable storage devices - IAsyncEnumerable GetDrivesAsync(); + IAsyncEnumerable GetDrivesAsync(); /// /// Refreshes the properties of a drive /// /// /// - Task UpdateDrivePropertiesAsync(ILocatableFolder drive); + Task UpdateDrivePropertiesAsync(IFolder drive); } } diff --git a/src/Files.App/Data/Exceptions/FileAlreadyExistsException.cs b/src/Files.App/Data/Exceptions/FileAlreadyExistsException.cs deleted file mode 100644 index f95274d09fa4..000000000000 --- a/src/Files.App/Data/Exceptions/FileAlreadyExistsException.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.IO; - -namespace Files.App.Data.Exceptions -{ - public sealed class FileAlreadyExistsException : IOException - { - public string FileName { get; private set; } - - public FileAlreadyExistsException(string message, string fileName) : base(message) - { - FileName = fileName; - } - } -} diff --git a/src/Files.App/Data/Items/DriveItem.cs b/src/Files.App/Data/Items/DriveItem.cs index d6484b3a3e8f..eb57c2cf9461 100644 --- a/src/Files.App/Data/Items/DriveItem.cs +++ b/src/Files.App/Data/Items/DriveItem.cs @@ -11,7 +11,7 @@ namespace Files.App.Data.Items { - public sealed partial class DriveItem : ObservableObject, INavigationControlItem, ILocatableFolder + public sealed partial class DriveItem : ObservableObject, INavigationControlItem, IFolder { private BitmapImage icon; public BitmapImage Icon @@ -48,7 +48,7 @@ public bool IsNetwork => Type == DriveType.Network; public bool IsPinned - => App.QuickAccessManager.Model.PinnedFolders.Contains(path); + => App.QuickAccessManager.Model.PinnedFolders.Contains(Path); public string MaxSpaceText => MaxSpace.ToSizeString(); @@ -175,10 +175,8 @@ public bool ShowStorageSense set => SetProperty(ref showStorageSense, value); } - public string Id => DeviceID; - + public string Id => Path; public string Name => Root.DisplayName; - public object? Children => null; private object toolTip = ""; @@ -315,6 +313,12 @@ public async Task UpdatePropertiesAsync() } } + public async IAsyncEnumerable GetItemsAsync(StorableType type = StorableType.All, CancellationToken cancellationToken = default) + { + await Task.CompletedTask; + yield break; + } + public int CompareTo(INavigationControlItem other) { var result = Type.CompareTo((other as DriveItem)?.Type ?? Type); @@ -355,30 +359,6 @@ private string GetSizeString() FreeSpace.ToSizeString(), MaxSpace.ToSizeString()); } - - public Task GetFileAsync(string fileName, CancellationToken cancellationToken = default) - { - var folder = new WindowsStorageFolderLegacy(Root); - return folder.GetFileAsync(fileName, cancellationToken); - } - - public Task GetFolderAsync(string folderName, CancellationToken cancellationToken = default) - { - var folder = new WindowsStorageFolderLegacy(Root); - return folder.GetFolderAsync(folderName, cancellationToken); - } - - public IAsyncEnumerable GetItemsAsync(StorableKind kind = StorableKind.All, CancellationToken cancellationToken = default) - { - var folder = new WindowsStorageFolderLegacy(Root); - return folder.GetItemsAsync(kind, cancellationToken); - } - - public Task GetParentAsync(CancellationToken cancellationToken = default) - { - var folder = new WindowsStorageFolderLegacy(Root); - return folder.GetParentAsync(cancellationToken); - } } public enum DriveType diff --git a/src/Files.App/Data/Items/WidgetFileTagCardItem.cs b/src/Files.App/Data/Items/WidgetFileTagCardItem.cs index a777d6a6a084..b18d137ab66e 100644 --- a/src/Files.App/Data/Items/WidgetFileTagCardItem.cs +++ b/src/Files.App/Data/Items/WidgetFileTagCardItem.cs @@ -1,7 +1,6 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.Core.Storage.Extensions; using Files.Shared.Utils; using System.Windows.Input; @@ -52,7 +51,7 @@ public WidgetFileTagCardItem(IStorable associatedStorable, IImage? icon) _associatedStorable = associatedStorable; _Icon = icon; _Name = associatedStorable.Name; - _Path = associatedStorable.TryGetPath(); + _Path = associatedStorable.Id; Item = this; ClickCommand = new AsyncRelayCommand(ClickAsync); diff --git a/src/Files.App/Data/Models/DrivesViewModel.cs b/src/Files.App/Data/Models/DrivesViewModel.cs index 7d6cf1cfdb84..4e1b13cf161b 100644 --- a/src/Files.App/Data/Models/DrivesViewModel.cs +++ b/src/Files.App/Data/Models/DrivesViewModel.cs @@ -10,7 +10,7 @@ namespace Files.App.Data.Models { public sealed partial class DrivesViewModel : ObservableObject, IDisposable { - public ObservableCollection Drives + public ObservableCollection Drives { get => drives; private set => SetProperty(ref drives, value); @@ -23,7 +23,7 @@ public bool ShowUserConsentOnInit } private bool showUserConsentOnInit; - private ObservableCollection drives; + private ObservableCollection drives; private readonly IRemovableDrivesService removableDrivesService; private readonly ISizeProvider folderSizeProvider; private readonly IStorageDeviceWatcher watcher; @@ -52,7 +52,7 @@ private async void Watcher_EnumerationCompleted(object? sender, System.EventArgs private async void Watcher_DeviceModified(object? sender, string e) { - var matchingDriveEjected = Drives.FirstOrDefault(x => Path.GetFullPath(x.Path) == Path.GetFullPath(e)); + var matchingDriveEjected = Drives.FirstOrDefault(x => Path.GetFullPath(x.Id) == Path.GetFullPath(e)); if (matchingDriveEjected != null) await removableDrivesService.UpdateDrivePropertiesAsync(matchingDriveEjected); } @@ -62,7 +62,7 @@ private void Watcher_DeviceRemoved(object? sender, string e) logger.LogInformation($"Drive removed: {e}"); lock (Drives) { - var drive = Drives.FirstOrDefault(x => x.Id == e); + var drive = Drives.FirstOrDefault(x => (x as DriveItem)?.DeviceID == e); if (drive is not null) Drives.Remove(drive); } @@ -71,22 +71,22 @@ private void Watcher_DeviceRemoved(object? sender, string e) Watcher_EnumerationCompleted(null, EventArgs.Empty); } - private void Watcher_DeviceAdded(object? sender, ILocatableFolder e) + private void Watcher_DeviceAdded(object? sender, IFolder e) { lock (Drives) { // If drive already in list, remove it first. var matchingDrive = Drives.FirstOrDefault(x => - x.Id == e.Id || - string.IsNullOrEmpty(e.Path) - ? x.Path.Contains(e.Name, StringComparison.OrdinalIgnoreCase) - : Path.GetFullPath(x.Path) == Path.GetFullPath(e.Path) + (x as DriveItem)?.DeviceID == (e as DriveItem)?.DeviceID || + string.IsNullOrEmpty(e.Id) + ? x.Id.Contains(e.Name, StringComparison.OrdinalIgnoreCase) + : Path.GetFullPath(x.Id) == Path.GetFullPath(e.Id) ); if (matchingDrive is not null) Drives.Remove(matchingDrive); - logger.LogInformation($"Drive added: {e.Path}"); + logger.LogInformation($"Drive added: {e.Id}"); Drives.Add(e); } @@ -96,15 +96,18 @@ private void Watcher_DeviceAdded(object? sender, ILocatableFolder e) public async Task UpdateDrivesAsync() { Drives.Clear(); - await foreach (ILocatableFolder item in removableDrivesService.GetDrivesAsync()) + await foreach (IFolder item in removableDrivesService.GetDrivesAsync()) { Drives.AddIfNotPresent(item); } var osDrive = await removableDrivesService.GetPrimaryDriveAsync(); + var osDrivePath = osDrive.Id.EndsWith(Path.DirectorySeparatorChar) + ? osDrive.Id + : $"{osDrive.Id}{Path.DirectorySeparatorChar}"; // Show consent dialog if the OS drive could not be accessed - if (!Drives.Any(x => Path.GetFullPath(x.Path) == Path.GetFullPath(osDrive.Path))) + if (Drives.All(x => Path.GetFullPath(x.Id) != osDrivePath)) ShowUserConsentOnInit = true; if (watcher.CanBeStarted) diff --git a/src/Files.App/Data/Models/IStorageDeviceWatcher.cs b/src/Files.App/Data/Models/IStorageDeviceWatcher.cs index efa44c8132bb..626ce8855eb7 100644 --- a/src/Files.App/Data/Models/IStorageDeviceWatcher.cs +++ b/src/Files.App/Data/Models/IStorageDeviceWatcher.cs @@ -1,9 +1,6 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.Core.Storage.Storables; -using System; - namespace Files.App.Data.Models { /// @@ -14,7 +11,7 @@ public interface IStorageDeviceWatcher /// /// Fires when a new device is detected by the storage device watcher /// - event EventHandler DeviceAdded; + event EventHandler DeviceAdded; /// /// Fires when a device removal is detected by the storage device watcher diff --git a/src/Files.App/Data/Models/TaggedItemModel.cs b/src/Files.App/Data/Models/TaggedItemModel.cs index 09abd9db7935..c362df021d40 100644 --- a/src/Files.App/Data/Models/TaggedItemModel.cs +++ b/src/Files.App/Data/Models/TaggedItemModel.cs @@ -1,8 +1,6 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.Core.Storage; - namespace Files.App.Data.Models { /// diff --git a/src/Files.App/GlobalUsings.cs b/src/Files.App/GlobalUsings.cs index c762e7394c23..4a8dae28813e 100644 --- a/src/Files.App/GlobalUsings.cs +++ b/src/Files.App/GlobalUsings.cs @@ -39,7 +39,6 @@ global using global::Files.App.Data.Contexts; global using global::Files.App.Data.Contracts; global using global::Files.App.Data.EventArguments; -global using global::Files.App.Data.Exceptions; global using global::Files.App.Data.Factories; global using global::Files.App.Data.Items; global using global::Files.App.Data.Models; @@ -69,12 +68,10 @@ // Files.Core.Storage global using global::Files.Core.Storage; -global using global::Files.Core.Storage.Contracts; -global using global::Files.Core.Storage.Storables; global using global::Files.Core.Storage.Enums; global using global::Files.Core.Storage.EventArguments; global using global::Files.Core.Storage.Extensions; -global using global::Files.Core.Storage.StorageEnumeration; +global using global::OwlCore.Storage; // Files.App.Storage diff --git a/src/Files.App/Services/App/FileTagsService.cs b/src/Files.App/Services/App/FileTagsService.cs index 671e71b7df36..44bc024b673c 100644 --- a/src/Files.App/Services/App/FileTagsService.cs +++ b/src/Files.App/Services/App/FileTagsService.cs @@ -1,9 +1,6 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.Core.Storage; -using Files.Core.Storage.Extensions; -using Files.Core.Storage.Storables; using System.Runtime.CompilerServices; namespace Files.App.Services @@ -22,9 +19,9 @@ public Task IsSupportedAsync() } /// - public Task SetFileTagAsync(ILocatableStorable storable, string[] tagUids, CancellationToken cancellationToken = default) + public Task SetFileTagAsync(IStorable storable, string[] tagUids, CancellationToken cancellationToken = default) { - FileTagsHelper.WriteFileTag(storable.Path, tagUids); + FileTagsHelper.WriteFileTag(storable.Id, tagUids); return Task.FromResult(true); } diff --git a/src/Files.App/Services/Storage/StorageDevicesService.cs b/src/Files.App/Services/Storage/StorageDevicesService.cs index a13ab8d41a42..7aed69898901 100644 --- a/src/Files.App/Services/Storage/StorageDevicesService.cs +++ b/src/Files.App/Services/Storage/StorageDevicesService.cs @@ -1,11 +1,10 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.App.Storage.Storables; -using Files.Core.Storage.Storables; using Microsoft.Extensions.Logging; using System.IO; using Windows.Storage; +using OwlCore.Storage.System.IO; namespace Files.App.Services { @@ -16,7 +15,7 @@ public IStorageDeviceWatcher CreateWatcher() return new WindowsStorageDeviceWatcher(); } - public async IAsyncEnumerable GetDrivesAsync() + public async IAsyncEnumerable GetDrivesAsync() { var list = DriveInfo.GetDrives(); var pCloudDrivePath = App.AppModel.PCloudDrivePath; @@ -53,15 +52,15 @@ public async IAsyncEnumerable GetDrivesAsync() } } - public async Task GetPrimaryDriveAsync() + public async Task GetPrimaryDriveAsync() { - string cDrivePath = $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\"; - return new WindowsStorageFolderLegacy(await StorageFolder.GetFolderFromPathAsync(cDrivePath)); + var cDrivePath = $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\"; + return new SystemFolder(cDrivePath); } - public async Task UpdateDrivePropertiesAsync(ILocatableFolder drive) + public async Task UpdateDrivePropertiesAsync(IFolder drive) { - var rootModified = await FilesystemTasks.Wrap(() => StorageFolder.GetFolderFromPathAsync(drive.Path).AsTask()); + var rootModified = await FilesystemTasks.Wrap(() => StorageFolder.GetFolderFromPathAsync(drive.Id).AsTask()); if (rootModified && drive is DriveItem matchingDriveEjected) { _ = MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => diff --git a/src/Files.App/Services/Storage/StorageNetworkService.cs b/src/Files.App/Services/Storage/StorageNetworkService.cs index a3b000af1e2d..c774a410cc1b 100644 --- a/src/Files.App/Services/Storage/StorageNetworkService.cs +++ b/src/Files.App/Services/Storage/StorageNetworkService.cs @@ -19,17 +19,17 @@ public sealed partial class NetworkService : ObservableObject, INetworkService private readonly static string guid = "::{f02c1a0d-be21-4350-88b0-7367fc96ef3c}"; - private ObservableCollection _Computers = []; + private ObservableCollection _Computers = []; /// - public ObservableCollection Computers + public ObservableCollection Computers { get => _Computers; private set => SetProperty(ref _Computers, value); } - private ObservableCollection _Shortcuts = []; + private ObservableCollection _Shortcuts = []; /// - public ObservableCollection Shortcuts + public ObservableCollection Shortcuts { get => _Shortcuts; private set => SetProperty(ref _Shortcuts, value); @@ -61,7 +61,7 @@ public NetworkService() } /// - public async Task> GetComputersAsync() + public async Task> GetComputersAsync() { var result = await Win32Helper.GetShellFolderAsync(guid, false, true, 0, int.MaxValue); @@ -89,7 +89,7 @@ public async Task> GetComputersAsync() } /// - public async Task> GetShortcutsAsync() + public async Task> GetShortcutsAsync() { var networkLocations = await Win32Helper.StartSTATask(() => { @@ -141,12 +141,12 @@ public async Task> GetShortcutsAsync() /// public async Task UpdateComputersAsync() { - var unsortedDrives = new List() + var unsortedDrives = new List() { _Computers.Single(x => x is DriveItem o && o.DeviceID == "network-folder") }; - foreach (ILocatableFolder item in await GetComputersAsync()) + foreach (var item in await GetComputersAsync()) unsortedDrives.Add(item); var orderedDrives = @@ -156,16 +156,16 @@ public async Task UpdateComputersAsync() Computers.Clear(); - foreach (ILocatableFolder item in orderedDrives) + foreach (var item in orderedDrives) Computers.AddIfNotPresent(item); } /// public async Task UpdateShortcutsAsync() { - var unsortedDrives = new List(); + var unsortedDrives = new List(); - foreach (ILocatableFolder item in await GetShortcutsAsync()) + foreach (var item in await GetShortcutsAsync()) unsortedDrives.Add(item); var orderedDrives = @@ -174,16 +174,16 @@ public async Task UpdateShortcutsAsync() Shortcuts.Clear(); - foreach (ILocatableFolder item in orderedDrives) + foreach (var item in orderedDrives) Shortcuts.AddIfNotPresent(item); } /// - public bool DisconnectNetworkDrive(ILocatableFolder drive) + public bool DisconnectNetworkDrive(IFolder drive) { return PInvoke.WNetCancelConnection2W( - drive.Path.TrimEnd('\\'), + drive.Id.TrimEnd('\\'), NET_CONNECT_FLAGS.CONNECT_UPDATE_PROFILE, true) is WIN32_ERROR.NO_ERROR; diff --git a/src/Files.App/Services/Windows/WindowsJumpListService.cs b/src/Files.App/Services/Windows/WindowsJumpListService.cs index c404f7569945..f0ad7edbe964 100644 --- a/src/Files.App/Services/Windows/WindowsJumpListService.cs +++ b/src/Files.App/Services/Windows/WindowsJumpListService.cs @@ -138,7 +138,7 @@ private void AddFolder(string path, string group, JumpList instance) var drivesViewModel = Ioc.Default.GetRequiredService(); // Jumplist item argument can't end with a slash so append a character that can't exist in a directory name to support listing drives. - var drive = drivesViewModel.Drives.FirstOrDefault(drive => drive.Path == path); + var drive = drivesViewModel.Drives.FirstOrDefault(drive => drive.Id == path); if (drive is null) return; diff --git a/src/Files.App/UserControls/Pane/ShelfPane.xaml.cs b/src/Files.App/UserControls/Pane/ShelfPane.xaml.cs index baf685530c70..7e5bdaf88bd6 100644 --- a/src/Files.App/UserControls/Pane/ShelfPane.xaml.cs +++ b/src/Files.App/UserControls/Pane/ShelfPane.xaml.cs @@ -7,6 +7,7 @@ using System.Windows.Input; using Vanara.PInvoke; using Windows.ApplicationModel.DataTransfer; +using OwlCore.Storage; using WinRT; namespace Files.App.UserControls diff --git a/src/Files.App/Utils/Global/WindowsStorageDeviceWatcher.cs b/src/Files.App/Utils/Global/WindowsStorageDeviceWatcher.cs index aeb6652541ed..f80c1b922b5f 100644 --- a/src/Files.App/Utils/Global/WindowsStorageDeviceWatcher.cs +++ b/src/Files.App/Utils/Global/WindowsStorageDeviceWatcher.cs @@ -16,7 +16,7 @@ namespace Files.App.Utils { public sealed class WindowsStorageDeviceWatcher : IStorageDeviceWatcher { - public event EventHandler DeviceAdded; + public event EventHandler DeviceAdded; public event EventHandler DeviceRemoved; public event EventHandler EnumerationCompleted; public event EventHandler DeviceModified; diff --git a/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs b/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs index 5bfc5f15a7e2..a92604489b69 100644 --- a/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs @@ -74,7 +74,7 @@ public static void OpenPropertiesWindow(IShellPage associatedInstance) foreach (var drive in drives) { // Current folder is drive - if (drive.Path.Equals(folder.ItemPath)) + if (drive.Id.Equals(folder.ItemPath)) { item = drive; break; diff --git a/src/Files.App/Utils/Storage/Helpers/FilesystemTasks.cs b/src/Files.App/Utils/Storage/Helpers/FilesystemTasks.cs index 7e2b4dde526d..924845641754 100644 --- a/src/Files.App/Utils/Storage/Helpers/FilesystemTasks.cs +++ b/src/Files.App/Utils/Storage/Helpers/FilesystemTasks.cs @@ -1,7 +1,6 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.App.Data.Exceptions; using System.IO; using System.Runtime.InteropServices; using Windows.Storage; diff --git a/src/Files.App/Utils/Storage/StorageItems/FtpStorageFolder.cs b/src/Files.App/Utils/Storage/StorageItems/FtpStorageFolder.cs index a9b0ee4a60b7..2b45e64285c8 100644 --- a/src/Files.App/Utils/Storage/StorageItems/FtpStorageFolder.cs +++ b/src/Files.App/Utils/Storage/StorageItems/FtpStorageFolder.cs @@ -1,7 +1,6 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.App.Data.Exceptions; using Files.App.Storage.Storables; using FluentFTP; using System.IO; @@ -222,7 +221,7 @@ public override IAsyncOperation CreateFileAsync(string desiredN if (result is FtpStatus.Skipped) { if (options is CreationCollisionOption.FailIfExists) - throw new FileAlreadyExistsException("File already exists.", desiredName); + throw new FileAlreadyExistsException(desiredName); return null; } diff --git a/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs b/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs index 77db75ff14fe..2fec9e72573a 100644 --- a/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs @@ -512,7 +512,7 @@ private void SetDriveItem() return; } - SelectedDriveItem = drivesViewModel.Drives.FirstOrDefault(drive => drive.Path == selectedItem.ItemPath) as DriveItem; + SelectedDriveItem = drivesViewModel.Drives.FirstOrDefault(drive => drive.Id == selectedItem.ItemPath) as DriveItem; } public void Dispose() diff --git a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs index 16004ae974d7..04b3d705cdcc 100644 --- a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs @@ -16,6 +16,7 @@ using Windows.Storage; using Windows.System; using Windows.UI.Core; +using OwlCore.Storage; namespace Files.App.ViewModels.UserControls { @@ -706,7 +707,7 @@ public async void HandleItemContextInvokedAsync(object sender, ItemContextInvoke await foreach (var taggedItem in fileTagsService.GetItemsForTagAsync(tagItem.FileTag.Uid, cts.Token)) { items.Add(( - taggedItem.Storable.TryGetPath() ?? string.Empty, + taggedItem.Storable.Id, taggedItem.Storable is IFolder)); } diff --git a/src/Files.App/ViewModels/UserControls/Widgets/NetworkLocationsWidgetViewModel.cs b/src/Files.App/ViewModels/UserControls/Widgets/NetworkLocationsWidgetViewModel.cs index 17fecdd081dc..b3434bc9a600 100644 --- a/src/Files.App/ViewModels/UserControls/Widgets/NetworkLocationsWidgetViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Widgets/NetworkLocationsWidgetViewModel.cs @@ -7,6 +7,7 @@ using System.Windows.Input; using Windows.System; using Windows.UI.Core; +using OwlCore.Storage; namespace Files.App.ViewModels.UserControls.Widgets { @@ -223,7 +224,7 @@ private void ExecuteDisconnectNetworkDriveCommand(WidgetDriveCardItem? item) NetworkService.DisconnectNetworkDrive(item.Item); } - private async Task UpdateItems(ObservableCollection source) + private async Task UpdateItems(ObservableCollection source) { await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () => { diff --git a/src/Files.Core.Storage/Contracts/IFolderWatcher.cs b/src/Files.Core.Storage/Contracts/IFolderWatcher.cs deleted file mode 100644 index 8196ece960c3..000000000000 --- a/src/Files.Core.Storage/Contracts/IFolderWatcher.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2023 Files Community -// Licensed under the MIT License. - -using Files.Core.Storage.Storables; -using System.Collections.Specialized; - -namespace Files.Core.Storage.Contracts -{ - public interface IFolderWatcher : INotifyCollectionChanged - { - /// - /// Gets the folder being watched for changes. - /// - IMutableFolder TargetFolder { get; } - - /// - /// Gets invoked when an item addition is detected by the watcher - /// - event EventHandler? ItemAdded; - - /// - /// Gets invoked when an item removal is detected by the watcher - /// - event EventHandler? ItemDeleted; - - /// - /// Gets invoked when an item changing is detected by the watcher - /// - event EventHandler? ItemChanged; - - /// - /// Gets invoked when an item renaming is detected by the watcher - /// - event EventHandler? ItemRenamed; - } -} diff --git a/src/Files.Core.Storage/Extensions/StorageExtensions.File.cs b/src/Files.Core.Storage/Extensions/StorageExtensions.File.cs index e7e940ab8d22..a63151c041b9 100644 --- a/src/Files.Core.Storage/Extensions/StorageExtensions.File.cs +++ b/src/Files.Core.Storage/Extensions/StorageExtensions.File.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System.IO; +using OwlCore.Storage.System.IO; namespace Files.Core.Storage.Extensions { @@ -10,8 +11,13 @@ public static partial class StorageExtensions /// public static async Task OpenStreamAsync(this IFile file, FileAccess access, FileShare share = FileShare.None, CancellationToken cancellationToken = default) { - if (file is IFileExtended fileExtended) - return await fileExtended.OpenStreamAsync(access, share, cancellationToken); + if (file is SystemFile systemFile) + return systemFile.Info.Open(new FileStreamOptions() + { + Access = access, + Share = share, + Options = FileOptions.Asynchronous + }); // TODO: Check if the file inherits from ILockableStorable and ensure a disposable handle to it via Stream bridge return await file.OpenStreamAsync(access, cancellationToken); diff --git a/src/Files.Core.Storage/Extensions/StorageExtensions.Folder.cs b/src/Files.Core.Storage/Extensions/StorageExtensions.Folder.cs index b7800fae45d6..52c858fa17ef 100644 --- a/src/Files.Core.Storage/Extensions/StorageExtensions.Folder.cs +++ b/src/Files.Core.Storage/Extensions/StorageExtensions.Folder.cs @@ -1,30 +1,22 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using System.Runtime.CompilerServices; - namespace Files.Core.Storage.Extensions { public static partial class StorageExtensions { #region Without Result - /// If file was found, returns the requested , otherwise null. - /// - public static async Task TryGetFileAsync(this IFolder folder, string fileName, CancellationToken cancellationToken = default) + /// If file was found, returns the requested , otherwise null. + public static async Task TryGetFileByNameAsync(this IFolder folder, string fileName, CancellationToken cancellationToken = default) { try { - if (folder is IFolderExtended folderExtended) - return await folderExtended.GetFileAsync(fileName, cancellationToken); - - await foreach (var item in folder.GetFilesAsync(cancellationToken)) + return await folder.GetFirstByNameAsync(fileName, cancellationToken) switch { - if (item.Name == fileName) - return item; - } - - return null; + IChildFile childFile => childFile, + _ => throw new InvalidOperationException("The provided name does not point to a file.") + }; } catch (Exception) { @@ -33,21 +25,15 @@ public static partial class StorageExtensions } /// If folder was found, returns the requested , otherwise null. - /// - public static async Task TryGetFolderAsync(this IFolder folder, string folderName, CancellationToken cancellationToken = default) + public static async Task TryGetFolderByNameAsync(this IFolder folder, string folderName, CancellationToken cancellationToken = default) { try { - if (folder is IFolderExtended folderExtended) - return await folderExtended.GetFolderAsync(folderName, cancellationToken); - - await foreach (var item in folder.GetFoldersAsync(cancellationToken)) + return await folder.GetFirstByNameAsync(folderName, cancellationToken) switch { - if (item.Name == folderName) - return item; - } - - return null; + IChildFolder childFolder => childFolder, + _ => throw new InvalidOperationException("The provided name does not point to a folder.") + }; } catch (Exception) { @@ -84,39 +70,5 @@ public static partial class StorageExtensions } #endregion - - #region Other - - /// - /// Gets all files contained within . - /// - /// The folder to enumerate. - /// A that cancels this action. - /// Returns an async operation represented by of type of files in the directory. - public static async IAsyncEnumerable GetFilesAsync(this IFolder folder, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - await foreach (var item in folder.GetItemsAsync(StorableKind.Files, cancellationToken)) - { - if (item is IFile fileItem) - yield return fileItem; - } - } - - /// - /// Gets all folders contained within . - /// - /// The folder to enumerate. - /// A that cancels this action. - /// Returns an async operation represented by of type of folders in the directory. - public static async IAsyncEnumerable GetFoldersAsync(this IFolder folder, [EnumeratorCancellation] CancellationToken cancellationToken = default) - { - await foreach (var item in folder.GetItemsAsync(StorableKind.Files, cancellationToken)) - { - if (item is IFolder folderItem) - yield return folderItem; - } - } - - #endregion } } diff --git a/src/Files.Core.Storage/Extensions/StorageExtensions.Storable.cs b/src/Files.Core.Storage/Extensions/StorageExtensions.Storable.cs deleted file mode 100644 index 484a8a6b47f0..000000000000 --- a/src/Files.Core.Storage/Extensions/StorageExtensions.Storable.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Extensions -{ - public static partial class StorageExtensions - { - /// - /// Tries to obtain path from the storable. - /// - /// The storable item to get the path from. - /// A path pointing to the item. - public static string TryGetPath(this IStorable storable) - { - return (storable as ILocatableStorable)?.Path ?? storable.Id; - } - } -} \ No newline at end of file diff --git a/src/Files.Core.Storage/Files.Core.Storage.csproj b/src/Files.Core.Storage/Files.Core.Storage.csproj index 772751b68401..624a22e6e56c 100644 --- a/src/Files.Core.Storage/Files.Core.Storage.csproj +++ b/src/Files.Core.Storage/Files.Core.Storage.csproj @@ -10,4 +10,8 @@ win-x86;win-x64;win-arm64 + + + + diff --git a/src/Files.Core.Storage/GlobalUsings.cs b/src/Files.Core.Storage/GlobalUsings.cs index 60f311226b93..88fe6c99dc37 100644 --- a/src/Files.Core.Storage/GlobalUsings.cs +++ b/src/Files.Core.Storage/GlobalUsings.cs @@ -23,4 +23,4 @@ global using global::Files.Core.Storage.Enums; global using global::Files.Core.Storage.EventArguments; global using global::Files.Core.Storage.Extensions; -global using global::Files.Core.Storage.StorageEnumeration; +global using global::OwlCore.Storage; diff --git a/src/Files.Core.Storage/IStorageService.cs b/src/Files.Core.Storage/IStorageService.cs index cd80d01eb820..7d96e981abef 100644 --- a/src/Files.Core.Storage/IStorageService.cs +++ b/src/Files.Core.Storage/IStorageService.cs @@ -1,10 +1,6 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.Core.Storage.Storables; -using System.Threading; -using System.Threading.Tasks; - namespace Files.Core.Storage { /// diff --git a/src/Files.Core.Storage/Storables/DirectStorage/IDirectCopy.cs b/src/Files.Core.Storage/Storables/DirectStorage/IDirectCopy.cs index 2d374e6bf12e..97e91c075724 100644 --- a/src/Files.Core.Storage/Storables/DirectStorage/IDirectCopy.cs +++ b/src/Files.Core.Storage/Storables/DirectStorage/IDirectCopy.cs @@ -11,6 +11,6 @@ public interface IDirectCopy : IModifiableFolder /// /// Creates a copy of the provided storable item in this folder. /// - Task CreateCopyOfAsync(INestedStorable itemToCopy, bool overwrite = default, CancellationToken cancellationToken = default); + Task CreateCopyOfAsync(IStorableChild itemToCopy, bool overwrite = default, CancellationToken cancellationToken = default); } } diff --git a/src/Files.Core.Storage/Storables/DirectStorage/IDirectMove.cs b/src/Files.Core.Storage/Storables/DirectStorage/IDirectMove.cs index d3a5a8d4ccba..9049a09cfb04 100644 --- a/src/Files.Core.Storage/Storables/DirectStorage/IDirectMove.cs +++ b/src/Files.Core.Storage/Storables/DirectStorage/IDirectMove.cs @@ -11,6 +11,6 @@ public interface IDirectMove : IModifiableFolder /// /// Moves a storable item out of the provided folder, and into this folder. Returns the new item that resides in this folder. /// - Task MoveFromAsync(INestedStorable itemToMove, IModifiableFolder source, bool overwrite = default, CancellationToken cancellationToken = default); + Task MoveFromAsync(IStorableChild itemToMove, IModifiableFolder source, bool overwrite = default, CancellationToken cancellationToken = default); } } diff --git a/src/Files.Core.Storage/Storables/ExtendableStorage/IFileExtended.cs b/src/Files.Core.Storage/Storables/ExtendableStorage/IFileExtended.cs deleted file mode 100644 index 09acf6b6e9ad..000000000000 --- a/src/Files.Core.Storage/Storables/ExtendableStorage/IFileExtended.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using System.IO; - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a file that provides additional options for its manipulation. - /// - public interface IFileExtended : IFile - { - /// The file sharing flags that specify access other processes have to the file. - /// - Task OpenStreamAsync(FileAccess access, FileShare share, CancellationToken cancellationToken = default); - } -} diff --git a/src/Files.Core.Storage/Storables/ExtendableStorage/IFolderExtended.cs b/src/Files.Core.Storage/Storables/ExtendableStorage/IFolderExtended.cs deleted file mode 100644 index 393ad0c770b8..000000000000 --- a/src/Files.Core.Storage/Storables/ExtendableStorage/IFolderExtended.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Extends existing interface with additional functionality. - /// - public interface IFolderExtended : IFolder - { - /// - /// Gets a file in the current directory by name. - /// - /// The name of the file. - /// A that cancels this action. - /// A that represents the asynchronous operation. Value is , otherwise an exception is thrown. - Task GetFileAsync(string fileName, CancellationToken cancellationToken = default); - - /// - /// Gets a folder in the current directory by name. - /// - /// The name of the folder. - /// A that cancels this action. - /// A that represents the asynchronous operation. If folder is found and access is granted, returns otherwise null. - Task GetFolderAsync(string folderName, CancellationToken cancellationToken = default); - } -} diff --git a/src/Files.Core.Storage/Storables/IFile.cs b/src/Files.Core.Storage/Storables/IFile.cs deleted file mode 100644 index eb25a74e50c4..000000000000 --- a/src/Files.Core.Storage/Storables/IFile.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using System.IO; - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a file on the file system. - /// - public interface IFile : IStorable - { - /// - /// Opens the file and returns a instance to it. - /// - /// The file access to open the file with. - /// A that cancels this action. - /// A that represents the asynchronous operation. Value is , otherwise an exception is thrown. - Task OpenStreamAsync(FileAccess access, CancellationToken cancellationToken = default); - } -} diff --git a/src/Files.Core.Storage/Storables/IFolder.cs b/src/Files.Core.Storage/Storables/IFolder.cs deleted file mode 100644 index b94156bdb1af..000000000000 --- a/src/Files.Core.Storage/Storables/IFolder.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a folder on the file system. - /// - public interface IFolder : IStorable - { - /// - /// Gets all items of this directory. - /// - /// The type of items to enumerate. - /// A that cancels this action. - /// Returns an async operation represented by of type of items in the directory. - IAsyncEnumerable GetItemsAsync(StorableKind kind = StorableKind.All, CancellationToken cancellationToken = default); - } -} diff --git a/src/Files.Core.Storage/Storables/IStorable.cs b/src/Files.Core.Storage/Storables/IStorable.cs deleted file mode 100644 index 5c9a53d9001f..000000000000 --- a/src/Files.Core.Storage/Storables/IStorable.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a base storage object on the file system. - /// - public interface IStorable - { - /// - /// Gets the unique and consistent identifier for this file or folder. - /// - public string Id { get; } - - /// - /// Gets the name of the storage object. - /// - string Name { get; } - } -} diff --git a/src/Files.Core.Storage/Storables/LocatableStorage/ILocatableFile.cs b/src/Files.Core.Storage/Storables/LocatableStorage/ILocatableFile.cs deleted file mode 100644 index 6795cd6671ea..000000000000 --- a/src/Files.Core.Storage/Storables/LocatableStorage/ILocatableFile.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a file that resides within a folder structure. - /// - public interface ILocatableFile : IFile, ILocatableStorable - { - } -} diff --git a/src/Files.Core.Storage/Storables/LocatableStorage/ILocatableFolder.cs b/src/Files.Core.Storage/Storables/LocatableStorage/ILocatableFolder.cs deleted file mode 100644 index e2fc7fe73f3c..000000000000 --- a/src/Files.Core.Storage/Storables/LocatableStorage/ILocatableFolder.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a folder that resides within a folder structure. - /// - public interface ILocatableFolder : IFolder, ILocatableStorable - { - } -} diff --git a/src/Files.Core.Storage/Storables/LocatableStorage/ILocatableStorable.cs b/src/Files.Core.Storage/Storables/LocatableStorage/ILocatableStorable.cs deleted file mode 100644 index 8a6412283d99..000000000000 --- a/src/Files.Core.Storage/Storables/LocatableStorage/ILocatableStorable.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a file or folder that resides within a folder structure. - /// - public interface ILocatableStorable : IStorable - { - /// - /// Gets the path where the item resides. - /// - string Path { get; } - } -} diff --git a/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableFile.cs b/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableFile.cs deleted file mode 100644 index 93959aae74ea..000000000000 --- a/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableFile.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a file that can be modified. - /// - public interface IModifiableFile : IFile, IModifiableStorable - { - } -} diff --git a/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableFolder.cs b/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableFolder.cs deleted file mode 100644 index d53dbe677a27..000000000000 --- a/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableFolder.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a folder that can be modified. - /// - public interface IModifiableFolder : IFolder, IModifiableStorable - { - /// - /// Deletes the provided storable item from this folder. - /// - Task DeleteAsync(INestedStorable item, bool permanently = default, CancellationToken cancellationToken = default); - - /// - /// Creates a new file with the desired name inside this folder. - /// - Task CreateFileAsync(string desiredName, bool overwrite = default, CancellationToken cancellationToken = default); - - /// - /// Creates a new folder with the desired name inside this folder. - /// - Task CreateFolderAsync(string desiredName, bool overwrite = default, CancellationToken cancellationToken = default); - } -} diff --git a/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableStorable.cs b/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableStorable.cs deleted file mode 100644 index 90efa7f9f814..000000000000 --- a/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableStorable.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a storage object that can be modified. - /// - public interface IModifiableStorable : IStorable - { - } -} diff --git a/src/Files.Core.Storage/Storables/MutableStorage/IMutableFolder.cs b/src/Files.Core.Storage/Storables/MutableStorage/IMutableFolder.cs deleted file mode 100644 index 70410912840c..000000000000 --- a/src/Files.Core.Storage/Storables/MutableStorage/IMutableFolder.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a folder whose content can change. - /// - public interface IMutableFolder - { - } -} diff --git a/src/Files.Core.Storage/Storables/NestedStorage/INestedFile.cs b/src/Files.Core.Storage/Storables/NestedStorage/INestedFile.cs deleted file mode 100644 index b6120f56c388..000000000000 --- a/src/Files.Core.Storage/Storables/NestedStorage/INestedFile.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a file that resides within a traversable folder structure. - /// - public interface INestedFile : IFile, INestedStorable - { - } -} diff --git a/src/Files.Core.Storage/Storables/NestedStorage/INestedFolder.cs b/src/Files.Core.Storage/Storables/NestedStorage/INestedFolder.cs deleted file mode 100644 index dda005da8342..000000000000 --- a/src/Files.Core.Storage/Storables/NestedStorage/INestedFolder.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a folder that resides within a traversable folder structure. - /// - public interface INestedFolder : IFolder, INestedStorable - { - } -} diff --git a/src/Files.Core.Storage/Storables/NestedStorage/INestedStorable.cs b/src/Files.Core.Storage/Storables/NestedStorage/INestedStorable.cs deleted file mode 100644 index f0beec81a8f7..000000000000 --- a/src/Files.Core.Storage/Storables/NestedStorage/INestedStorable.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.Storables -{ - /// - /// Represents a storable resource that resides within a traversable folder structure. - /// - public interface INestedStorable : IStorable - { - /// - /// Gets the containing folder for this item, if any. - /// - Task GetParentAsync(CancellationToken cancellationToken = default); - } -} diff --git a/src/Files.Core.Storage/StorageEnumeration/IStorageEnumerator.cs b/src/Files.Core.Storage/StorageEnumeration/IStorageEnumerator.cs deleted file mode 100644 index ff4d09398a02..000000000000 --- a/src/Files.Core.Storage/StorageEnumeration/IStorageEnumerator.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.Core.Storage.StorageEnumeration -{ - /// - /// Enumerates storage objects of a given directory. - /// - /// This interface can be implemented to provide complex enumeration of directories as well as being a substitute for built-in enumeration. - /// - public interface IStorageEnumerator : IDisposable - { - /// - /// Gets the folder where enumeration takes place. - /// - IFolder SourceFolder { get; } - - /// - /// Enumerates the for files. - /// - /// A that cancels this action. - /// Returns an async operation represented by of type of all files discovered by the enumerator. - IAsyncEnumerable EnumerateFilesAsync(CancellationToken cancellationToken = default); - - /// - /// Enumerates the for folders. - /// - /// A that cancels this action. - /// Returns an async operation represented by of type of all folders discovered by the enumerator. - IAsyncEnumerable EnumerateFoldersAsync(CancellationToken cancellationToken = default); - - /// - /// Enumerates the for items. - /// - /// A that cancels this action. - /// Returns an async operation represented by of type of all items discovered by the enumerator. - IAsyncEnumerable EnumerateStorageAsync(CancellationToken cancellationToken = default); - } -}