From f7683e640edbc31afdec03630481b73c5d0a22eb Mon Sep 17 00:00:00 2001
From: 0x5bfa <62196528+0x5bfa@users.noreply.github.com>
Date: Thu, 16 May 2024 09:29:24 +0900
Subject: [PATCH 1/4] Init
---
src/Files.App.Storage/GlobalUsings.cs | 25 +++
.../NativeStorage/NativeFolder.cs | 154 +++++++++---------
.../NativeStorage/NativeFolderWatcher.cs | 91 -----------
src/Files.App/GlobalUsings.cs | 2 +
.../Data/Contracts/IDeviceWatcher.cs | 43 +++++
.../Data/Contracts/IFolderWatcher.cs | 36 ++++
.../Data/Contracts/ITrashWatcher.cs | 33 ++++
.../Data/Contracts/IWatcher.cs | 21 +++
.../{ => Data}/Enums/StorableKind.cs | 0
.../Data/EventArguments/DeviceEventArgs.cs | 5 +-
src/Files.Core.Storage/GlobalUsings.cs | 25 +++
.../MutableStorage/IFolderWatcher.cs | 19 ---
12 files changed, 261 insertions(+), 193 deletions(-)
create mode 100644 src/Files.App.Storage/GlobalUsings.cs
delete mode 100644 src/Files.App.Storage/NativeStorage/NativeFolderWatcher.cs
create mode 100644 src/Files.Core.Storage/Data/Contracts/IDeviceWatcher.cs
create mode 100644 src/Files.Core.Storage/Data/Contracts/IFolderWatcher.cs
create mode 100644 src/Files.Core.Storage/Data/Contracts/ITrashWatcher.cs
create mode 100644 src/Files.Core.Storage/Data/Contracts/IWatcher.cs
rename src/Files.Core.Storage/{ => Data}/Enums/StorableKind.cs (100%)
rename src/{Files.App => Files.Core.Storage}/Data/EventArguments/DeviceEventArgs.cs (86%)
create mode 100644 src/Files.Core.Storage/GlobalUsings.cs
delete mode 100644 src/Files.Core.Storage/MutableStorage/IFolderWatcher.cs
diff --git a/src/Files.App.Storage/GlobalUsings.cs b/src/Files.App.Storage/GlobalUsings.cs
new file mode 100644
index 000000000000..92e96b100e33
--- /dev/null
+++ b/src/Files.App.Storage/GlobalUsings.cs
@@ -0,0 +1,25 @@
+// Copyright (c) 2024 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
+// System
+global using global::System;
+global using global::System.Collections;
+global using global::System.Collections.Generic;
+global using global::System.Collections.ObjectModel;
+global using global::System.Linq;
+global using global::System.Threading;
+global using global::System.Threading.Tasks;
+global using global::System.ComponentModel;
+global using global::System.Diagnostics;
+global using global::System.Text.Json;
+global using global::System.Text.Json.Serialization;
+global using SystemIO = global::System.IO;
+
+// Files.Core.Storage
+
+global using global::Files.Core.Storage;
+global using global::Files.Core.Storage.Data.Contracts;
+global using global::Files.Core.Storage.Data.EventArguments;
+global using global::Files.Core.Storage.Enums;
+global using global::Files.Core.Storage.LocatableStorage;
+global using global::Files.Core.Storage.NestedStorage;
diff --git a/src/Files.App.Storage/NativeStorage/NativeFolder.cs b/src/Files.App.Storage/NativeStorage/NativeFolder.cs
index e49c7577e5b6..aefd07d21c0b 100644
--- a/src/Files.App.Storage/NativeStorage/NativeFolder.cs
+++ b/src/Files.App.Storage/NativeStorage/NativeFolder.cs
@@ -21,83 +21,83 @@ namespace Files.App.Storage.NativeStorage
{
///
public class NativeFolder : NativeStorable, ILocatableFolder, IModifiableFolder, IMutableFolder, IFolderExtended, INestedFolder, IDirectCopy, IDirectMove
- {
+ {
public NativeFolder(DirectoryInfo directoryInfo, string? name = null)
- : base(directoryInfo, name)
- {
- }
-
- public NativeFolder(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 NativeFile(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 NativeFolder(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 NativeFile(item);
- }
- else if (kind == StorableKind.Folders)
- {
- foreach (var item in Directory.EnumerateDirectories(Path))
- yield return new NativeFolder(item);
- }
- else
- {
- foreach (var item in Directory.EnumerateFileSystemEntries(Path))
- {
- if (File.Exists(item))
- yield return new NativeFile(item);
- else
- yield return new NativeFolder(item);
- }
- }
-
- await Task.CompletedTask;
- }
+ : base(directoryInfo, name)
+ {
+ }
+
+ public NativeFolder(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 NativeFile(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 NativeFolder(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 NativeFile(item);
+ }
+ else if (kind == StorableKind.Folders)
+ {
+ foreach (var item in Directory.EnumerateDirectories(Path))
+ yield return new NativeFolder(item);
+ }
+ else
+ {
+ foreach (var item in Directory.EnumerateFileSystemEntries(Path))
+ {
+ if (File.Exists(item))
+ yield return new NativeFile(item);
+ else
+ yield return new NativeFolder(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;
- }
+ {
+ _ = 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)
@@ -176,11 +176,5 @@ public virtual Task CreateFolderAsync(string desiredName, bool ov
_ = Directory.CreateDirectory(path);
return Task.FromResult(new NativeFolder(path));
}
-
- ///
- public Task GetFolderWatcherAsync(CancellationToken cancellationToken = default)
- {
- return Task.FromResult(new NativeFolderWatcher(this));
- }
- }
+ }
}
diff --git a/src/Files.App.Storage/NativeStorage/NativeFolderWatcher.cs b/src/Files.App.Storage/NativeStorage/NativeFolderWatcher.cs
deleted file mode 100644
index 1020452221a1..000000000000
--- a/src/Files.App.Storage/NativeStorage/NativeFolderWatcher.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (c) 2024 Files Community
-// Licensed under the MIT License. See the LICENSE.
-
-using Files.Core.Storage.LocatableStorage;
-using Files.Core.Storage.MutableStorage;
-using System.Collections.Specialized;
-using System.IO;
-using System.Threading.Tasks;
-
-namespace Files.App.Storage.NativeStorage
-{
- ///
- public sealed class NativeFolderWatcher : IFolderWatcher
- {
- private FileSystemWatcher? _fileSystemWatcher;
- private NotifyCollectionChangedEventHandler? _collectionChanged;
-
- public IMutableFolder Folder { get; }
-
- ///
- public event NotifyCollectionChangedEventHandler? CollectionChanged
- {
- add
- {
- if (_fileSystemWatcher is not null)
- _fileSystemWatcher.EnableRaisingEvents = true;
-
- _collectionChanged += value;
- }
- remove
- {
- if (_fileSystemWatcher is not null)
- _fileSystemWatcher.EnableRaisingEvents = false;
-
- _collectionChanged -= value;
- }
- }
-
- public NativeFolderWatcher(IMutableFolder folder)
- {
- Folder = folder;
- SetupWatcher();
- }
-
- private void SetupWatcher()
- {
- if (Folder is ILocatableFolder locatableFolder)
- {
- _fileSystemWatcher = new(locatableFolder.Path);
- _fileSystemWatcher.Created += FileSystemWatcher_Created;
- _fileSystemWatcher.Deleted += FileSystemWatcher_Deleted;
- _fileSystemWatcher.Renamed += FileSystemWatcher_Renamed;
- }
- }
-
- private void FileSystemWatcher_Renamed(object sender, RenamedEventArgs e)
- {
- _collectionChanged?.Invoke(this, new(NotifyCollectionChangedAction.Replace, e.FullPath, e.OldFullPath));
- }
-
- private void FileSystemWatcher_Deleted(object sender, FileSystemEventArgs e)
- {
- _collectionChanged?.Invoke(this, new(NotifyCollectionChangedAction.Remove, e.FullPath));
- }
-
- private void FileSystemWatcher_Created(object sender, FileSystemEventArgs e)
- {
- _collectionChanged?.Invoke(this, new(NotifyCollectionChangedAction.Add, e.FullPath));
- }
-
- ///
- public ValueTask DisposeAsync()
- {
- Dispose();
- return default;
- }
-
- ///
- public void Dispose()
- {
- if (_fileSystemWatcher is not null)
- {
- _fileSystemWatcher.EnableRaisingEvents = false;
- _fileSystemWatcher.Created -= FileSystemWatcher_Created;
- _fileSystemWatcher.Deleted -= FileSystemWatcher_Deleted;
- _fileSystemWatcher.Renamed -= FileSystemWatcher_Renamed;
- _fileSystemWatcher.Dispose();
- }
- }
- }
-}
diff --git a/src/Files.App/GlobalUsings.cs b/src/Files.App/GlobalUsings.cs
index 90ba38009f1d..63aa054fe298 100644
--- a/src/Files.App/GlobalUsings.cs
+++ b/src/Files.App/GlobalUsings.cs
@@ -72,6 +72,8 @@
// Files.Core.Storage
global using global::Files.Core.Storage;
+global using global::Files.Core.Storage.Data.Contracts;
+global using global::Files.Core.Storage.Data.EventArguments;
global using global::Files.Core.Storage.Enums;
global using global::Files.Core.Storage.LocatableStorage;
global using global::Files.Core.Storage.NestedStorage;
diff --git a/src/Files.Core.Storage/Data/Contracts/IDeviceWatcher.cs b/src/Files.Core.Storage/Data/Contracts/IDeviceWatcher.cs
new file mode 100644
index 000000000000..ac172590e288
--- /dev/null
+++ b/src/Files.Core.Storage/Data/Contracts/IDeviceWatcher.cs
@@ -0,0 +1,43 @@
+// Copyright (c) 2023 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
+namespace Files.Core.Storage.Data.Contracts
+{
+ internal interface IDeviceWatcher
+ {
+ ///
+ /// Gets the value that indicates whether the watcher can be started.
+ ///
+ bool CanBeStarted { 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 inserting is detected by the watcher
+ ///
+ event EventHandler? ItemInserted;
+
+ ///
+ /// Gets invoked when an item ejection is detected by the watcher
+ ///
+ event EventHandler? ItemEjected;
+
+ ///
+ /// Gets invoked when item enumeration completed.
+ ///
+ event EventHandler? EnumerationCompleted;
+ }
+}
diff --git a/src/Files.Core.Storage/Data/Contracts/IFolderWatcher.cs b/src/Files.Core.Storage/Data/Contracts/IFolderWatcher.cs
new file mode 100644
index 000000000000..9a8cdc1ace4d
--- /dev/null
+++ b/src/Files.Core.Storage/Data/Contracts/IFolderWatcher.cs
@@ -0,0 +1,36 @@
+// Copyright (c) 2023 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
+using Files.Core.Storage.MutableStorage;
+using System.Collections.Specialized;
+
+namespace Files.Core.Storage.Data.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/Data/Contracts/ITrashWatcher.cs b/src/Files.Core.Storage/Data/Contracts/ITrashWatcher.cs
new file mode 100644
index 000000000000..ba5eee725be8
--- /dev/null
+++ b/src/Files.Core.Storage/Data/Contracts/ITrashWatcher.cs
@@ -0,0 +1,33 @@
+// Copyright (c) 2023 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
+namespace Files.Core.Storage.Data.Contracts
+{
+ public interface ITrashWatcher
+ {
+ ///
+ /// 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;
+
+ ///
+ /// Gets invoked when an refresh request is detected by the watcher
+ ///
+ event EventHandler? RefreshRequested;
+ }
+}
diff --git a/src/Files.Core.Storage/Data/Contracts/IWatcher.cs b/src/Files.Core.Storage/Data/Contracts/IWatcher.cs
new file mode 100644
index 000000000000..bba1930677dc
--- /dev/null
+++ b/src/Files.Core.Storage/Data/Contracts/IWatcher.cs
@@ -0,0 +1,21 @@
+// Copyright (c) 2023 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
+namespace Files.Core.Storage.Data.Contracts
+{
+ ///
+ /// A disposable object which can notify of changes to the folder.
+ ///
+ public interface IWatcher : IDisposable, IAsyncDisposable
+ {
+ ///
+ /// Starts the watcher
+ ///
+ void StartWatcher();
+
+ ///
+ /// Stops the watcher
+ ///
+ void StopsWatcher();
+ }
+}
diff --git a/src/Files.Core.Storage/Enums/StorableKind.cs b/src/Files.Core.Storage/Data/Enums/StorableKind.cs
similarity index 100%
rename from src/Files.Core.Storage/Enums/StorableKind.cs
rename to src/Files.Core.Storage/Data/Enums/StorableKind.cs
diff --git a/src/Files.App/Data/EventArguments/DeviceEventArgs.cs b/src/Files.Core.Storage/Data/EventArguments/DeviceEventArgs.cs
similarity index 86%
rename from src/Files.App/Data/EventArguments/DeviceEventArgs.cs
rename to src/Files.Core.Storage/Data/EventArguments/DeviceEventArgs.cs
index 3e36a114aac2..ca1aa7e0d555 100644
--- a/src/Files.App/Data/EventArguments/DeviceEventArgs.cs
+++ b/src/Files.Core.Storage/Data/EventArguments/DeviceEventArgs.cs
@@ -1,13 +1,12 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using System;
-
-namespace Files.App.Data.EventArguments
+namespace Files.Core.Storage.Data.EventArguments
{
public sealed class DeviceEventArgs : EventArgs
{
public string DeviceName { get; }
+
public string DeviceId { get; }
public DeviceEventArgs(string deviceName, string deviceId)
diff --git a/src/Files.Core.Storage/GlobalUsings.cs b/src/Files.Core.Storage/GlobalUsings.cs
new file mode 100644
index 000000000000..92e96b100e33
--- /dev/null
+++ b/src/Files.Core.Storage/GlobalUsings.cs
@@ -0,0 +1,25 @@
+// Copyright (c) 2024 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
+// System
+global using global::System;
+global using global::System.Collections;
+global using global::System.Collections.Generic;
+global using global::System.Collections.ObjectModel;
+global using global::System.Linq;
+global using global::System.Threading;
+global using global::System.Threading.Tasks;
+global using global::System.ComponentModel;
+global using global::System.Diagnostics;
+global using global::System.Text.Json;
+global using global::System.Text.Json.Serialization;
+global using SystemIO = global::System.IO;
+
+// Files.Core.Storage
+
+global using global::Files.Core.Storage;
+global using global::Files.Core.Storage.Data.Contracts;
+global using global::Files.Core.Storage.Data.EventArguments;
+global using global::Files.Core.Storage.Enums;
+global using global::Files.Core.Storage.LocatableStorage;
+global using global::Files.Core.Storage.NestedStorage;
diff --git a/src/Files.Core.Storage/MutableStorage/IFolderWatcher.cs b/src/Files.Core.Storage/MutableStorage/IFolderWatcher.cs
deleted file mode 100644
index 94bb3c99f6d7..000000000000
--- a/src/Files.Core.Storage/MutableStorage/IFolderWatcher.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2024 Files Community
-// Licensed under the MIT License. See the LICENSE.
-
-using System;
-using System.Collections.Specialized;
-
-namespace Files.Core.Storage.MutableStorage
-{
- ///
- /// A disposable object which can notify of changes to the folder.
- ///
- public interface IFolderWatcher : INotifyCollectionChanged, IDisposable, IAsyncDisposable
- {
- ///
- /// The folder being watched for changes.
- ///
- public IMutableFolder Folder { get; }
- }
-}
From 0d252a4442fc4d9357672781f007ba37084a5e34 Mon Sep 17 00:00:00 2001
From: 0x5bfa <62196528+0x5bfa@users.noreply.github.com>
Date: Thu, 16 May 2024 09:48:09 +0900
Subject: [PATCH 2/4] Update
---
src/Files.App.Storage/GlobalUsings.cs | 10 ++++++++--
.../{ => Storables}/FtpStorage/FtpHelpers.cs | 3 ---
.../{ => Storables}/FtpStorage/FtpManager.cs | 1 -
.../{ => Storables}/FtpStorage/FtpStorable.cs | 5 -----
.../FtpStorage/FtpStorageFile.cs | 7 -------
.../FtpStorage/FtpStorageFolder.cs | 12 -----------
.../FtpStorage/FtpStorageService.cs | 4 ----
.../NativeStorage/NativeFile.cs | 7 -------
.../NativeStorage/NativeFolder.cs | 13 ------------
.../NativeStorage/NativeStorable.cs | 5 -----
.../NativeStorage/NativeStorageService.cs | 4 ----
.../WindowsStorage/WindowsStorable.cs | 5 -----
.../WindowsStorage/WindowsStorageFile.cs | 8 --------
.../WindowsStorage/WindowsStorageFolder.cs | 11 ----------
.../WindowsStorage/WindowsStorageService.cs | 5 -----
.../{Data => }/Contracts/IDeviceWatcher.cs | 2 +-
.../{Data => }/Contracts/IFolderWatcher.cs | 2 +-
.../{Data => }/Contracts/ITrashWatcher.cs | 2 +-
.../{Data => }/Contracts/IWatcher.cs | 2 +-
.../{Data => }/Enums/StorableKind.cs | 2 --
.../EventArguments/DeviceEventArgs.cs | 2 +-
.../Extensions/StorageExtensions.File.cs | 4 ----
.../Extensions/StorageExtensions.Folder.cs | 10 +++-------
.../Extensions/StorageExtensions.Service.cs | 5 -----
.../Extensions/StorageExtensions.Storable.cs | 2 --
src/Files.Core.Storage/GlobalUsings.cs | 10 ++++++++--
.../MutableStorage/IMutableFolder.cs | 20 -------------------
.../DirectStorage/IDirectCopy.cs | 6 ++----
.../DirectStorage/IDirectMove.cs | 6 ++----
.../ExtendableStorage/IFileExtended.cs | 2 --
.../ExtendableStorage/IFolderExtended.cs | 5 ++---
.../{ => Storables}/IFile.cs | 2 --
.../{ => Storables}/IFolder.cs | 5 -----
.../{ => Storables}/IStorable.cs | 0
.../LocatableStorage/ILocatableFile.cs | 0
.../LocatableStorage/ILocatableFolder.cs | 0
.../LocatableStorage/ILocatableStorable.cs | 0
.../ModifiableStorage/IModifiableFile.cs | 0
.../ModifiableStorage/IModifiableFolder.cs | 4 ----
.../ModifiableStorage/IModifiableStorable.cs | 0
.../MutableStorage/IMutableFolder.cs | 12 +++++++++++
.../NestedStorage/INestedFile.cs | 5 ++++-
.../NestedStorage/INestedFolder.cs | 5 ++++-
.../NestedStorage/INestedStorable.cs | 4 ++--
.../StorageEnumeration/IStorageEnumerator.cs | 4 ----
45 files changed, 52 insertions(+), 171 deletions(-)
rename src/Files.App.Storage/{ => Storables}/FtpStorage/FtpHelpers.cs (96%)
rename src/Files.App.Storage/{ => Storables}/FtpStorage/FtpManager.cs (91%)
rename src/Files.App.Storage/{ => Storables}/FtpStorage/FtpStorable.cs (85%)
rename src/Files.App.Storage/{ => Storables}/FtpStorage/FtpStorageFile.cs (80%)
rename src/Files.App.Storage/{ => Storables}/FtpStorage/FtpStorageFolder.cs (93%)
rename src/Files.App.Storage/{ => Storables}/FtpStorage/FtpStorageService.cs (91%)
rename src/Files.App.Storage/{ => Storables}/NativeStorage/NativeFile.cs (79%)
rename src/Files.App.Storage/{ => Storables}/NativeStorage/NativeFolder.cs (91%)
rename src/Files.App.Storage/{ => Storables}/NativeStorage/NativeStorable.cs (90%)
rename src/Files.App.Storage/{ => Storables}/NativeStorage/NativeStorageService.cs (92%)
rename src/Files.App.Storage/{ => Storables}/WindowsStorage/WindowsStorable.cs (85%)
rename src/Files.App.Storage/{ => Storables}/WindowsStorage/WindowsStorageFile.cs (89%)
rename src/Files.App.Storage/{ => Storables}/WindowsStorage/WindowsStorageFolder.cs (93%)
rename src/Files.App.Storage/{ => Storables}/WindowsStorage/WindowsStorageService.cs (85%)
rename src/Files.Core.Storage/{Data => }/Contracts/IDeviceWatcher.cs (96%)
rename src/Files.Core.Storage/{Data => }/Contracts/IFolderWatcher.cs (95%)
rename src/Files.Core.Storage/{Data => }/Contracts/ITrashWatcher.cs (95%)
rename src/Files.Core.Storage/{Data => }/Contracts/IWatcher.cs (90%)
rename src/Files.Core.Storage/{Data => }/Enums/StorableKind.cs (94%)
rename src/Files.Core.Storage/{Data => }/EventArguments/DeviceEventArgs.cs (87%)
delete mode 100644 src/Files.Core.Storage/MutableStorage/IMutableFolder.cs
rename src/Files.Core.Storage/{ => Storables}/DirectStorage/IDirectCopy.cs (76%)
rename src/Files.Core.Storage/{ => Storables}/DirectStorage/IDirectMove.cs (79%)
rename src/Files.Core.Storage/{ => Storables}/ExtendableStorage/IFileExtended.cs (91%)
rename src/Files.Core.Storage/{ => Storables}/ExtendableStorage/IFolderExtended.cs (92%)
rename src/Files.Core.Storage/{ => Storables}/IFile.cs (93%)
rename src/Files.Core.Storage/{ => Storables}/IFolder.cs (85%)
rename src/Files.Core.Storage/{ => Storables}/IStorable.cs (100%)
rename src/Files.Core.Storage/{ => Storables}/LocatableStorage/ILocatableFile.cs (100%)
rename src/Files.Core.Storage/{ => Storables}/LocatableStorage/ILocatableFolder.cs (100%)
rename src/Files.Core.Storage/{ => Storables}/LocatableStorage/ILocatableStorable.cs (100%)
rename src/Files.Core.Storage/{ => Storables}/ModifiableStorage/IModifiableFile.cs (100%)
rename src/Files.Core.Storage/{ => Storables}/ModifiableStorage/IModifiableFolder.cs (91%)
rename src/Files.Core.Storage/{ => Storables}/ModifiableStorage/IModifiableStorable.cs (100%)
create mode 100644 src/Files.Core.Storage/Storables/MutableStorage/IMutableFolder.cs
rename src/Files.Core.Storage/{ => Storables}/NestedStorage/INestedFile.cs (57%)
rename src/Files.Core.Storage/{ => Storables}/NestedStorage/INestedFolder.cs (58%)
rename src/Files.Core.Storage/{ => Storables}/NestedStorage/INestedStorable.cs (81%)
diff --git a/src/Files.App.Storage/GlobalUsings.cs b/src/Files.App.Storage/GlobalUsings.cs
index 92e96b100e33..e96c02e065d2 100644
--- a/src/Files.App.Storage/GlobalUsings.cs
+++ b/src/Files.App.Storage/GlobalUsings.cs
@@ -18,8 +18,14 @@
// Files.Core.Storage
global using global::Files.Core.Storage;
-global using global::Files.Core.Storage.Data.Contracts;
-global using global::Files.Core.Storage.Data.EventArguments;
+global using global::Files.Core.Storage.Contracts;
+global using global::Files.Core.Storage.DirectStorage;
global using global::Files.Core.Storage.Enums;
+global using global::Files.Core.Storage.EventArguments;
+global using global::Files.Core.Storage.ExtendableStorage;
+global using global::Files.Core.Storage.Extensions;
global using global::Files.Core.Storage.LocatableStorage;
+global using global::Files.Core.Storage.ModifiableStorage;
+global using global::Files.Core.Storage.MutableStorage;
global using global::Files.Core.Storage.NestedStorage;
+global using global::Files.Core.Storage.StorageEnumeration;
diff --git a/src/Files.App.Storage/FtpStorage/FtpHelpers.cs b/src/Files.App.Storage/Storables/FtpStorage/FtpHelpers.cs
similarity index 96%
rename from src/Files.App.Storage/FtpStorage/FtpHelpers.cs
rename to src/Files.App.Storage/Storables/FtpStorage/FtpHelpers.cs
index b2883f23214d..8d7d2a3a0742 100644
--- a/src/Files.App.Storage/FtpStorage/FtpHelpers.cs
+++ b/src/Files.App.Storage/Storables/FtpStorage/FtpHelpers.cs
@@ -3,9 +3,6 @@
using Files.Shared.Extensions;
using FluentFTP;
-using System;
-using System.Threading;
-using System.Threading.Tasks;
namespace Files.App.Storage.FtpStorage
{
diff --git a/src/Files.App.Storage/FtpStorage/FtpManager.cs b/src/Files.App.Storage/Storables/FtpStorage/FtpManager.cs
similarity index 91%
rename from src/Files.App.Storage/FtpStorage/FtpManager.cs
rename to src/Files.App.Storage/Storables/FtpStorage/FtpManager.cs
index f7bcef00b2b5..cfca9769f46d 100644
--- a/src/Files.App.Storage/FtpStorage/FtpManager.cs
+++ b/src/Files.App.Storage/Storables/FtpStorage/FtpManager.cs
@@ -1,7 +1,6 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using System.Collections.Generic;
using System.Net;
namespace Files.App.Storage.FtpStorage
diff --git a/src/Files.App.Storage/FtpStorage/FtpStorable.cs b/src/Files.App.Storage/Storables/FtpStorage/FtpStorable.cs
similarity index 85%
rename from src/Files.App.Storage/FtpStorage/FtpStorable.cs
rename to src/Files.App.Storage/Storables/FtpStorage/FtpStorable.cs
index 8c978d6488f7..6d674287237e 100644
--- a/src/Files.App.Storage/FtpStorage/FtpStorable.cs
+++ b/src/Files.App.Storage/Storables/FtpStorage/FtpStorable.cs
@@ -1,12 +1,7 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage;
-using Files.Core.Storage.LocatableStorage;
-using Files.Core.Storage.NestedStorage;
using FluentFTP;
-using System.Threading;
-using System.Threading.Tasks;
namespace Files.App.Storage.FtpStorage
{
diff --git a/src/Files.App.Storage/FtpStorage/FtpStorageFile.cs b/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFile.cs
similarity index 80%
rename from src/Files.App.Storage/FtpStorage/FtpStorageFile.cs
rename to src/Files.App.Storage/Storables/FtpStorage/FtpStorageFile.cs
index 216b27782546..f36db8c53746 100644
--- a/src/Files.App.Storage/FtpStorage/FtpStorageFile.cs
+++ b/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFile.cs
@@ -1,14 +1,7 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage;
-using Files.Core.Storage.LocatableStorage;
-using Files.Core.Storage.ModifiableStorage;
-using Files.Core.Storage.NestedStorage;
-using System;
using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
namespace Files.App.Storage.FtpStorage
{
diff --git a/src/Files.App.Storage/FtpStorage/FtpStorageFolder.cs b/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFolder.cs
similarity index 93%
rename from src/Files.App.Storage/FtpStorage/FtpStorageFolder.cs
rename to src/Files.App.Storage/Storables/FtpStorage/FtpStorageFolder.cs
index 7943e474dde7..861f905f9cc7 100644
--- a/src/Files.App.Storage/FtpStorage/FtpStorageFolder.cs
+++ b/src/Files.App.Storage/Storables/FtpStorage/FtpStorageFolder.cs
@@ -1,22 +1,10 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage;
-using Files.Core.Storage.DirectStorage;
-using Files.Core.Storage.Enums;
-using Files.Core.Storage.ExtendableStorage;
-using Files.Core.Storage.Extensions;
-using Files.Core.Storage.LocatableStorage;
-using Files.Core.Storage.ModifiableStorage;
-using Files.Core.Storage.NestedStorage;
using Files.Shared.Helpers;
using FluentFTP;
-using System;
-using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
-using System.Threading;
-using System.Threading.Tasks;
namespace Files.App.Storage.FtpStorage
{
diff --git a/src/Files.App.Storage/FtpStorage/FtpStorageService.cs b/src/Files.App.Storage/Storables/FtpStorage/FtpStorageService.cs
similarity index 91%
rename from src/Files.App.Storage/FtpStorage/FtpStorageService.cs
rename to src/Files.App.Storage/Storables/FtpStorage/FtpStorageService.cs
index ca0246c7fa88..2116ce251095 100644
--- a/src/Files.App.Storage/FtpStorage/FtpStorageService.cs
+++ b/src/Files.App.Storage/Storables/FtpStorage/FtpStorageService.cs
@@ -1,12 +1,8 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage;
-using Files.Core.Storage.LocatableStorage;
using FluentFTP;
using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
namespace Files.App.Storage.FtpStorage
{
diff --git a/src/Files.App.Storage/NativeStorage/NativeFile.cs b/src/Files.App.Storage/Storables/NativeStorage/NativeFile.cs
similarity index 79%
rename from src/Files.App.Storage/NativeStorage/NativeFile.cs
rename to src/Files.App.Storage/Storables/NativeStorage/NativeFile.cs
index d1e501427109..56ec529b3509 100644
--- a/src/Files.App.Storage/NativeStorage/NativeFile.cs
+++ b/src/Files.App.Storage/Storables/NativeStorage/NativeFile.cs
@@ -1,14 +1,7 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage;
-using Files.Core.Storage.ExtendableStorage;
-using Files.Core.Storage.LocatableStorage;
-using Files.Core.Storage.ModifiableStorage;
-using Files.Core.Storage.NestedStorage;
using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
namespace Files.App.Storage.NativeStorage
{
diff --git a/src/Files.App.Storage/NativeStorage/NativeFolder.cs b/src/Files.App.Storage/Storables/NativeStorage/NativeFolder.cs
similarity index 91%
rename from src/Files.App.Storage/NativeStorage/NativeFolder.cs
rename to src/Files.App.Storage/Storables/NativeStorage/NativeFolder.cs
index aefd07d21c0b..4ed18dd0e88c 100644
--- a/src/Files.App.Storage/NativeStorage/NativeFolder.cs
+++ b/src/Files.App.Storage/Storables/NativeStorage/NativeFolder.cs
@@ -1,21 +1,8 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage;
-using Files.Core.Storage.DirectStorage;
-using Files.Core.Storage.Enums;
-using Files.Core.Storage.ExtendableStorage;
-using Files.Core.Storage.Extensions;
-using Files.Core.Storage.LocatableStorage;
-using Files.Core.Storage.ModifiableStorage;
-using Files.Core.Storage.MutableStorage;
-using Files.Core.Storage.NestedStorage;
-using System;
-using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
-using System.Threading;
-using System.Threading.Tasks;
namespace Files.App.Storage.NativeStorage
{
diff --git a/src/Files.App.Storage/NativeStorage/NativeStorable.cs b/src/Files.App.Storage/Storables/NativeStorage/NativeStorable.cs
similarity index 90%
rename from src/Files.App.Storage/NativeStorage/NativeStorable.cs
rename to src/Files.App.Storage/Storables/NativeStorage/NativeStorable.cs
index b568eb0e53dd..dd1146f49341 100644
--- a/src/Files.App.Storage/NativeStorage/NativeStorable.cs
+++ b/src/Files.App.Storage/Storables/NativeStorage/NativeStorable.cs
@@ -1,12 +1,7 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage;
-using Files.Core.Storage.LocatableStorage;
-using Files.Core.Storage.NestedStorage;
using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
namespace Files.App.Storage.NativeStorage
{
diff --git a/src/Files.App.Storage/NativeStorage/NativeStorageService.cs b/src/Files.App.Storage/Storables/NativeStorage/NativeStorageService.cs
similarity index 92%
rename from src/Files.App.Storage/NativeStorage/NativeStorageService.cs
rename to src/Files.App.Storage/Storables/NativeStorage/NativeStorageService.cs
index 657a89e44abe..3ac2e92a2ef2 100644
--- a/src/Files.App.Storage/NativeStorage/NativeStorageService.cs
+++ b/src/Files.App.Storage/Storables/NativeStorage/NativeStorageService.cs
@@ -1,12 +1,8 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage;
using Files.Shared.Helpers;
-using System;
using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
using Windows.Storage;
namespace Files.App.Storage.NativeStorage
diff --git a/src/Files.App.Storage/WindowsStorage/WindowsStorable.cs b/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorable.cs
similarity index 85%
rename from src/Files.App.Storage/WindowsStorage/WindowsStorable.cs
rename to src/Files.App.Storage/Storables/WindowsStorage/WindowsStorable.cs
index fda9670dcb07..9fb454192f51 100644
--- a/src/Files.App.Storage/WindowsStorage/WindowsStorable.cs
+++ b/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorable.cs
@@ -1,12 +1,7 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage;
-using Files.Core.Storage.LocatableStorage;
-using Files.Core.Storage.NestedStorage;
using Files.Shared.Helpers;
-using System.Threading;
-using System.Threading.Tasks;
using Windows.Storage;
namespace Files.App.Storage.WindowsStorage
diff --git a/src/Files.App.Storage/WindowsStorage/WindowsStorageFile.cs b/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageFile.cs
similarity index 89%
rename from src/Files.App.Storage/WindowsStorage/WindowsStorageFile.cs
rename to src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageFile.cs
index 1663ec507260..1063ba538753 100644
--- a/src/Files.App.Storage/WindowsStorage/WindowsStorageFile.cs
+++ b/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageFile.cs
@@ -1,15 +1,7 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage;
-using Files.Core.Storage.ExtendableStorage;
-using Files.Core.Storage.LocatableStorage;
-using Files.Core.Storage.ModifiableStorage;
-using Files.Core.Storage.NestedStorage;
-using System;
using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
using Windows.Storage;
namespace Files.App.Storage.WindowsStorage
diff --git a/src/Files.App.Storage/WindowsStorage/WindowsStorageFolder.cs b/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageFolder.cs
similarity index 93%
rename from src/Files.App.Storage/WindowsStorage/WindowsStorageFolder.cs
rename to src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageFolder.cs
index 95cb70c9d600..c5d5bfa9f522 100644
--- a/src/Files.App.Storage/WindowsStorage/WindowsStorageFolder.cs
+++ b/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageFolder.cs
@@ -1,19 +1,8 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage;
-using Files.Core.Storage.Enums;
-using Files.Core.Storage.LocatableStorage;
-using Files.Core.Storage.ModifiableStorage;
-using System;
-using System.Collections.Generic;
using System.Runtime.CompilerServices;
-using System.Threading;
-using System.Threading.Tasks;
using Windows.Storage;
-using Files.Core.Storage.DirectStorage;
-using Files.Core.Storage.ExtendableStorage;
-using Files.Core.Storage.NestedStorage;
namespace Files.App.Storage.WindowsStorage
{
diff --git a/src/Files.App.Storage/WindowsStorage/WindowsStorageService.cs b/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageService.cs
similarity index 85%
rename from src/Files.App.Storage/WindowsStorage/WindowsStorageService.cs
rename to src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageService.cs
index 594e7f66c7aa..b72c5e2d95b4 100644
--- a/src/Files.App.Storage/WindowsStorage/WindowsStorageService.cs
+++ b/src/Files.App.Storage/Storables/WindowsStorage/WindowsStorageService.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage;
-using Files.Core.Storage.LocatableStorage;
-using System;
-using System.Threading;
-using System.Threading.Tasks;
using Windows.Storage;
namespace Files.App.Storage.WindowsStorage
diff --git a/src/Files.Core.Storage/Data/Contracts/IDeviceWatcher.cs b/src/Files.Core.Storage/Contracts/IDeviceWatcher.cs
similarity index 96%
rename from src/Files.Core.Storage/Data/Contracts/IDeviceWatcher.cs
rename to src/Files.Core.Storage/Contracts/IDeviceWatcher.cs
index ac172590e288..3d221a947a5f 100644
--- a/src/Files.Core.Storage/Data/Contracts/IDeviceWatcher.cs
+++ b/src/Files.Core.Storage/Contracts/IDeviceWatcher.cs
@@ -1,7 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.
-namespace Files.Core.Storage.Data.Contracts
+namespace Files.Core.Storage.Contracts
{
internal interface IDeviceWatcher
{
diff --git a/src/Files.Core.Storage/Data/Contracts/IFolderWatcher.cs b/src/Files.Core.Storage/Contracts/IFolderWatcher.cs
similarity index 95%
rename from src/Files.Core.Storage/Data/Contracts/IFolderWatcher.cs
rename to src/Files.Core.Storage/Contracts/IFolderWatcher.cs
index 9a8cdc1ace4d..29ccea9c79da 100644
--- a/src/Files.Core.Storage/Data/Contracts/IFolderWatcher.cs
+++ b/src/Files.Core.Storage/Contracts/IFolderWatcher.cs
@@ -4,7 +4,7 @@
using Files.Core.Storage.MutableStorage;
using System.Collections.Specialized;
-namespace Files.Core.Storage.Data.Contracts
+namespace Files.Core.Storage.Contracts
{
public interface IFolderWatcher : INotifyCollectionChanged
{
diff --git a/src/Files.Core.Storage/Data/Contracts/ITrashWatcher.cs b/src/Files.Core.Storage/Contracts/ITrashWatcher.cs
similarity index 95%
rename from src/Files.Core.Storage/Data/Contracts/ITrashWatcher.cs
rename to src/Files.Core.Storage/Contracts/ITrashWatcher.cs
index ba5eee725be8..0bf261fe07a6 100644
--- a/src/Files.Core.Storage/Data/Contracts/ITrashWatcher.cs
+++ b/src/Files.Core.Storage/Contracts/ITrashWatcher.cs
@@ -1,7 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.
-namespace Files.Core.Storage.Data.Contracts
+namespace Files.Core.Storage.Contracts
{
public interface ITrashWatcher
{
diff --git a/src/Files.Core.Storage/Data/Contracts/IWatcher.cs b/src/Files.Core.Storage/Contracts/IWatcher.cs
similarity index 90%
rename from src/Files.Core.Storage/Data/Contracts/IWatcher.cs
rename to src/Files.Core.Storage/Contracts/IWatcher.cs
index bba1930677dc..0349788552c5 100644
--- a/src/Files.Core.Storage/Data/Contracts/IWatcher.cs
+++ b/src/Files.Core.Storage/Contracts/IWatcher.cs
@@ -1,7 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.
-namespace Files.Core.Storage.Data.Contracts
+namespace Files.Core.Storage.Contracts
{
///
/// A disposable object which can notify of changes to the folder.
diff --git a/src/Files.Core.Storage/Data/Enums/StorableKind.cs b/src/Files.Core.Storage/Enums/StorableKind.cs
similarity index 94%
rename from src/Files.Core.Storage/Data/Enums/StorableKind.cs
rename to src/Files.Core.Storage/Enums/StorableKind.cs
index 8077d353e093..fcbb1e3971e5 100644
--- a/src/Files.Core.Storage/Data/Enums/StorableKind.cs
+++ b/src/Files.Core.Storage/Enums/StorableKind.cs
@@ -1,8 +1,6 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using System;
-
namespace Files.Core.Storage.Enums
{
[Flags]
diff --git a/src/Files.Core.Storage/Data/EventArguments/DeviceEventArgs.cs b/src/Files.Core.Storage/EventArguments/DeviceEventArgs.cs
similarity index 87%
rename from src/Files.Core.Storage/Data/EventArguments/DeviceEventArgs.cs
rename to src/Files.Core.Storage/EventArguments/DeviceEventArgs.cs
index ca1aa7e0d555..2d004c8a3de8 100644
--- a/src/Files.Core.Storage/Data/EventArguments/DeviceEventArgs.cs
+++ b/src/Files.Core.Storage/EventArguments/DeviceEventArgs.cs
@@ -1,7 +1,7 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-namespace Files.Core.Storage.Data.EventArguments
+namespace Files.Core.Storage.EventArguments
{
public sealed class DeviceEventArgs : EventArgs
{
diff --git a/src/Files.Core.Storage/Extensions/StorageExtensions.File.cs b/src/Files.Core.Storage/Extensions/StorageExtensions.File.cs
index 25f110faec7c..d48bc4927737 100644
--- a/src/Files.Core.Storage/Extensions/StorageExtensions.File.cs
+++ b/src/Files.Core.Storage/Extensions/StorageExtensions.File.cs
@@ -1,11 +1,7 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage.ExtendableStorage;
-using System;
using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
namespace Files.Core.Storage.Extensions
{
diff --git a/src/Files.Core.Storage/Extensions/StorageExtensions.Folder.cs b/src/Files.Core.Storage/Extensions/StorageExtensions.Folder.cs
index 5264d3b3929e..1d2f0d3bff38 100644
--- a/src/Files.Core.Storage/Extensions/StorageExtensions.Folder.cs
+++ b/src/Files.Core.Storage/Extensions/StorageExtensions.Folder.cs
@@ -1,11 +1,7 @@
-using Files.Core.Storage.Enums;
-using Files.Core.Storage.ExtendableStorage;
-using Files.Core.Storage.ModifiableStorage;
-using System;
-using System.Collections.Generic;
+// Copyright (c) 2024 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
using System.Runtime.CompilerServices;
-using System.Threading;
-using System.Threading.Tasks;
namespace Files.Core.Storage.Extensions
{
diff --git a/src/Files.Core.Storage/Extensions/StorageExtensions.Service.cs b/src/Files.Core.Storage/Extensions/StorageExtensions.Service.cs
index 9974f1577aa3..e8d61f495f6d 100644
--- a/src/Files.Core.Storage/Extensions/StorageExtensions.Service.cs
+++ b/src/Files.Core.Storage/Extensions/StorageExtensions.Service.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage.LocatableStorage;
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-
namespace Files.Core.Storage.Extensions
{
public static partial class StorageExtensions
diff --git a/src/Files.Core.Storage/Extensions/StorageExtensions.Storable.cs b/src/Files.Core.Storage/Extensions/StorageExtensions.Storable.cs
index b3c74268735c..8aa6f2c52e2a 100644
--- a/src/Files.Core.Storage/Extensions/StorageExtensions.Storable.cs
+++ b/src/Files.Core.Storage/Extensions/StorageExtensions.Storable.cs
@@ -1,8 +1,6 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage.LocatableStorage;
-
namespace Files.Core.Storage.Extensions
{
public static partial class StorageExtensions
diff --git a/src/Files.Core.Storage/GlobalUsings.cs b/src/Files.Core.Storage/GlobalUsings.cs
index 92e96b100e33..e96c02e065d2 100644
--- a/src/Files.Core.Storage/GlobalUsings.cs
+++ b/src/Files.Core.Storage/GlobalUsings.cs
@@ -18,8 +18,14 @@
// Files.Core.Storage
global using global::Files.Core.Storage;
-global using global::Files.Core.Storage.Data.Contracts;
-global using global::Files.Core.Storage.Data.EventArguments;
+global using global::Files.Core.Storage.Contracts;
+global using global::Files.Core.Storage.DirectStorage;
global using global::Files.Core.Storage.Enums;
+global using global::Files.Core.Storage.EventArguments;
+global using global::Files.Core.Storage.ExtendableStorage;
+global using global::Files.Core.Storage.Extensions;
global using global::Files.Core.Storage.LocatableStorage;
+global using global::Files.Core.Storage.ModifiableStorage;
+global using global::Files.Core.Storage.MutableStorage;
global using global::Files.Core.Storage.NestedStorage;
+global using global::Files.Core.Storage.StorageEnumeration;
diff --git a/src/Files.Core.Storage/MutableStorage/IMutableFolder.cs b/src/Files.Core.Storage/MutableStorage/IMutableFolder.cs
deleted file mode 100644
index 73d0841b7f4c..000000000000
--- a/src/Files.Core.Storage/MutableStorage/IMutableFolder.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2024 Files Community
-// Licensed under the MIT License. See the LICENSE.
-
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Files.Core.Storage.MutableStorage
-{
- ///
- /// Represents a folder whose content can change.
- ///
- public interface IMutableFolder
- {
- ///
- /// Asynchronously retrieves a disposable object which can notify of changes to the folder.
- ///
- /// A Task representing the asynchronous operation. The result is a disposable object which can notify of changes to the folder.
- public Task GetFolderWatcherAsync(CancellationToken cancellationToken = default);
- }
-}
diff --git a/src/Files.Core.Storage/DirectStorage/IDirectCopy.cs b/src/Files.Core.Storage/Storables/DirectStorage/IDirectCopy.cs
similarity index 76%
rename from src/Files.Core.Storage/DirectStorage/IDirectCopy.cs
rename to src/Files.Core.Storage/Storables/DirectStorage/IDirectCopy.cs
index b03bf7974834..a6e1948b6e43 100644
--- a/src/Files.Core.Storage/DirectStorage/IDirectCopy.cs
+++ b/src/Files.Core.Storage/Storables/DirectStorage/IDirectCopy.cs
@@ -1,7 +1,5 @@
-using Files.Core.Storage.ModifiableStorage;
-using Files.Core.Storage.NestedStorage;
-using System.Threading;
-using System.Threading.Tasks;
+// Copyright (c) 2024 Files Community
+// Licensed under the MIT License. See the LICENSE.
namespace Files.Core.Storage.DirectStorage
{
diff --git a/src/Files.Core.Storage/DirectStorage/IDirectMove.cs b/src/Files.Core.Storage/Storables/DirectStorage/IDirectMove.cs
similarity index 79%
rename from src/Files.Core.Storage/DirectStorage/IDirectMove.cs
rename to src/Files.Core.Storage/Storables/DirectStorage/IDirectMove.cs
index 074391439215..c843dd2c7c65 100644
--- a/src/Files.Core.Storage/DirectStorage/IDirectMove.cs
+++ b/src/Files.Core.Storage/Storables/DirectStorage/IDirectMove.cs
@@ -1,7 +1,5 @@
-using Files.Core.Storage.ModifiableStorage;
-using Files.Core.Storage.NestedStorage;
-using System.Threading;
-using System.Threading.Tasks;
+// Copyright (c) 2024 Files Community
+// Licensed under the MIT License. See the LICENSE.
namespace Files.Core.Storage.DirectStorage
{
diff --git a/src/Files.Core.Storage/ExtendableStorage/IFileExtended.cs b/src/Files.Core.Storage/Storables/ExtendableStorage/IFileExtended.cs
similarity index 91%
rename from src/Files.Core.Storage/ExtendableStorage/IFileExtended.cs
rename to src/Files.Core.Storage/Storables/ExtendableStorage/IFileExtended.cs
index fbcedbb21f34..7c4501672a37 100644
--- a/src/Files.Core.Storage/ExtendableStorage/IFileExtended.cs
+++ b/src/Files.Core.Storage/Storables/ExtendableStorage/IFileExtended.cs
@@ -2,8 +2,6 @@
// Licensed under the MIT License. See the LICENSE.
using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
namespace Files.Core.Storage.ExtendableStorage
{
diff --git a/src/Files.Core.Storage/ExtendableStorage/IFolderExtended.cs b/src/Files.Core.Storage/Storables/ExtendableStorage/IFolderExtended.cs
similarity index 92%
rename from src/Files.Core.Storage/ExtendableStorage/IFolderExtended.cs
rename to src/Files.Core.Storage/Storables/ExtendableStorage/IFolderExtended.cs
index 05f06ed27caf..fe9952cc2504 100644
--- a/src/Files.Core.Storage/ExtendableStorage/IFolderExtended.cs
+++ b/src/Files.Core.Storage/Storables/ExtendableStorage/IFolderExtended.cs
@@ -1,6 +1,5 @@
-using Files.Core.Storage.NestedStorage;
-using System.Threading;
-using System.Threading.Tasks;
+// Copyright (c) 2024 Files Community
+// Licensed under the MIT License. See the LICENSE.
namespace Files.Core.Storage.ExtendableStorage
{
diff --git a/src/Files.Core.Storage/IFile.cs b/src/Files.Core.Storage/Storables/IFile.cs
similarity index 93%
rename from src/Files.Core.Storage/IFile.cs
rename to src/Files.Core.Storage/Storables/IFile.cs
index 639336501249..83d3038738d7 100644
--- a/src/Files.Core.Storage/IFile.cs
+++ b/src/Files.Core.Storage/Storables/IFile.cs
@@ -2,8 +2,6 @@
// Licensed under the MIT License. See the LICENSE.
using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
namespace Files.Core.Storage
{
diff --git a/src/Files.Core.Storage/IFolder.cs b/src/Files.Core.Storage/Storables/IFolder.cs
similarity index 85%
rename from src/Files.Core.Storage/IFolder.cs
rename to src/Files.Core.Storage/Storables/IFolder.cs
index 999c32acbf3f..a2752787e575 100644
--- a/src/Files.Core.Storage/IFolder.cs
+++ b/src/Files.Core.Storage/Storables/IFolder.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage.Enums;
-using Files.Core.Storage.NestedStorage;
-using System.Collections.Generic;
-using System.Threading;
-
namespace Files.Core.Storage
{
///
diff --git a/src/Files.Core.Storage/IStorable.cs b/src/Files.Core.Storage/Storables/IStorable.cs
similarity index 100%
rename from src/Files.Core.Storage/IStorable.cs
rename to src/Files.Core.Storage/Storables/IStorable.cs
diff --git a/src/Files.Core.Storage/LocatableStorage/ILocatableFile.cs b/src/Files.Core.Storage/Storables/LocatableStorage/ILocatableFile.cs
similarity index 100%
rename from src/Files.Core.Storage/LocatableStorage/ILocatableFile.cs
rename to src/Files.Core.Storage/Storables/LocatableStorage/ILocatableFile.cs
diff --git a/src/Files.Core.Storage/LocatableStorage/ILocatableFolder.cs b/src/Files.Core.Storage/Storables/LocatableStorage/ILocatableFolder.cs
similarity index 100%
rename from src/Files.Core.Storage/LocatableStorage/ILocatableFolder.cs
rename to src/Files.Core.Storage/Storables/LocatableStorage/ILocatableFolder.cs
diff --git a/src/Files.Core.Storage/LocatableStorage/ILocatableStorable.cs b/src/Files.Core.Storage/Storables/LocatableStorage/ILocatableStorable.cs
similarity index 100%
rename from src/Files.Core.Storage/LocatableStorage/ILocatableStorable.cs
rename to src/Files.Core.Storage/Storables/LocatableStorage/ILocatableStorable.cs
diff --git a/src/Files.Core.Storage/ModifiableStorage/IModifiableFile.cs b/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableFile.cs
similarity index 100%
rename from src/Files.Core.Storage/ModifiableStorage/IModifiableFile.cs
rename to src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableFile.cs
diff --git a/src/Files.Core.Storage/ModifiableStorage/IModifiableFolder.cs b/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableFolder.cs
similarity index 91%
rename from src/Files.Core.Storage/ModifiableStorage/IModifiableFolder.cs
rename to src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableFolder.cs
index a2eb49016adf..a9d5ad7cfa98 100644
--- a/src/Files.Core.Storage/ModifiableStorage/IModifiableFolder.cs
+++ b/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableFolder.cs
@@ -1,10 +1,6 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using Files.Core.Storage.NestedStorage;
-using System.Threading;
-using System.Threading.Tasks;
-
namespace Files.Core.Storage.ModifiableStorage
{
///
diff --git a/src/Files.Core.Storage/ModifiableStorage/IModifiableStorable.cs b/src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableStorable.cs
similarity index 100%
rename from src/Files.Core.Storage/ModifiableStorage/IModifiableStorable.cs
rename to src/Files.Core.Storage/Storables/ModifiableStorage/IModifiableStorable.cs
diff --git a/src/Files.Core.Storage/Storables/MutableStorage/IMutableFolder.cs b/src/Files.Core.Storage/Storables/MutableStorage/IMutableFolder.cs
new file mode 100644
index 000000000000..3e75ac55cd6b
--- /dev/null
+++ b/src/Files.Core.Storage/Storables/MutableStorage/IMutableFolder.cs
@@ -0,0 +1,12 @@
+// Copyright (c) 2024 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
+namespace Files.Core.Storage.MutableStorage
+{
+ ///
+ /// Represents a folder whose content can change.
+ ///
+ public interface IMutableFolder
+ {
+ }
+}
diff --git a/src/Files.Core.Storage/NestedStorage/INestedFile.cs b/src/Files.Core.Storage/Storables/NestedStorage/INestedFile.cs
similarity index 57%
rename from src/Files.Core.Storage/NestedStorage/INestedFile.cs
rename to src/Files.Core.Storage/Storables/NestedStorage/INestedFile.cs
index ab588728f88b..2e631a7d57a9 100644
--- a/src/Files.Core.Storage/NestedStorage/INestedFile.cs
+++ b/src/Files.Core.Storage/Storables/NestedStorage/INestedFile.cs
@@ -1,4 +1,7 @@
-namespace Files.Core.Storage.NestedStorage
+// Copyright (c) 2024 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
+namespace Files.Core.Storage.NestedStorage
{
///
/// Represents a file that resides within a traversable folder structure.
diff --git a/src/Files.Core.Storage/NestedStorage/INestedFolder.cs b/src/Files.Core.Storage/Storables/NestedStorage/INestedFolder.cs
similarity index 58%
rename from src/Files.Core.Storage/NestedStorage/INestedFolder.cs
rename to src/Files.Core.Storage/Storables/NestedStorage/INestedFolder.cs
index 2b098bf178bc..592b771efe25 100644
--- a/src/Files.Core.Storage/NestedStorage/INestedFolder.cs
+++ b/src/Files.Core.Storage/Storables/NestedStorage/INestedFolder.cs
@@ -1,4 +1,7 @@
-namespace Files.Core.Storage.NestedStorage
+// Copyright (c) 2024 Files Community
+// Licensed under the MIT License. See the LICENSE.
+
+namespace Files.Core.Storage.NestedStorage
{
///
/// Represents a folder that resides within a traversable folder structure.
diff --git a/src/Files.Core.Storage/NestedStorage/INestedStorable.cs b/src/Files.Core.Storage/Storables/NestedStorage/INestedStorable.cs
similarity index 81%
rename from src/Files.Core.Storage/NestedStorage/INestedStorable.cs
rename to src/Files.Core.Storage/Storables/NestedStorage/INestedStorable.cs
index 9bda622de1cc..df0f4eeb9ea4 100644
--- a/src/Files.Core.Storage/NestedStorage/INestedStorable.cs
+++ b/src/Files.Core.Storage/Storables/NestedStorage/INestedStorable.cs
@@ -1,5 +1,5 @@
-using System.Threading;
-using System.Threading.Tasks;
+// Copyright (c) 2024 Files Community
+// Licensed under the MIT License. See the LICENSE.
namespace Files.Core.Storage.NestedStorage
{
diff --git a/src/Files.Core.Storage/StorageEnumeration/IStorageEnumerator.cs b/src/Files.Core.Storage/StorageEnumeration/IStorageEnumerator.cs
index 211ee0ad9fb5..21905bbe51a7 100644
--- a/src/Files.Core.Storage/StorageEnumeration/IStorageEnumerator.cs
+++ b/src/Files.Core.Storage/StorageEnumeration/IStorageEnumerator.cs
@@ -1,10 +1,6 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
-using System;
-using System.Collections.Generic;
-using System.Threading;
-
namespace Files.Core.Storage.StorageEnumeration
{
///
From 27eade09ffd14932f1057ea186d39bc60ada8c44 Mon Sep 17 00:00:00 2001
From: 0x5bfa <62196528+0x5bfa@users.noreply.github.com>
Date: Thu, 16 May 2024 09:50:45 +0900
Subject: [PATCH 3/4] Revert
---
.../Storables/NativeStorage/NativeFolder.cs | 146 +++++++++---------
src/Files.App/GlobalUsings.cs | 10 +-
2 files changed, 81 insertions(+), 75 deletions(-)
diff --git a/src/Files.App.Storage/Storables/NativeStorage/NativeFolder.cs b/src/Files.App.Storage/Storables/NativeStorage/NativeFolder.cs
index 4ed18dd0e88c..313e6d5af780 100644
--- a/src/Files.App.Storage/Storables/NativeStorage/NativeFolder.cs
+++ b/src/Files.App.Storage/Storables/NativeStorage/NativeFolder.cs
@@ -8,83 +8,83 @@ namespace Files.App.Storage.NativeStorage
{
///
public class NativeFolder : NativeStorable, ILocatableFolder, IModifiableFolder, IMutableFolder, IFolderExtended, INestedFolder, IDirectCopy, IDirectMove
- {
+ {
public NativeFolder(DirectoryInfo directoryInfo, string? name = null)
- : base(directoryInfo, name)
- {
- }
-
- public NativeFolder(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 NativeFile(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 NativeFolder(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 NativeFile(item);
- }
- else if (kind == StorableKind.Folders)
- {
- foreach (var item in Directory.EnumerateDirectories(Path))
- yield return new NativeFolder(item);
- }
- else
- {
- foreach (var item in Directory.EnumerateFileSystemEntries(Path))
- {
- if (File.Exists(item))
- yield return new NativeFile(item);
- else
- yield return new NativeFolder(item);
- }
- }
-
- await Task.CompletedTask;
- }
+ : base(directoryInfo, name)
+ {
+ }
+
+ public NativeFolder(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 NativeFile(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 NativeFolder(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 NativeFile(item);
+ }
+ else if (kind == StorableKind.Folders)
+ {
+ foreach (var item in Directory.EnumerateDirectories(Path))
+ yield return new NativeFolder(item);
+ }
+ else
+ {
+ foreach (var item in Directory.EnumerateFileSystemEntries(Path))
+ {
+ if (File.Exists(item))
+ yield return new NativeFile(item);
+ else
+ yield return new NativeFolder(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;
- }
+ {
+ _ = 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)
diff --git a/src/Files.App/GlobalUsings.cs b/src/Files.App/GlobalUsings.cs
index 63aa054fe298..b60e36cbe396 100644
--- a/src/Files.App/GlobalUsings.cs
+++ b/src/Files.App/GlobalUsings.cs
@@ -72,11 +72,17 @@
// Files.Core.Storage
global using global::Files.Core.Storage;
-global using global::Files.Core.Storage.Data.Contracts;
-global using global::Files.Core.Storage.Data.EventArguments;
+global using global::Files.Core.Storage.Contracts;
+global using global::Files.Core.Storage.DirectStorage;
global using global::Files.Core.Storage.Enums;
+global using global::Files.Core.Storage.EventArguments;
+global using global::Files.Core.Storage.ExtendableStorage;
+global using global::Files.Core.Storage.Extensions;
global using global::Files.Core.Storage.LocatableStorage;
+global using global::Files.Core.Storage.ModifiableStorage;
+global using global::Files.Core.Storage.MutableStorage;
global using global::Files.Core.Storage.NestedStorage;
+global using global::Files.Core.Storage.StorageEnumeration;
// Files.Shared
global using global::Files.Shared;
From 92d13c430f2a7a4f0beb5a39a7093b74786e39ad Mon Sep 17 00:00:00 2001
From: 0x5bfa <62196528+0x5bfa@users.noreply.github.com>
Date: Fri, 17 May 2024 08:32:16 +0900
Subject: [PATCH 4/4] Update src/Files.Core.Storage/Contracts/IWatcher.cs
Co-authored-by: Yair <39923744+yaira2@users.noreply.github.com>
---
src/Files.Core.Storage/Contracts/IWatcher.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Files.Core.Storage/Contracts/IWatcher.cs b/src/Files.Core.Storage/Contracts/IWatcher.cs
index 0349788552c5..f62ad0ab065e 100644
--- a/src/Files.Core.Storage/Contracts/IWatcher.cs
+++ b/src/Files.Core.Storage/Contracts/IWatcher.cs
@@ -16,6 +16,6 @@ public interface IWatcher : IDisposable, IAsyncDisposable
///
/// Stops the watcher
///
- void StopsWatcher();
+ void StopWatcher();
}
}