From fdada996c3654cac0c68f4e18b3b613115d3f3fa Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Sat, 5 Oct 2024 07:08:05 +0000 Subject: [PATCH 1/9] Init --- .../Files.App.Storage.csproj | 12 +- .../{FtpStorage => Ftp}/FtpHelpers.cs | 0 .../{FtpStorage => Ftp}/FtpManager.cs | 0 .../{FtpStorage => Ftp}/FtpStorable.cs | 0 .../{FtpStorage => Ftp}/FtpStorageFile.cs | 0 .../{FtpStorage => Ftp}/FtpStorageFolder.cs | 0 .../{FtpStorage => Ftp}/FtpStorageService.cs | 0 .../Storables/Native/NativeFile.cs | 14 ++ .../Storables/Native/NativeFolder.cs | 15 ++ .../Storables/Native/NativeStorable.cs | 14 ++ .../NativeFileOld.cs} | 6 +- .../NativeFolderOld.cs} | 22 +-- .../NativeStorableOld.cs} | 6 +- .../NativeStorageService.cs | 6 +- .../WindowsStorage/WindowsStorable.cs | 35 ---- .../WindowsStorage/WindowsStorageFile.cs | 69 -------- .../WindowsStorage/WindowsStorageFolder.cs | 157 ------------------ .../WindowsStorage/WindowsStorageService.cs | 25 --- 18 files changed, 67 insertions(+), 314 deletions(-) rename src/Files.App.Storage/Storables/{FtpStorage => Ftp}/FtpHelpers.cs (100%) rename src/Files.App.Storage/Storables/{FtpStorage => Ftp}/FtpManager.cs (100%) rename src/Files.App.Storage/Storables/{FtpStorage => Ftp}/FtpStorable.cs (100%) rename src/Files.App.Storage/Storables/{FtpStorage => Ftp}/FtpStorageFile.cs (100%) rename src/Files.App.Storage/Storables/{FtpStorage => Ftp}/FtpStorageFolder.cs (100%) rename src/Files.App.Storage/Storables/{FtpStorage => Ftp}/FtpStorageService.cs (100%) create mode 100644 src/Files.App.Storage/Storables/Native/NativeFile.cs create mode 100644 src/Files.App.Storage/Storables/Native/NativeFolder.cs create mode 100644 src/Files.App.Storage/Storables/Native/NativeStorable.cs rename src/Files.App.Storage/Storables/{NativeStorage/NativeFile.cs => NativeOld/NativeFileOld.cs} (76%) rename src/Files.App.Storage/Storables/{NativeStorage/NativeFolder.cs => NativeOld/NativeFolderOld.cs} (86%) rename src/Files.App.Storage/Storables/{NativeStorage/NativeStorable.cs => NativeOld/NativeStorableOld.cs} (85%) rename src/Files.App.Storage/Storables/{NativeStorage => NativeOld}/NativeStorageService.cs (87%) delete mode 100644 src/Files.App.Storage/Storables/WindowsStorage/WindowsStorable.cs delete mode 100644 src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageFile.cs delete mode 100644 src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageFolder.cs delete mode 100644 src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageService.cs diff --git a/src/Files.App.Storage/Files.App.Storage.csproj b/src/Files.App.Storage/Files.App.Storage.csproj index c08d08cbe3f0..821916c64f24 100644 --- a/src/Files.App.Storage/Files.App.Storage.csproj +++ b/src/Files.App.Storage/Files.App.Storage.csproj @@ -9,20 +9,16 @@ Debug;Release;Stable;Preview;Store x86;x64;arm64 win-x86;win-x64;win-arm64 + TRACE;DEBUG;NETFX_CORE + TRACE;RELEASE;NETFX_CORE + true + - - TRACE;DEBUG;NETFX_CORE - - - TRACE;RELEASE;NETFX_CORE - true - - diff --git a/src/Files.App.Storage/Storables/FtpStorage/FtpHelpers.cs b/src/Files.App.Storage/Storables/Ftp/FtpHelpers.cs similarity index 100% rename from src/Files.App.Storage/Storables/FtpStorage/FtpHelpers.cs rename to src/Files.App.Storage/Storables/Ftp/FtpHelpers.cs diff --git a/src/Files.App.Storage/Storables/FtpStorage/FtpManager.cs b/src/Files.App.Storage/Storables/Ftp/FtpManager.cs similarity index 100% rename from src/Files.App.Storage/Storables/FtpStorage/FtpManager.cs rename to src/Files.App.Storage/Storables/Ftp/FtpManager.cs diff --git a/src/Files.App.Storage/Storables/FtpStorage/FtpStorable.cs b/src/Files.App.Storage/Storables/Ftp/FtpStorable.cs similarity index 100% rename from src/Files.App.Storage/Storables/FtpStorage/FtpStorable.cs rename to src/Files.App.Storage/Storables/Ftp/FtpStorable.cs diff --git a/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFile.cs b/src/Files.App.Storage/Storables/Ftp/FtpStorageFile.cs similarity index 100% rename from src/Files.App.Storage/Storables/FtpStorage/FtpStorageFile.cs rename to src/Files.App.Storage/Storables/Ftp/FtpStorageFile.cs diff --git a/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFolder.cs b/src/Files.App.Storage/Storables/Ftp/FtpStorageFolder.cs similarity index 100% rename from src/Files.App.Storage/Storables/FtpStorage/FtpStorageFolder.cs rename to src/Files.App.Storage/Storables/Ftp/FtpStorageFolder.cs diff --git a/src/Files.App.Storage/Storables/FtpStorage/FtpStorageService.cs b/src/Files.App.Storage/Storables/Ftp/FtpStorageService.cs similarity index 100% rename from src/Files.App.Storage/Storables/FtpStorage/FtpStorageService.cs rename to src/Files.App.Storage/Storables/Ftp/FtpStorageService.cs diff --git a/src/Files.App.Storage/Storables/Native/NativeFile.cs b/src/Files.App.Storage/Storables/Native/NativeFile.cs new file mode 100644 index 000000000000..886ab6d4e81e --- /dev/null +++ b/src/Files.App.Storage/Storables/Native/NativeFile.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2024 Files Community +// Licensed under the MIT License. See the LICENSE. + +using System.IO; + +namespace Files.App.Storage.Storables +{ + /// + /// Represents a file object that is natively supported by Windows Shell API. + /// + public class NativeFile : NativeStorable + { + } +} diff --git a/src/Files.App.Storage/Storables/Native/NativeFolder.cs b/src/Files.App.Storage/Storables/Native/NativeFolder.cs new file mode 100644 index 000000000000..02e14394fb67 --- /dev/null +++ b/src/Files.App.Storage/Storables/Native/NativeFolder.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2024 Files Community +// Licensed under the MIT License. See the LICENSE. + +using System.IO; +using System.Runtime.CompilerServices; + +namespace Files.App.Storage.Storables +{ + /// + /// Represents a folder object that is natively supported by Windows Shell API. + /// + public class NativeFolder : NativeStorable + { + } +} diff --git a/src/Files.App.Storage/Storables/Native/NativeStorable.cs b/src/Files.App.Storage/Storables/Native/NativeStorable.cs new file mode 100644 index 000000000000..2ceb559c2908 --- /dev/null +++ b/src/Files.App.Storage/Storables/Native/NativeStorable.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2024 Files Community +// Licensed under the MIT License. See the LICENSE. + +using System.IO; + +namespace Files.App.Storage.Storables +{ + /// + /// Represents a storable that is natively supported by Windows Shell API. + /// + public abstract class NativeStorable + { + } +} diff --git a/src/Files.App.Storage/Storables/NativeStorage/NativeFile.cs b/src/Files.App.Storage/Storables/NativeOld/NativeFileOld.cs similarity index 76% rename from src/Files.App.Storage/Storables/NativeStorage/NativeFile.cs rename to src/Files.App.Storage/Storables/NativeOld/NativeFileOld.cs index d930426f77b7..8f0730462fc7 100644 --- a/src/Files.App.Storage/Storables/NativeStorage/NativeFile.cs +++ b/src/Files.App.Storage/Storables/NativeOld/NativeFileOld.cs @@ -6,14 +6,14 @@ namespace Files.App.Storage.Storables { /// - public class NativeFile : NativeStorable, ILocatableFile, IModifiableFile, IFileExtended, INestedFile + public class NativeFileOld : NativeStorableOld, ILocatableFile, IModifiableFile, IFileExtended, INestedFile { - public NativeFile(FileInfo fileInfo, string? name = null) + public NativeFileOld(FileInfo fileInfo, string? name = null) : base(fileInfo, name) { } - public NativeFile(string path, string? name = null) + public NativeFileOld(string path, string? name = null) : this(new FileInfo(path), name) { } diff --git a/src/Files.App.Storage/Storables/NativeStorage/NativeFolder.cs b/src/Files.App.Storage/Storables/NativeOld/NativeFolderOld.cs similarity index 86% rename from src/Files.App.Storage/Storables/NativeStorage/NativeFolder.cs rename to src/Files.App.Storage/Storables/NativeOld/NativeFolderOld.cs index e364cfb3b8c2..cdddc27d0e3c 100644 --- a/src/Files.App.Storage/Storables/NativeStorage/NativeFolder.cs +++ b/src/Files.App.Storage/Storables/NativeOld/NativeFolderOld.cs @@ -7,14 +7,14 @@ namespace Files.App.Storage.Storables { /// - public class NativeFolder : NativeStorable, ILocatableFolder, IModifiableFolder, IMutableFolder, IFolderExtended, INestedFolder, IDirectCopy, IDirectMove + public class NativeFolderOld : NativeStorableOld, ILocatableFolder, IModifiableFolder, IMutableFolder, IFolderExtended, INestedFolder, IDirectCopy, IDirectMove { - public NativeFolder(DirectoryInfo directoryInfo, string? name = null) + public NativeFolderOld(DirectoryInfo directoryInfo, string? name = null) : base(directoryInfo, name) { } - public NativeFolder(string path, string? name = null) + public NativeFolderOld(string path, string? name = null) : this(new DirectoryInfo(path), name) { } @@ -27,7 +27,7 @@ public virtual Task GetFileAsync(string fileName, CancellationToken if (!File.Exists(path)) throw new FileNotFoundException(); - return Task.FromResult(new NativeFile(path)); + return Task.FromResult(new NativeFileOld(path)); } /// @@ -46,21 +46,21 @@ public virtual async IAsyncEnumerable GetItemsAsync(StorableKin if (kind == StorableKind.Files) { foreach (var item in Directory.EnumerateFiles(Path)) - yield return new NativeFile(item); + yield return new NativeFileOld(item); } else if (kind == StorableKind.Folders) { foreach (var item in Directory.EnumerateDirectories(Path)) - yield return new NativeFolder(item); + yield return new NativeFolderOld(item); } else { foreach (var item in Directory.EnumerateFileSystemEntries(Path)) { if (File.Exists(item)) - yield return new NativeFile(item); + yield return new NativeFileOld(item); else - yield return new NativeFolder(item); + yield return new NativeFolderOld(item); } } @@ -96,7 +96,7 @@ public virtual async Task CreateCopyOfAsync(INestedStorable ite var newPath = System.IO.Path.Combine(Path, itemToCopy.Name); File.Copy(sourceLocatableFile.Path, newPath, overwrite); - return new NativeFile(newPath); + return new NativeFileOld(newPath); } var copiedFile = await CreateFileAsync(itemToCopy.Name, overwrite, cancellationToken); @@ -124,7 +124,7 @@ public virtual async Task MoveFromAsync(INestedStorable itemToM var newPath = System.IO.Path.Combine(Path, itemToMove.Name); File.Move(sourceLocatableFile.Path, newPath, overwrite); - return new NativeFile(newPath); + return new NativeFileOld(newPath); } else { @@ -161,7 +161,7 @@ public virtual Task CreateFolderAsync(string desiredName, bool ov Directory.Delete(path, true); _ = Directory.CreateDirectory(path); - return Task.FromResult(new NativeFolder(path)); + return Task.FromResult(new NativeFolderOld(path)); } } } diff --git a/src/Files.App.Storage/Storables/NativeStorage/NativeStorable.cs b/src/Files.App.Storage/Storables/NativeOld/NativeStorableOld.cs similarity index 85% rename from src/Files.App.Storage/Storables/NativeStorage/NativeStorable.cs rename to src/Files.App.Storage/Storables/NativeOld/NativeStorableOld.cs index 1aab43b33a5a..fbdef44138f3 100644 --- a/src/Files.App.Storage/Storables/NativeStorage/NativeStorable.cs +++ b/src/Files.App.Storage/Storables/NativeOld/NativeStorableOld.cs @@ -6,7 +6,7 @@ namespace Files.App.Storage.Storables { /// - public abstract class NativeStorable : ILocatableStorable, INestedStorable + public abstract class NativeStorableOld : ILocatableStorable, INestedStorable where TStorage : FileSystemInfo { protected readonly TStorage storage; @@ -20,7 +20,7 @@ public abstract class NativeStorable : ILocatableStorable, INestedStor /// public virtual string Id { get; } - protected NativeStorable(TStorage storage, string? name = null) + protected NativeStorableOld(TStorage storage, string? name = null) { this.storage = storage; Path = storage.FullName; @@ -35,7 +35,7 @@ protected NativeStorable(TStorage storage, string? name = null) if (parent is null) return Task.FromResult(null); - return Task.FromResult(new NativeFolder(parent)); + return Task.FromResult(new NativeFolderOld(parent)); } /// diff --git a/src/Files.App.Storage/Storables/NativeStorage/NativeStorageService.cs b/src/Files.App.Storage/Storables/NativeOld/NativeStorageService.cs similarity index 87% rename from src/Files.App.Storage/Storables/NativeStorage/NativeStorageService.cs rename to src/Files.App.Storage/Storables/NativeOld/NativeStorageService.cs index a94d4f2b801a..e2af4cca0a8c 100644 --- a/src/Files.App.Storage/Storables/NativeStorage/NativeStorageService.cs +++ b/src/Files.App.Storage/Storables/NativeOld/NativeStorageService.cs @@ -16,7 +16,7 @@ public Task GetFileAsync(string id, CancellationToken cancellationToken = if (!File.Exists(id)) throw new FileNotFoundException(); - return Task.FromResult(new NativeFile(id)); + return Task.FromResult(new NativeFileOld(id)); } /// @@ -29,10 +29,10 @@ public async Task GetFolderAsync(string id, CancellationToken cancellat if (PathHelpers.IsSpecialFolder(id)) { var storageFolder = await TryGetStorageFolderAsync(id); - return new NativeFolder(id, storageFolder?.DisplayName); + return new NativeFolderOld(id, storageFolder?.DisplayName); } - return new NativeFolder(id); + return new NativeFolderOld(id); async Task TryGetStorageFolderAsync(string path) { diff --git a/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorable.cs b/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorable.cs deleted file mode 100644 index f730db243c85..000000000000 --- a/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorable.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2024 Files Community -// Licensed under the MIT License. See the LICENSE. - -using Files.Shared.Helpers; -using Windows.Storage; - -namespace Files.App.Storage.Storables -{ - /// - public abstract class WindowsStorable : 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 WindowsStorable(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/WindowsStorage/WindowsStorageFile.cs b/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageFile.cs deleted file mode 100644 index 15d856a34fe3..000000000000 --- a/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageFile.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2024 Files Community -// Licensed under the MIT License. See the LICENSE. - -using System.IO; -using Windows.Storage; - -namespace Files.App.Storage.Storables -{ - /// - public sealed class WindowsStorageFile : WindowsStorable, ILocatableFile, IModifiableFile, IFileExtended, INestedFile - { - public WindowsStorageFile(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 WindowsStorageFolder(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/WindowsStorage/WindowsStorageFolder.cs b/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageFolder.cs deleted file mode 100644 index e2467acc9ae9..000000000000 --- a/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageFolder.cs +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (c) 2024 Files Community -// Licensed under the MIT License. See the LICENSE. - -using System.Runtime.CompilerServices; -using Windows.Storage; - -namespace Files.App.Storage.Storables -{ - /// - public sealed class WindowsStorageFolder : WindowsStorable, ILocatableFolder, IFolderExtended, INestedFolder, IDirectCopy, IDirectMove - { - // TODO: Implement IMutableFolder - - public WindowsStorageFolder(StorageFolder storage) - : base(storage) - { - } - - /// - public async Task GetFileAsync(string fileName, CancellationToken cancellationToken = default) - { - var file = await storage.GetFileAsync(fileName).AsTask(cancellationToken); - return new WindowsStorageFile(file); - } - - /// - public async Task GetFolderAsync(string folderName, CancellationToken cancellationToken = default) - { - var folder = await storage.GetFolderAsync(folderName).AsTask(cancellationToken); - return new WindowsStorageFolder(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 WindowsStorageFile(item); - } - - break; - } - - case StorableKind.Folders: - { - var folders = await storage.GetFoldersAsync().AsTask(cancellationToken); - foreach (var item in folders) - { - yield return new WindowsStorageFolder(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 WindowsStorageFile(storageFile); - - if (item is StorageFolder storageFolder) - yield return new WindowsStorageFolder(storageFolder); - } - - break; - } - - default: - yield break; - } - } - - /// - public Task DeleteAsync(INestedStorable item, bool permanently = default, CancellationToken cancellationToken = default) - { - return item switch - { - WindowsStorable storageFile => storageFile.storage - .DeleteAsync(GetWindowsStorageDeleteOption(permanently)) - .AsTask(cancellationToken), - - WindowsStorable 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 WindowsStorable sourceFile) - { - var copiedFile = await sourceFile.storage.CopyAsync(storage, itemToCopy.Name, GetWindowsNameCollisionOption(overwrite)).AsTask(cancellationToken); - return new WindowsStorageFile(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 WindowsStorable sourceFile) - { - await sourceFile.storage.MoveAsync(storage, itemToMove.Name, GetWindowsNameCollisionOption(overwrite)).AsTask(cancellationToken); - return new WindowsStorageFile(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 WindowsStorageFile(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 WindowsStorageFolder(folder); - } - - /// - public override async Task GetParentAsync(CancellationToken cancellationToken = default) - { - var parentFolder = await storage.GetParentAsync().AsTask(cancellationToken); - return new WindowsStorageFolder(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.Storage/Storables/WindowsStorage/WindowsStorageService.cs b/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageService.cs deleted file mode 100644 index f642a7aed968..000000000000 --- a/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageService.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2024 Files Community -// Licensed under the MIT License. See the LICENSE. - -using Windows.Storage; - -namespace Files.App.Storage.Storables -{ - /// - internal sealed class WindowsStorageService : IStorageService - { - /// - public async Task GetFileAsync(string id, CancellationToken cancellationToken = default) - { - var file = await StorageFile.GetFileFromPathAsync(id).AsTask(cancellationToken); - return new WindowsStorageFile(file); - } - - /// - public async Task GetFolderAsync(string id, CancellationToken cancellationToken = default) - { - var folder = await StorageFolder.GetFolderFromPathAsync(id).AsTask(cancellationToken); - return new WindowsStorageFolder(folder); - } - } -} From abf98739386be7374a16a0d07714c794e04324ef Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Sat, 5 Oct 2024 08:45:17 +0000 Subject: [PATCH 2/9] Created the new NativeStorable --- .../Storables/Native/INativeStorable.cs | 18 ++++ .../Storables/Native/NativeFile.cs | 4 +- .../Storables/Native/NativeFolder.cs | 31 +++++- .../Storables/Native/NativeStorable.cs | 97 ++++++++++++++++++- 4 files changed, 141 insertions(+), 9 deletions(-) create mode 100644 src/Files.App.Storage/Storables/Native/INativeStorable.cs diff --git a/src/Files.App.Storage/Storables/Native/INativeStorable.cs b/src/Files.App.Storage/Storables/Native/INativeStorable.cs new file mode 100644 index 000000000000..69287fa6996a --- /dev/null +++ b/src/Files.App.Storage/Storables/Native/INativeStorable.cs @@ -0,0 +1,18 @@ +// Copyright (c) 2024 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.Storage.Storables +{ + /// + /// Represents a file object that is natively supported by Windows Shell API. + /// + public class INativeStorable : NativeStorable + { + /// + /// Get a property value from this . + /// + /// The property ID (e.g. "System.Image.Dimensions"). + /// Returns a valid value formatted with string; otherwise, returns . + public string GetPropertyAsync(string id); + } +} diff --git a/src/Files.App.Storage/Storables/Native/NativeFile.cs b/src/Files.App.Storage/Storables/Native/NativeFile.cs index 886ab6d4e81e..81dba251f5da 100644 --- a/src/Files.App.Storage/Storables/Native/NativeFile.cs +++ b/src/Files.App.Storage/Storables/Native/NativeFile.cs @@ -1,14 +1,12 @@ // Copyright (c) 2024 Files Community // Licensed under the MIT License. See the LICENSE. -using System.IO; - namespace Files.App.Storage.Storables { /// /// Represents a file object that is natively supported by Windows Shell API. /// - public class NativeFile : NativeStorable + public class NativeFile : NativeStorable/*, IFile*/ { } } diff --git a/src/Files.App.Storage/Storables/Native/NativeFolder.cs b/src/Files.App.Storage/Storables/Native/NativeFolder.cs index 02e14394fb67..0a1eeffe7e71 100644 --- a/src/Files.App.Storage/Storables/Native/NativeFolder.cs +++ b/src/Files.App.Storage/Storables/Native/NativeFolder.cs @@ -1,15 +1,38 @@ // Copyright (c) 2024 Files Community // Licensed under the MIT License. See the LICENSE. -using System.IO; -using System.Runtime.CompilerServices; - namespace Files.App.Storage.Storables { /// /// Represents a folder object that is natively supported by Windows Shell API. /// - public class NativeFolder : NativeStorable + public class NativeFolder : NativeStorable/*, IFolder*/ { + public async IAsyncEnumerable GetChildrenAsync() + { + foreach (var storable in GetChildren()) + { + await Task.Yield(); + + yield return storable; + } + + unsafe IEnumerable GetChildren() + { + using ComPtr pEnumShellItems = default; + fixed (Guid* pBHID = PInvoke.BHID_EnumItems) + { + hr = pRecycleBinFolderShellItem.Get()->BindToHandler( + null, + pBHID, + (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IEnumShellItems.Guid)), + (void**)pEnumShellItems.GetAddressOf()); + + ComPtr pShellItem = default; + while (pEnumShellItems.Get()->Next(1, pShellItem.GetAddressOf()) == HRESULT.S_OK) + yield return NativeStorable(pShellItem); + } + } + } } } diff --git a/src/Files.App.Storage/Storables/Native/NativeStorable.cs b/src/Files.App.Storage/Storables/Native/NativeStorable.cs index 2ceb559c2908..50206bedc907 100644 --- a/src/Files.App.Storage/Storables/Native/NativeStorable.cs +++ b/src/Files.App.Storage/Storables/Native/NativeStorable.cs @@ -1,14 +1,107 @@ // Copyright (c) 2024 Files Community // Licensed under the MIT License. See the LICENSE. -using System.IO; +using System.Runtime.InteropServices; +using Windows.Win32; +using Windows.Win32.Foundation; +using Windows.Win32.System.Com; +using Windows.Win32.UI.Shell; namespace Files.App.Storage.Storables { /// /// Represents a storable that is natively supported by Windows Shell API. /// - public abstract class NativeStorable + public abstract class NativeStorable, INativeStorable { + /// + /// + /// This must be a path that can be parsed by SHCreateItemFromParsingName. + /// + public string Path { get; protected set; } + + /// + /// + /// This must be a path that can be parsed by SHParseDisplayName. + /// + public string Name { get; protected set; } + + /// + public string Id { get; protected set; } // Won't use + + protected ComPtr m_pShellItem { get; private set; } + + /// + /// Initializes an instance of class. + /// + /// Win32 file namespace, shell namespace, or UNC path. + public unsafe NativeFile(string path) + { + HRESULT hr = PInvoke.SHCreateItemFromParsingName( + path, + null, + (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IShellItem.Guid)), + (void**)m_pShellItem.GetAddressOf()); + } + + /// + /// Initializes an instance of class. + /// + /// An instance of GUID that represents a shell folder. + public unsafe NativeStorable(Guid shellGuid) + { + HRESULT hr = default; + + // For known folders + fixed (Guid* pFolderId = shellGuid) + { + hr = PInvoke.SHGetKnownFolderItem( + pFolderId, + KNOWN_FOLDER_FLAG.KF_FLAG_DEFAULT, + HANDLE.Null, + (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IShellItem.Guid)), + (void**)m_pShellItem.GetAddressOf()); + } + + if (hr == HRESULT.S_OK) + return; + + string path = $"Shell:::{shellGuid.ToString("B")}"; + + hr = PInvoke.SHCreateItemFromParsingName( + path, + null, + (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IShellItem.Guid)), + (void**)m_pShellItem.GetAddressOf()); + } + + /// + /// Initializes an instance of class. + /// + /// An instance of . + public NativeStorable(ComPtr pShellItem) + { + m_pShellItem = pShellItem; + } + + /// + public string GetPropertyAsync(string id) + { + using ComPtr pShellItem2 = default; + hr = pShellItem.Get()->QueryInterface( + (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IShellItem2.Guid)), + (void**)pShellItem2.GetAddressOf()); + + hr = PInvoke.PSGetPropertyKeyFromName( + id, + out var propertyKey); + + using ComHeapPtr pPropertyValue; + hr = pShellItem2.Get()->GetString( + propertyKey, + (void**)pPropertyValue.GetAddressOf()); + + return szPropertyValue.Get()->ToString(); + } } } From 4c2d8be0f597cc249eb12918b56952913c9ba500 Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Sun, 6 Oct 2024 00:38:38 +0900 Subject: [PATCH 3/9] Update NativeStorable.cs --- src/Files.App.Storage/Storables/Native/NativeStorable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App.Storage/Storables/Native/NativeStorable.cs b/src/Files.App.Storage/Storables/Native/NativeStorable.cs index 50206bedc907..0e2dcda57208 100644 --- a/src/Files.App.Storage/Storables/Native/NativeStorable.cs +++ b/src/Files.App.Storage/Storables/Native/NativeStorable.cs @@ -12,7 +12,7 @@ namespace Files.App.Storage.Storables /// /// Represents a storable that is natively supported by Windows Shell API. /// - public abstract class NativeStorable, INativeStorable + public abstract class NativeStorable : INativeStorable { /// /// From 8cbb0b4144cfcadc59d77eaa740dd9952f6cc6fb Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Sun, 6 Oct 2024 00:44:56 +0900 Subject: [PATCH 4/9] Update Files.App.Storage.csproj --- src/Files.App.Storage/Files.App.Storage.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Files.App.Storage/Files.App.Storage.csproj b/src/Files.App.Storage/Files.App.Storage.csproj index 821916c64f24..57304cdd2e88 100644 --- a/src/Files.App.Storage/Files.App.Storage.csproj +++ b/src/Files.App.Storage/Files.App.Storage.csproj @@ -15,13 +15,13 @@ - + - \ No newline at end of file + From 1ad99039e126b7d25877bfbc42bb651d3b62046a Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Sun, 6 Oct 2024 10:12:23 +0000 Subject: [PATCH 5/9] Added NativeFolderView --- src/Files.App.Storage/Files.App.Storage.csproj | 1 + .../Storables/Native/NativeFolder.cs | 6 +++--- .../Storables/Native/NativeFolderView.cs | 12 ++++++++++++ .../Storables/Native/NativeStorable.cs | 4 ++-- 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 src/Files.App.Storage/Storables/Native/NativeFolderView.cs diff --git a/src/Files.App.Storage/Files.App.Storage.csproj b/src/Files.App.Storage/Files.App.Storage.csproj index 57304cdd2e88..bda43bf82fd8 100644 --- a/src/Files.App.Storage/Files.App.Storage.csproj +++ b/src/Files.App.Storage/Files.App.Storage.csproj @@ -5,6 +5,7 @@ net8.0-windows10.0.22621.0 10.0.19041.0 enable + true true Debug;Release;Stable;Preview;Store x86;x64;arm64 diff --git a/src/Files.App.Storage/Storables/Native/NativeFolder.cs b/src/Files.App.Storage/Storables/Native/NativeFolder.cs index 0a1eeffe7e71..6127c8c65845 100644 --- a/src/Files.App.Storage/Storables/Native/NativeFolder.cs +++ b/src/Files.App.Storage/Storables/Native/NativeFolder.cs @@ -28,9 +28,9 @@ unsafe IEnumerable GetChildren() (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IEnumShellItems.Guid)), (void**)pEnumShellItems.GetAddressOf()); - ComPtr pShellItem = default; - while (pEnumShellItems.Get()->Next(1, pShellItem.GetAddressOf()) == HRESULT.S_OK) - yield return NativeStorable(pShellItem); + ComPtr pShellItem = default; + while (pEnumShellItems.Get()->Next(1, pShellItem.GetAddressOf()) == HRESULT.S_OK) + yield return NativeStorable(pShellItem); } } } diff --git a/src/Files.App.Storage/Storables/Native/NativeFolderView.cs b/src/Files.App.Storage/Storables/Native/NativeFolderView.cs new file mode 100644 index 000000000000..eeaf37d397c8 --- /dev/null +++ b/src/Files.App.Storage/Storables/Native/NativeFolderView.cs @@ -0,0 +1,12 @@ +// Copyright (c) 2024 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.Storage.Storables +{ + /// + /// Represents a folder object that is natively supported by Windows Shell API. + /// + public class NativeFolderView /*:IFolderView*/ + { + } +} diff --git a/src/Files.App.Storage/Storables/Native/NativeStorable.cs b/src/Files.App.Storage/Storables/Native/NativeStorable.cs index 0e2dcda57208..a386e390ac4b 100644 --- a/src/Files.App.Storage/Storables/Native/NativeStorable.cs +++ b/src/Files.App.Storage/Storables/Native/NativeStorable.cs @@ -98,8 +98,8 @@ public string GetPropertyAsync(string id) using ComHeapPtr pPropertyValue; hr = pShellItem2.Get()->GetString( - propertyKey, - (void**)pPropertyValue.GetAddressOf()); + &propertyKey, + pPropertyValue.GetAddressOf()); return szPropertyValue.Get()->ToString(); } From 50cd70fd2bb0a83d4e771dfc7f6aec5b03078a8f Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Sun, 6 Oct 2024 10:43:56 +0000 Subject: [PATCH 6/9] Update NativeFolderView --- .../Storables/Native/INativeStorable.cs | 9 ++------- .../Storables/Native/NativeFolderView.cs | 13 ++++++++++++- .../FolderView/FolderViewMode.cs | 15 +++++++++++++++ src/Files.Core.Storage/FolderView/IFolderView.cs | 16 ++++++++++++++++ 4 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 src/Files.Core.Storage/FolderView/FolderViewMode.cs create mode 100644 src/Files.Core.Storage/FolderView/IFolderView.cs diff --git a/src/Files.App.Storage/Storables/Native/INativeStorable.cs b/src/Files.App.Storage/Storables/Native/INativeStorable.cs index 69287fa6996a..336d0e8ddcfb 100644 --- a/src/Files.App.Storage/Storables/Native/INativeStorable.cs +++ b/src/Files.App.Storage/Storables/Native/INativeStorable.cs @@ -6,13 +6,8 @@ namespace Files.App.Storage.Storables /// /// Represents a file object that is natively supported by Windows Shell API. /// - public class INativeStorable : NativeStorable + public class INativeStorable { - /// - /// Get a property value from this . - /// - /// The property ID (e.g. "System.Image.Dimensions"). - /// Returns a valid value formatted with string; otherwise, returns . - public string GetPropertyAsync(string id); + public string GetPropertyAsync(string id); } } diff --git a/src/Files.App.Storage/Storables/Native/NativeFolderView.cs b/src/Files.App.Storage/Storables/Native/NativeFolderView.cs index eeaf37d397c8..e8d4672b2c17 100644 --- a/src/Files.App.Storage/Storables/Native/NativeFolderView.cs +++ b/src/Files.App.Storage/Storables/Native/NativeFolderView.cs @@ -6,7 +6,18 @@ namespace Files.App.Storage.Storables /// /// Represents a folder object that is natively supported by Windows Shell API. /// - public class NativeFolderView /*:IFolderView*/ + public class NativeFolderView : IFolderView { + public int GetSpacing() + {} + + public int GetThumbnailSize() + {} + + public FolderViewMode GetViewMode() + {} + + public uint GetItemsCount() + {} } } diff --git a/src/Files.Core.Storage/FolderView/FolderViewMode.cs b/src/Files.Core.Storage/FolderView/FolderViewMode.cs new file mode 100644 index 000000000000..1cb2b065548c --- /dev/null +++ b/src/Files.Core.Storage/FolderView/FolderViewMode.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.Core.Storage +{ + public enum FolderViewMode + { + Auto = 0, + Details, + List, + Tiles, + Grid, + Columns, + } +} diff --git a/src/Files.Core.Storage/FolderView/IFolderView.cs b/src/Files.Core.Storage/FolderView/IFolderView.cs new file mode 100644 index 000000000000..54e91ae9f2ac --- /dev/null +++ b/src/Files.Core.Storage/FolderView/IFolderView.cs @@ -0,0 +1,16 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.Core.Storage +{ + public interface IFolderView + { + int GetSpacing(); + + int GetThumbnailSize(); + + FolderViewMode GetViewMode(); + + uint GetItemsCount(); + } +} From 65a38140e958bea4d0f6c9d5eeec4a9742839604 Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Sun, 6 Oct 2024 10:52:40 +0000 Subject: [PATCH 7/9] Update NativeFolderView --- .../Storables/Native/NativeFolderView.cs | 16 ++++++++++++---- .../FolderView/FolderViewColumnAlignment.cs | 12 ++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 src/Files.Core.Storage/FolderView/FolderViewColumnAlignment.cs diff --git a/src/Files.App.Storage/Storables/Native/NativeFolderView.cs b/src/Files.App.Storage/Storables/Native/NativeFolderView.cs index e8d4672b2c17..ad1189bc2571 100644 --- a/src/Files.App.Storage/Storables/Native/NativeFolderView.cs +++ b/src/Files.App.Storage/Storables/Native/NativeFolderView.cs @@ -9,15 +9,23 @@ namespace Files.App.Storage.Storables public class NativeFolderView : IFolderView { public int GetSpacing() - {} + { + return 0; + } public int GetThumbnailSize() - {} + { + return 0; + } public FolderViewMode GetViewMode() - {} + { + return 0; + } public uint GetItemsCount() - {} + { + return 0; + } } } diff --git a/src/Files.Core.Storage/FolderView/FolderViewColumnAlignment.cs b/src/Files.Core.Storage/FolderView/FolderViewColumnAlignment.cs new file mode 100644 index 000000000000..f350a794a530 --- /dev/null +++ b/src/Files.Core.Storage/FolderView/FolderViewColumnAlignment.cs @@ -0,0 +1,12 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.Core.Storage +{ + public enum FolderViewColumnAlignment + { + Left, + Center, + Right, + } +} From 67980b554e421ed9d54f7248759bddd1c0eb4966 Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Sun, 6 Oct 2024 11:39:11 +0000 Subject: [PATCH 8/9] Update --- src/Files.App.Storage/Storables/Native/INativeStorable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App.Storage/Storables/Native/INativeStorable.cs b/src/Files.App.Storage/Storables/Native/INativeStorable.cs index 336d0e8ddcfb..a384ee7ed77c 100644 --- a/src/Files.App.Storage/Storables/Native/INativeStorable.cs +++ b/src/Files.App.Storage/Storables/Native/INativeStorable.cs @@ -6,7 +6,7 @@ namespace Files.App.Storage.Storables /// /// Represents a file object that is natively supported by Windows Shell API. /// - public class INativeStorable + public interface INativeStorable { public string GetPropertyAsync(string id); } From 2493ba4a40d67607fb7849e21cf9c1da2f1317e7 Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Sun, 6 Oct 2024 15:11:24 +0000 Subject: [PATCH 9/9] Added ArchiveStorable --- .../Storables/Archive/ArchiveFile.cs | 12 ++++++++++ .../Storables/Archive/ArchiveFolder.cs | 12 ++++++++++ .../Storables/Archive/ArchiveFolderView.cs | 12 ++++++++++ .../Storables/Archive/ArchiveStorable.cs | 24 +++++++++++++++++++ .../Storables/Archive/IArchiveStorable.cs | 12 ++++++++++ .../Storables/Native/INativeStorable.cs | 4 ++-- .../Storables/Native/NativeFile.cs | 2 +- .../Storables/Native/NativeFolder.cs | 2 +- .../Storables/Native/NativeFolderView.cs | 21 +--------------- .../Storables/Native/NativeStorable.cs | 14 +++++------ .../FolderView/IFolderView.cs | 7 ------ 11 files changed, 84 insertions(+), 38 deletions(-) create mode 100644 src/Files.App.Storage/Storables/Archive/ArchiveFile.cs create mode 100644 src/Files.App.Storage/Storables/Archive/ArchiveFolder.cs create mode 100644 src/Files.App.Storage/Storables/Archive/ArchiveFolderView.cs create mode 100644 src/Files.App.Storage/Storables/Archive/ArchiveStorable.cs create mode 100644 src/Files.App.Storage/Storables/Archive/IArchiveStorable.cs diff --git a/src/Files.App.Storage/Storables/Archive/ArchiveFile.cs b/src/Files.App.Storage/Storables/Archive/ArchiveFile.cs new file mode 100644 index 000000000000..4c4ab41e2756 --- /dev/null +++ b/src/Files.App.Storage/Storables/Archive/ArchiveFile.cs @@ -0,0 +1,12 @@ +// Copyright (c) 2024 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.Storage.Storables +{ + /// + /// Represents a file that is powered by SevenZipSharp and 7zip. + /// + public class ArchiveFile : ArchiveStorable/*, IFile*/ + { + } +} diff --git a/src/Files.App.Storage/Storables/Archive/ArchiveFolder.cs b/src/Files.App.Storage/Storables/Archive/ArchiveFolder.cs new file mode 100644 index 000000000000..2e700c52b328 --- /dev/null +++ b/src/Files.App.Storage/Storables/Archive/ArchiveFolder.cs @@ -0,0 +1,12 @@ +// Copyright (c) 2024 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.Storage.Storables +{ + /// + /// Represents a folder that is powered by SevenZipSharp and 7zip. + /// + public class ArchiveFolder : ArchiveStorable/*, IFolder*/ + { + } +} diff --git a/src/Files.App.Storage/Storables/Archive/ArchiveFolderView.cs b/src/Files.App.Storage/Storables/Archive/ArchiveFolderView.cs new file mode 100644 index 000000000000..31466f281f80 --- /dev/null +++ b/src/Files.App.Storage/Storables/Archive/ArchiveFolderView.cs @@ -0,0 +1,12 @@ +// Copyright (c) 2024 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.Storage.Storables +{ + /// + /// Represents a folder view that is powered by SevenZipSharp and 7zip. + /// + public class ArchiveFolderView : IFolderView + { + } +} diff --git a/src/Files.App.Storage/Storables/Archive/ArchiveStorable.cs b/src/Files.App.Storage/Storables/Archive/ArchiveStorable.cs new file mode 100644 index 000000000000..4fc45dd2035e --- /dev/null +++ b/src/Files.App.Storage/Storables/Archive/ArchiveStorable.cs @@ -0,0 +1,24 @@ +// Copyright (c) 2024 Files Community +// Licensed under the MIT License. See the LICENSE. + +using System.Runtime.InteropServices; +using Windows.Win32; +using Windows.Win32.Foundation; +using Windows.Win32.System.Com; +using Windows.Win32.UI.Shell; + +namespace Files.App.Storage.Storables +{ + /// + public abstract class ArchiveStorable : IArchiveStorable + { + /// + public string Path { get; protected set; } + + /// + public string Name { get; protected set; } + + /// + public string Id { get; protected set; } + } +} diff --git a/src/Files.App.Storage/Storables/Archive/IArchiveStorable.cs b/src/Files.App.Storage/Storables/Archive/IArchiveStorable.cs new file mode 100644 index 000000000000..25681fb64c83 --- /dev/null +++ b/src/Files.App.Storage/Storables/Archive/IArchiveStorable.cs @@ -0,0 +1,12 @@ +// Copyright (c) 2024 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.Storage.Storables +{ + /// + /// Represents a storable that is powered by SevenZipSharp and 7zip. + /// + public interface IArchiveStorable : IStorable + { + } +} diff --git a/src/Files.App.Storage/Storables/Native/INativeStorable.cs b/src/Files.App.Storage/Storables/Native/INativeStorable.cs index a384ee7ed77c..e01caa44e1b8 100644 --- a/src/Files.App.Storage/Storables/Native/INativeStorable.cs +++ b/src/Files.App.Storage/Storables/Native/INativeStorable.cs @@ -4,9 +4,9 @@ namespace Files.App.Storage.Storables { /// - /// Represents a file object that is natively supported by Windows Shell API. + /// Represents a storable that is natively supported by Windows Shell API. /// - public interface INativeStorable + public interface INativeStorable : IStorable { public string GetPropertyAsync(string id); } diff --git a/src/Files.App.Storage/Storables/Native/NativeFile.cs b/src/Files.App.Storage/Storables/Native/NativeFile.cs index 81dba251f5da..6301a9d28c57 100644 --- a/src/Files.App.Storage/Storables/Native/NativeFile.cs +++ b/src/Files.App.Storage/Storables/Native/NativeFile.cs @@ -4,7 +4,7 @@ namespace Files.App.Storage.Storables { /// - /// Represents a file object that is natively supported by Windows Shell API. + /// Represents a file that is natively supported by Windows Shell API. /// public class NativeFile : NativeStorable/*, IFile*/ { diff --git a/src/Files.App.Storage/Storables/Native/NativeFolder.cs b/src/Files.App.Storage/Storables/Native/NativeFolder.cs index 6127c8c65845..e116de332bce 100644 --- a/src/Files.App.Storage/Storables/Native/NativeFolder.cs +++ b/src/Files.App.Storage/Storables/Native/NativeFolder.cs @@ -4,7 +4,7 @@ namespace Files.App.Storage.Storables { /// - /// Represents a folder object that is natively supported by Windows Shell API. + /// Represents a folder that is natively supported by Windows Shell API. /// public class NativeFolder : NativeStorable/*, IFolder*/ { diff --git a/src/Files.App.Storage/Storables/Native/NativeFolderView.cs b/src/Files.App.Storage/Storables/Native/NativeFolderView.cs index ad1189bc2571..a2e7f95e3ae3 100644 --- a/src/Files.App.Storage/Storables/Native/NativeFolderView.cs +++ b/src/Files.App.Storage/Storables/Native/NativeFolderView.cs @@ -4,28 +4,9 @@ namespace Files.App.Storage.Storables { /// - /// Represents a folder object that is natively supported by Windows Shell API. + /// Represents a folder view that is natively supported by Windows Shell API. /// public class NativeFolderView : IFolderView { - public int GetSpacing() - { - return 0; - } - - public int GetThumbnailSize() - { - return 0; - } - - public FolderViewMode GetViewMode() - { - return 0; - } - - public uint GetItemsCount() - { - return 0; - } } } diff --git a/src/Files.App.Storage/Storables/Native/NativeStorable.cs b/src/Files.App.Storage/Storables/Native/NativeStorable.cs index a386e390ac4b..80b3e691322e 100644 --- a/src/Files.App.Storage/Storables/Native/NativeStorable.cs +++ b/src/Files.App.Storage/Storables/Native/NativeStorable.cs @@ -35,7 +35,7 @@ public abstract class NativeStorable : INativeStorable /// Initializes an instance of class. /// /// Win32 file namespace, shell namespace, or UNC path. - public unsafe NativeFile(string path) + public unsafe NativeStorable(string path) { HRESULT hr = PInvoke.SHCreateItemFromParsingName( path, @@ -53,7 +53,7 @@ public unsafe NativeStorable(Guid shellGuid) HRESULT hr = default; // For known folders - fixed (Guid* pFolderId = shellGuid) + fixed (Guid* pFolderId = &shellGuid) { hr = PInvoke.SHGetKnownFolderItem( pFolderId, @@ -96,12 +96,12 @@ public string GetPropertyAsync(string id) id, out var propertyKey); - using ComHeapPtr pPropertyValue; - hr = pShellItem2.Get()->GetString( - &propertyKey, - pPropertyValue.GetAddressOf()); + using ComHeapPtr pszPropertyValue = default; + //hr = pShellItem2.Get()->GetString( + // &propertyKey, + // pszPropertyValue.GetAddressOf()); - return szPropertyValue.Get()->ToString(); + return pszPropertyValue.Get()->ToString(); } } } diff --git a/src/Files.Core.Storage/FolderView/IFolderView.cs b/src/Files.Core.Storage/FolderView/IFolderView.cs index 54e91ae9f2ac..6b0ec9196890 100644 --- a/src/Files.Core.Storage/FolderView/IFolderView.cs +++ b/src/Files.Core.Storage/FolderView/IFolderView.cs @@ -5,12 +5,5 @@ namespace Files.Core.Storage { public interface IFolderView { - int GetSpacing(); - - int GetThumbnailSize(); - - FolderViewMode GetViewMode(); - - uint GetItemsCount(); } }