diff --git a/src/Files.App.Storage/Files.App.Storage.csproj b/src/Files.App.Storage/Files.App.Storage.csproj
index c08d08cbe3f0..bda43bf82fd8 100644
--- a/src/Files.App.Storage/Files.App.Storage.csproj
+++ b/src/Files.App.Storage/Files.App.Storage.csproj
@@ -5,27 +5,24 @@
net8.0-windows10.0.22621.0
10.0.19041.0
enable
+ true
true
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
-
-
+
-
\ No newline at end of file
+
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/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/INativeStorable.cs b/src/Files.App.Storage/Storables/Native/INativeStorable.cs
new file mode 100644
index 000000000000..e01caa44e1b8
--- /dev/null
+++ b/src/Files.App.Storage/Storables/Native/INativeStorable.cs
@@ -0,0 +1,13 @@
+// Copyright (c) 2024 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
+namespace Files.App.Storage.Storables
+{
+ ///
+ /// Represents a storable that is natively supported by Windows Shell API.
+ ///
+ 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
new file mode 100644
index 000000000000..6301a9d28c57
--- /dev/null
+++ b/src/Files.App.Storage/Storables/Native/NativeFile.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 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
new file mode 100644
index 000000000000..e116de332bce
--- /dev/null
+++ b/src/Files.App.Storage/Storables/Native/NativeFolder.cs
@@ -0,0 +1,38 @@
+// Copyright (c) 2024 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
+namespace Files.App.Storage.Storables
+{
+ ///
+ /// Represents a folder that is natively supported by Windows Shell API.
+ ///
+ 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/NativeFolderView.cs b/src/Files.App.Storage/Storables/Native/NativeFolderView.cs
new file mode 100644
index 000000000000..a2e7f95e3ae3
--- /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 view 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
new file mode 100644
index 000000000000..80b3e691322e
--- /dev/null
+++ b/src/Files.App.Storage/Storables/Native/NativeStorable.cs
@@ -0,0 +1,107 @@
+// 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
+{
+ ///
+ /// Represents a storable that is natively supported by Windows Shell API.
+ ///
+ 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 NativeStorable(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 pszPropertyValue = default;
+ //hr = pShellItem2.Get()->GetString(
+ // &propertyKey,
+ // pszPropertyValue.GetAddressOf());
+
+ return pszPropertyValue.Get()->ToString();
+ }
+ }
+}
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);
- }
- }
-}
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,
+ }
+}
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..6b0ec9196890
--- /dev/null
+++ b/src/Files.Core.Storage/FolderView/IFolderView.cs
@@ -0,0 +1,9 @@
+// Copyright (c) 2023 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
+namespace Files.Core.Storage
+{
+ public interface IFolderView
+ {
+ }
+}