From 81df0a6492f82486e5ba5cda6c331a713df28fac Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Wed, 19 Jul 2023 23:38:24 +0900 Subject: [PATCH] Code Quality: Introduced App.Utils.Storage namespace for storage functionalities (#12902) --- src/Files.App/App.xaml.cs | 1 - ...ecurityAdvancedAccessControlItemFactory.cs | 1 - src/Files.App/Data/Items/ListedItem.cs | 1 - src/Files.App/Data/Models/ItemViewModel.cs | 6 +- .../Extensions/ShellNewEntryExtensions.cs | 1 - src/Files.App/GlobalUsings.cs | 8 +- src/Files.App/Helpers/BitmapHelper.cs | 1 - .../Helpers/Navigation/NavigationHelpers.cs | 1 - src/Files.App/Helpers/ShareItemHelpers.cs | 1 - .../Helpers/UI/UIFilesystemHelpers.cs | 1 - src/Files.App/Services/QuickAccessService.cs | 1 - .../UserControls/SidebarControl.xaml.cs | 5 +- .../Widgets/RecentFilesWidget.xaml.cs | 2 - .../Utils/Archives/ArchiveHelpers.cs | 1 - src/Files.App/Utils/Archives/ZipHelpers.cs | 1 - .../Utils/Cloud/CloudDrivesDetector.cs | 2 +- .../Utils/{ => Global}/NetworkDrivesAPI.cs | 0 .../Utils/{ => Global}/QuickAccessManager.cs | 0 .../Utils/{ => Global}/WSLDistroManager.cs | 0 .../Utils/{ => Global}/WallpaperHelpers.cs | 2 +- .../WindowsStorageDeviceWatcher.cs | 0 src/Files.App/Utils/RecentItem/RecentItem.cs | 1 - .../Storage/Cache/IStorageCacheController.cs} | 9 +- .../Storage/Cache/StorageCacheController.cs} | 20 ++-- .../Collection}/BlockingListEnumerator.cs | 27 +++--- .../BulkConcurrentObservableCollection.cs | 10 +- .../Collection}/ConcurrentCollection.cs | 4 + .../Storage/Collection/GroupedCollection.cs | 80 ++++++++++++++++ .../Collection/GroupedHeaderViewModel.cs} | 94 +------------------ .../Storage/Collection}/GroupingHelper.cs | 7 +- .../Storage/Collection/IGroupableItem.cs | 10 ++ .../Collection/IGroupedCollectionHeader.cs | 16 ++++ .../Storage/Collection}/SortingHelper.cs | 7 +- .../UniversalStorageEnumerator.cs | 65 ++++++------- .../Enumerators}/Win32StorageEnumerator.cs | 62 ++++++------ .../Storage/Helpers}/DeviceManager.cs | 4 +- .../Storage/Helpers}/DriveHelpers.cs | 10 +- .../Storage/Helpers}/ErrorCodeConverter.cs | 2 +- .../Storage/Helpers}/FileOperationsHelpers.cs | 5 +- .../Storage/Helpers}/FilePropertiesHelpers.cs | 2 +- .../Storage/Helpers}/FileSecurityHelpers.cs | 4 +- .../Storage/Helpers}/FileThumbnailHelper.cs | 8 +- .../Helpers}/FilesystemResult.cs | 2 +- .../Helpers}/FilesystemTasks.cs | 2 +- .../Storage/Helpers}/FolderHelpers.cs | 6 +- .../Utils/{ => Storage/Helpers}/FtpHelpers.cs | 4 +- .../Helpers}/IStorageItemWithPath.cs | 2 +- .../Helpers}/StorageFileExtensions.cs | 14 +-- .../Helpers}/StorageFileWithPath.cs | 1 - .../Helpers}/StorageFolderWithPath.cs | 1 - .../Storage/Helpers}/StorageHelpers.cs | 6 -- .../Helpers}/StorageItemIconHelpers.cs | 4 +- .../Storage/Helpers}/StorageSenseHelper.cs | 5 +- .../History}/IStorageHistory.cs | 4 +- .../History}/IStorageHistoryOperations.cs | 5 +- .../History}/StorageHistory.cs | 5 +- .../History}/StorageHistoryHelpers.cs | 6 +- .../History}/StorageHistoryOperations.cs | 10 +- .../History}/StorageHistoryWrapper.cs | 5 +- .../Operations}/FileSystemProgress.cs | 2 +- .../Operations}/FilesystemHelpers.cs | 2 +- .../Operations}/FilesystemOperations.cs | 7 +- .../Operations}/IFilesystemHelpers.cs | 5 +- .../Operations}/IFilesystemOperations.cs | 3 +- .../Operations}/ShellFilesystemOperations.cs | 8 +- .../{ => Storage}/Search/FolderSearch.cs | 17 +--- .../Security/AccessControlEntry.cs | 11 +-- .../Security/AccessControlEntryFlags.cs | 2 +- .../Security/AccessControlEntryType.cs | 2 +- .../Security/AccessControlList.cs | 2 +- .../{ => Storage}/Security/AccessMaskFlags.cs | 4 +- .../{ => Storage}/Security/AccessMaskItem.cs | 5 +- .../Utils/{ => Storage}/Security/Principal.cs | 2 +- .../{ => Storage}/Security/PrincipalType.cs | 2 +- .../StorageBaseItems}/BaseBasicProperties.cs | 2 +- .../BaseBasicStorageItemExtraProperties.cs | 2 +- .../StorageBaseItems}/BaseStorageFile.cs | 2 +- .../StorageBaseItems}/BaseStorageFolder.cs | 2 +- .../BaseStorageItemExtraProperties.cs | 2 +- .../StorageBaseItems}/IBaseStorageFile.cs | 2 +- .../StorageBaseItems}/IBaseStorageFolder.cs | 2 +- .../ICreateFileWithStream.cs | 2 +- .../IPasswordProtectedItem.cs | 11 ++- .../StorageBaseItems}/StorageCredential.cs | 32 +++---- .../StorageItems/BaseQueryResults.cs | 5 +- .../StorageItems/FtpStorageFile.cs | 2 +- .../StorageItems/FtpStorageFolder.cs | 2 +- .../StorageItems/NativeStorageFile.cs | 8 +- .../StorageItems/ShellStorageFile.cs | 6 +- .../StorageItems/ShellStorageFolder.cs | 8 +- .../StorageItems/StreamWithContentType.cs | 2 +- .../StorageItems/SystemStorageFile.cs | 6 +- .../StorageItems/SystemStorageFolder.cs | 6 +- .../StorageItems/VirtualStorageFile.cs | 2 +- .../StorageItems/VirtualStorageFolder.cs | 2 +- .../StorageItems/VirtualStorageItem.cs | 5 +- .../StorageItems/ZipStorageFile.cs | 9 +- .../StorageItems/ZipStorageFolder.cs | 9 +- .../LayoutModes/BaseLayoutViewModel.cs | 1 - src/Files.App/ViewModels/MainPageViewModel.cs | 1 - .../ViewModels/Previews/BasePreviewModel.cs | 1 - .../Items/CombinedFileProperties.cs | 1 - .../Properties/Items/DriveProperties.cs | 1 - .../Properties/Items/FileProperties.cs | 1 - .../Properties/Items/FileProperty.cs | 1 - .../Properties/Items/FolderProperties.cs | 1 - .../Properties/Items/LibraryProperties.cs | 1 - .../Properties/SecurityAdvancedViewModel.cs | 1 - .../Properties/SecurityViewModel.cs | 1 - .../ViewModels/Settings/AdvancedViewModel.cs | 1 - src/Files.App/Views/LayoutModes/BaseLayout.cs | 2 +- .../Views/LayoutModes/ColumnViewBase.xaml | 23 ++--- .../LayoutModes/DetailsLayoutBrowser.xaml | 23 ++--- .../Views/LayoutModes/GridViewBrowser.xaml | 23 ++--- .../Properties/SecurityAdvancedPage.xaml | 2 +- .../Views/Properties/SecurityPage.xaml | 2 +- src/Files.App/Views/Shells/BaseShellPage.cs | 3 - src/Files.App/Views/Shells/IShellPage.cs | 1 - .../Files.Core.Storage.csproj | 5 - .../DirectStorage/IDirectCopy.cs | 18 ---- .../DirectStorage/IDirectMove.cs | 18 ---- .../NestedStorage/INestedFile.cs | 9 -- .../NestedStorage/INestedFolder.cs | 9 -- .../NestedStorage/INestedStorable.cs | 16 ---- 124 files changed, 333 insertions(+), 603 deletions(-) rename src/Files.App/Utils/{ => Global}/NetworkDrivesAPI.cs (100%) rename src/Files.App/Utils/{ => Global}/QuickAccessManager.cs (100%) rename src/Files.App/Utils/{ => Global}/WSLDistroManager.cs (100%) rename src/Files.App/Utils/{ => Global}/WallpaperHelpers.cs (98%) rename src/Files.App/Utils/{ => Global}/WindowsStorageDeviceWatcher.cs (100%) rename src/Files.App/{Helpers/StorageCache/IFileListCache.cs => Utils/Storage/Cache/IStorageCacheController.cs} (68%) rename src/Files.App/{Helpers/StorageCache/FileListCacheController.cs => Utils/Storage/Cache/StorageCacheController.cs} (67%) rename src/Files.App/{Helpers/StorageItemCollection => Utils/Storage/Collection}/BlockingListEnumerator.cs (84%) rename src/Files.App/{Helpers/StorageItemCollection => Utils/Storage/Collection}/BulkConcurrentObservableCollection.cs (97%) rename src/Files.App/{Helpers/StorageItemCollection => Utils/Storage/Collection}/ConcurrentCollection.cs (99%) create mode 100644 src/Files.App/Utils/Storage/Collection/GroupedCollection.cs rename src/Files.App/{Helpers/StorageItemCollection/GroupedCollection.cs => Utils/Storage/Collection/GroupedHeaderViewModel.cs} (51%) rename src/Files.App/{Helpers/StorageItemCollection => Utils/Storage/Collection}/GroupingHelper.cs (98%) create mode 100644 src/Files.App/Utils/Storage/Collection/IGroupableItem.cs create mode 100644 src/Files.App/Utils/Storage/Collection/IGroupedCollectionHeader.cs rename src/Files.App/{Helpers/StorageItemCollection => Utils/Storage/Collection}/SortingHelper.cs (97%) rename src/Files.App/Utils/{StorageEnumerators => Storage/Enumerators}/UniversalStorageEnumerator.cs (90%) rename src/Files.App/Utils/{StorageEnumerators => Storage/Enumerators}/Win32StorageEnumerator.cs (89%) rename src/Files.App/{Helpers/Storage => Utils/Storage/Helpers}/DeviceManager.cs (98%) rename src/Files.App/{Helpers/Storage => Utils/Storage/Helpers}/DriveHelpers.cs (95%) rename src/Files.App/{Helpers/Storage => Utils/Storage/Helpers}/ErrorCodeConverter.cs (95%) rename src/Files.App/{Helpers/Storage => Utils/Storage/Helpers}/FileOperationsHelpers.cs (99%) rename src/Files.App/{Helpers/Storage => Utils/Storage/Helpers}/FilePropertiesHelpers.cs (99%) rename src/Files.App/{Helpers/Storage => Utils/Storage/Helpers}/FileSecurityHelpers.cs (98%) rename src/Files.App/{Helpers/Storage => Utils/Storage/Helpers}/FileThumbnailHelper.cs (93%) rename src/Files.App/Utils/{StorageFileHelpers => Storage/Helpers}/FilesystemResult.cs (96%) rename src/Files.App/Utils/{StorageFileHelpers => Storage/Helpers}/FilesystemTasks.cs (98%) rename src/Files.App/{Helpers/Storage => Utils/Storage/Helpers}/FolderHelpers.cs (92%) rename src/Files.App/Utils/{ => Storage/Helpers}/FtpHelpers.cs (96%) rename src/Files.App/Utils/{StorageFileHelpers => Storage/Helpers}/IStorageItemWithPath.cs (90%) rename src/Files.App/Utils/{StorageFileHelpers => Storage/Helpers}/StorageFileExtensions.cs (97%) rename src/Files.App/Utils/{StorageFileHelpers => Storage/Helpers}/StorageFileWithPath.cs (94%) rename src/Files.App/Utils/{StorageFileHelpers => Storage/Helpers}/StorageFolderWithPath.cs (95%) rename src/Files.App/{Helpers/Storage => Utils/Storage/Helpers}/StorageHelpers.cs (97%) rename src/Files.App/{Helpers/Storage => Utils/Storage/Helpers}/StorageItemIconHelpers.cs (95%) rename src/Files.App/{Helpers/Storage => Utils/Storage/Helpers}/StorageSenseHelper.cs (86%) rename src/Files.App/Utils/{StorageHistory => Storage/History}/IStorageHistory.cs (92%) rename src/Files.App/Utils/{StorageHistory => Storage/History}/IStorageHistoryOperations.cs (86%) rename src/Files.App/Utils/{StorageHistory => Storage/History}/StorageHistory.cs (92%) rename src/Files.App/Utils/{StorageHistory/Helpers => Storage/History}/StorageHistoryHelpers.cs (92%) rename src/Files.App/Utils/{StorageHistory => Storage/History}/StorageHistoryOperations.cs (96%) rename src/Files.App/Utils/{StorageHistory => Storage/History}/StorageHistoryWrapper.cs (92%) rename src/Files.App/Utils/{FilesystemOperations => Storage/Operations}/FileSystemProgress.cs (98%) rename src/Files.App/Utils/{FilesystemOperations/Helpers => Storage/Operations}/FilesystemHelpers.cs (99%) rename src/Files.App/Utils/{FilesystemOperations => Storage/Operations}/FilesystemOperations.cs (99%) rename src/Files.App/Utils/{FilesystemOperations/Helpers => Storage/Operations}/IFilesystemHelpers.cs (99%) rename src/Files.App/Utils/{FilesystemOperations => Storage/Operations}/IFilesystemOperations.cs (99%) rename src/Files.App/Utils/{FilesystemOperations => Storage/Operations}/ShellFilesystemOperations.cs (99%) rename src/Files.App/Utils/{ => Storage}/Search/FolderSearch.cs (97%) rename src/Files.App/Utils/{ => Storage}/Security/AccessControlEntry.cs (97%) rename src/Files.App/Utils/{ => Storage}/Security/AccessControlEntryFlags.cs (97%) rename src/Files.App/Utils/{ => Storage}/Security/AccessControlEntryType.cs (90%) rename src/Files.App/Utils/{ => Storage}/Security/AccessControlList.cs (97%) rename src/Files.App/Utils/{ => Storage}/Security/AccessMaskFlags.cs (97%) rename src/Files.App/Utils/{ => Storage}/Security/AccessMaskItem.cs (92%) rename src/Files.App/Utils/{ => Storage}/Security/Principal.cs (98%) rename src/Files.App/Utils/{ => Storage}/Security/PrincipalType.cs (92%) rename src/Files.App/Utils/{BaseStorage => Storage/StorageBaseItems}/BaseBasicProperties.cs (89%) rename src/Files.App/Utils/{BaseStorage => Storage/StorageBaseItems}/BaseBasicStorageItemExtraProperties.cs (96%) rename src/Files.App/Utils/{BaseStorage => Storage/StorageBaseItems}/BaseStorageFile.cs (99%) rename src/Files.App/Utils/{BaseStorage => Storage/StorageBaseItems}/BaseStorageFolder.cs (99%) rename src/Files.App/Utils/{BaseStorage => Storage/StorageBaseItems}/BaseStorageItemExtraProperties.cs (96%) rename src/Files.App/Utils/{BaseStorage => Storage/StorageBaseItems}/IBaseStorageFile.cs (96%) rename src/Files.App/Utils/{BaseStorage => Storage/StorageBaseItems}/IBaseStorageFolder.cs (98%) rename src/Files.App/Utils/{BaseStorage => Storage/StorageBaseItems}/ICreateFileWithStream.cs (91%) rename src/Files.App/Utils/{BaseStorage => Storage/StorageBaseItems}/IPasswordProtectedItem.cs (90%) rename src/Files.App/Utils/{BaseStorage => Storage/StorageBaseItems}/StorageCredential.cs (88%) rename src/Files.App/Utils/{ => Storage}/StorageItems/BaseQueryResults.cs (98%) rename src/Files.App/Utils/{ => Storage}/StorageItems/FtpStorageFile.cs (99%) rename src/Files.App/Utils/{ => Storage}/StorageItems/FtpStorageFolder.cs (99%) rename src/Files.App/Utils/{ => Storage}/StorageItems/NativeStorageFile.cs (97%) rename src/Files.App/Utils/{ => Storage}/StorageItems/ShellStorageFile.cs (98%) rename src/Files.App/Utils/{ => Storage}/StorageItems/ShellStorageFolder.cs (98%) rename src/Files.App/Utils/{ => Storage}/StorageItems/StreamWithContentType.cs (99%) rename src/Files.App/Utils/{ => Storage}/StorageItems/SystemStorageFile.cs (98%) rename src/Files.App/Utils/{ => Storage}/StorageItems/SystemStorageFolder.cs (98%) rename src/Files.App/Utils/{ => Storage}/StorageItems/VirtualStorageFile.cs (99%) rename src/Files.App/Utils/{ => Storage}/StorageItems/VirtualStorageFolder.cs (99%) rename src/Files.App/Utils/{ => Storage}/StorageItems/VirtualStorageItem.cs (97%) rename src/Files.App/Utils/{ => Storage}/StorageItems/ZipStorageFile.cs (98%) rename src/Files.App/Utils/{ => Storage}/StorageItems/ZipStorageFolder.cs (99%) delete mode 100644 src/Files.Sdk.Storage/DirectStorage/IDirectCopy.cs delete mode 100644 src/Files.Sdk.Storage/DirectStorage/IDirectMove.cs delete mode 100644 src/Files.Sdk.Storage/NestedStorage/INestedFile.cs delete mode 100644 src/Files.Sdk.Storage/NestedStorage/INestedFolder.cs delete mode 100644 src/Files.Sdk.Storage/NestedStorage/INestedStorable.cs diff --git a/src/Files.App/App.xaml.cs b/src/Files.App/App.xaml.cs index 71e457778ffd..ca7690120654 100644 --- a/src/Files.App/App.xaml.cs +++ b/src/Files.App/App.xaml.cs @@ -7,7 +7,6 @@ using Files.App.Extensions; using Files.App.Utils; using Files.App.Utils.Cloud; -using Files.App.Utils.FilesystemHistory; using Files.App.Helpers; using Files.App.Services; using Files.App.Services.DateTimeFormatter; diff --git a/src/Files.App/Data/Factories/SecurityAdvancedAccessControlItemFactory.cs b/src/Files.App/Data/Factories/SecurityAdvancedAccessControlItemFactory.cs index fd6c21a9db8a..51a969765aaa 100644 --- a/src/Files.App/Data/Factories/SecurityAdvancedAccessControlItemFactory.cs +++ b/src/Files.App/Data/Factories/SecurityAdvancedAccessControlItemFactory.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See the LICENSE. using Files.App.Extensions; -using Files.App.Utils.Security; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/src/Files.App/Data/Items/ListedItem.cs b/src/Files.App/Data/Items/ListedItem.cs index 0f6b24f0b8a5..01d3badddb8f 100644 --- a/src/Files.App/Data/Items/ListedItem.cs +++ b/src/Files.App/Data/Items/ListedItem.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See the LICENSE. using Files.App.Utils.Cloud; -using Files.App.Utils.StorageItems; using Files.App.ViewModels.Properties; using Files.Core.Helpers; using Files.Core.ViewModels.FileTags; diff --git a/src/Files.App/Data/Models/ItemViewModel.cs b/src/Files.App/Data/Models/ItemViewModel.cs index ce0a017e158b..15819dd7223d 100644 --- a/src/Files.App/Data/Models/ItemViewModel.cs +++ b/src/Files.App/Data/Models/ItemViewModel.cs @@ -1,7 +1,9 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Helpers.StorageCache; +using Files.App.Utils.Cloud; +using Files.App.Utils.Shell; +using Files.App.Storage.FtpStorage; using Files.App.ViewModels.Previews; using Files.Core.Services.SizeProvider; using LibGit2Sharp; @@ -36,7 +38,7 @@ public sealed class ItemViewModel : ObservableObject, IDisposable private readonly AsyncManualResetEvent gitChangedEvent; private readonly DispatcherQueue dispatcherQueue; private readonly JsonElement defaultJson = JsonSerializer.SerializeToElement("{}"); - private readonly IFileListCache fileListCache = FileListCacheController.GetInstance(); + private readonly IStorageCacheController fileListCache = StorageCacheController.GetInstance(); private readonly string folderTypeTextLocalized = "Folder".GetLocalizedResource(); private Task? aProcessQueueAction; diff --git a/src/Files.App/Extensions/ShellNewEntryExtensions.cs b/src/Files.App/Extensions/ShellNewEntryExtensions.cs index f5cb1a81815c..65e6973f6002 100644 --- a/src/Files.App/Extensions/ShellNewEntryExtensions.cs +++ b/src/Files.App/Extensions/ShellNewEntryExtensions.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See the LICENSE. using Files.App.Utils; -using Files.App.Utils.StorageItems; using Files.App.Helpers; using Files.App.Utils.Shell; using Files.Shared; diff --git a/src/Files.App/GlobalUsings.cs b/src/Files.App/GlobalUsings.cs index d3b803619ebb..5f9e162f6e0a 100644 --- a/src/Files.App/GlobalUsings.cs +++ b/src/Files.App/GlobalUsings.cs @@ -19,24 +19,20 @@ global using global::CommunityToolkit.Mvvm.Input; global using global::CommunityToolkit.Mvvm.Messaging; -// Files Front-end +// Files.App global using global::Files.App.Helpers; global using global::Files.App.Extensions; global using global::Files.App.Utils; global using global::Files.App.Utils.Archives; global using global::Files.App.Utils.Cloud; -global using global::Files.App.Utils.FilesystemHistory; global using global::Files.App.Utils.FileTags; global using global::Files.App.Utils.Git; global using global::Files.App.Utils.Library; global using global::Files.App.Utils.RecentItem; global using global::Files.App.Utils.RecycleBin; -global using global::Files.App.Utils.Search; -global using global::Files.App.Utils.Security; global using global::Files.App.Utils.Serialization; global using global::Files.App.Utils.Shell; -global using global::Files.App.Utils.StorageEnumerators; -global using global::Files.App.Utils.StorageItems; +global using global::Files.App.Utils.Storage; global using global::Files.App.Data.Attributes; global using global::Files.App.Data.Behaviors; global using global::Files.App.Data.Commands; diff --git a/src/Files.App/Helpers/BitmapHelper.cs b/src/Files.App/Helpers/BitmapHelper.cs index fd9f082e7213..7d8791721366 100644 --- a/src/Files.App/Helpers/BitmapHelper.cs +++ b/src/Files.App/Helpers/BitmapHelper.cs @@ -1,7 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; using Microsoft.UI.Xaml.Media.Imaging; using System.IO; using Windows.Graphics.Imaging; diff --git a/src/Files.App/Helpers/Navigation/NavigationHelpers.cs b/src/Files.App/Helpers/Navigation/NavigationHelpers.cs index d71f0d01d1c2..ae0a93c54dba 100644 --- a/src/Files.App/Helpers/Navigation/NavigationHelpers.cs +++ b/src/Files.App/Helpers/Navigation/NavigationHelpers.cs @@ -4,7 +4,6 @@ using CommunityToolkit.Mvvm.DependencyInjection; using Files.App.Extensions; using Files.App.Utils; -using Files.App.Utils.StorageItems; using Files.App.Utils.Shell; using Files.App.ViewModels; using Files.App.Views; diff --git a/src/Files.App/Helpers/ShareItemHelpers.cs b/src/Files.App/Helpers/ShareItemHelpers.cs index 98390fa5027e..63ef8079b106 100644 --- a/src/Files.App/Helpers/ShareItemHelpers.cs +++ b/src/Files.App/Helpers/ShareItemHelpers.cs @@ -3,7 +3,6 @@ using Files.App.Extensions; using Files.App.Utils; -using Files.App.Utils.StorageItems; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs b/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs index b6d29c19e136..cdb08903d2ce 100644 --- a/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs +++ b/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See the LICENSE. using Files.App.Dialogs; -using Files.App.Utils.StorageItems; using Files.App.Storage.FtpStorage; using Files.App.ViewModels.Dialogs; using Microsoft.Extensions.Logging; diff --git a/src/Files.App/Services/QuickAccessService.cs b/src/Files.App/Services/QuickAccessService.cs index 228a5999efde..735c846961d5 100644 --- a/src/Files.App/Services/QuickAccessService.cs +++ b/src/Files.App/Services/QuickAccessService.cs @@ -1,7 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; using Files.App.Utils.Shell; using Files.App.UserControls.Widgets; diff --git a/src/Files.App/UserControls/SidebarControl.xaml.cs b/src/Files.App/UserControls/SidebarControl.xaml.cs index a1b1b935a845..f17140018ce7 100644 --- a/src/Files.App/UserControls/SidebarControl.xaml.cs +++ b/src/Files.App/UserControls/SidebarControl.xaml.cs @@ -8,7 +8,6 @@ using Files.App.Data.Items; using Files.App.Data.Models; using Files.App.Extensions; -using Files.App.Utils.StorageItems; using Files.App.Helpers.ContextFlyouts; using Files.App.Services; using Files.App.Utils.Shell; @@ -787,7 +786,7 @@ private async void NavigationViewFileTagItem_DragOver(object sender, DragEventAr var deferral = e.GetDeferral(); e.Handled = true; - var storageItems = await Utils.FilesystemHelpers.GetDraggedStorageItems(e.DataView); + var storageItems = await FilesystemHelpers.GetDraggedStorageItems(e.DataView); if (!storageItems.Any()) { @@ -820,7 +819,7 @@ private async void NavigationViewFileTag_Drop(object sender, DragEventArgs e) var deferral = e.GetDeferral(); - var storageItems = await Utils.FilesystemHelpers.GetDraggedStorageItems(e.DataView); + var storageItems = await FilesystemHelpers.GetDraggedStorageItems(e.DataView); foreach (var item in storageItems.Where(x => !string.IsNullOrEmpty(x.Path))) { var listedItem = new ListedItem(null) diff --git a/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs b/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs index 433aee43b2a8..be96a0cab42d 100644 --- a/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs @@ -5,8 +5,6 @@ using CommunityToolkit.WinUI; using Files.App.Extensions; using Files.App.Utils; -using Files.App.Utils.StorageEnumerators; -using Files.App.Utils.StorageItems; using Files.App.Helpers; using Files.App.Helpers.ContextFlyouts; using Files.App.ViewModels; diff --git a/src/Files.App/Utils/Archives/ArchiveHelpers.cs b/src/Files.App/Utils/Archives/ArchiveHelpers.cs index c61d282ffb68..1a3fb3e8e457 100644 --- a/src/Files.App/Utils/Archives/ArchiveHelpers.cs +++ b/src/Files.App/Utils/Archives/ArchiveHelpers.cs @@ -3,7 +3,6 @@ using Files.App.Dialogs; using Files.App.Utils.Archives; -using Files.App.Utils.StorageItems; using Files.App.ViewModels.Dialogs; using Microsoft.UI.Xaml.Controls; using System.IO; diff --git a/src/Files.App/Utils/Archives/ZipHelpers.cs b/src/Files.App/Utils/Archives/ZipHelpers.cs index faae19c3ec15..82810ec1f472 100644 --- a/src/Files.App/Utils/Archives/ZipHelpers.cs +++ b/src/Files.App/Utils/Archives/ZipHelpers.cs @@ -1,7 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; using Microsoft.Extensions.Logging; using SevenZip; using System.IO; diff --git a/src/Files.App/Utils/Cloud/CloudDrivesDetector.cs b/src/Files.App/Utils/Cloud/CloudDrivesDetector.cs index 6a1ef9f20a7f..414cf12843a5 100644 --- a/src/Files.App/Utils/Cloud/CloudDrivesDetector.cs +++ b/src/Files.App/Utils/Cloud/CloudDrivesDetector.cs @@ -10,7 +10,7 @@ using System.Runtime.Versioning; using System.Threading.Tasks; -namespace Files.App.Helpers +namespace Files.App.Utils.Cloud { [SupportedOSPlatform("Windows10.0.10240")] public class CloudDrivesDetector diff --git a/src/Files.App/Utils/NetworkDrivesAPI.cs b/src/Files.App/Utils/Global/NetworkDrivesAPI.cs similarity index 100% rename from src/Files.App/Utils/NetworkDrivesAPI.cs rename to src/Files.App/Utils/Global/NetworkDrivesAPI.cs diff --git a/src/Files.App/Utils/QuickAccessManager.cs b/src/Files.App/Utils/Global/QuickAccessManager.cs similarity index 100% rename from src/Files.App/Utils/QuickAccessManager.cs rename to src/Files.App/Utils/Global/QuickAccessManager.cs diff --git a/src/Files.App/Utils/WSLDistroManager.cs b/src/Files.App/Utils/Global/WSLDistroManager.cs similarity index 100% rename from src/Files.App/Utils/WSLDistroManager.cs rename to src/Files.App/Utils/Global/WSLDistroManager.cs diff --git a/src/Files.App/Utils/WallpaperHelpers.cs b/src/Files.App/Utils/Global/WallpaperHelpers.cs similarity index 98% rename from src/Files.App/Utils/WallpaperHelpers.cs rename to src/Files.App/Utils/Global/WallpaperHelpers.cs index 2dde14759868..2b6de156b268 100644 --- a/src/Files.App/Utils/WallpaperHelpers.cs +++ b/src/Files.App/Utils/Global/WallpaperHelpers.cs @@ -8,7 +8,7 @@ using Windows.Storage; using Windows.System.UserProfile; -namespace Files.App.Helpers +namespace Files.App.Utils { public static class WallpaperHelpers { diff --git a/src/Files.App/Utils/WindowsStorageDeviceWatcher.cs b/src/Files.App/Utils/Global/WindowsStorageDeviceWatcher.cs similarity index 100% rename from src/Files.App/Utils/WindowsStorageDeviceWatcher.cs rename to src/Files.App/Utils/Global/WindowsStorageDeviceWatcher.cs diff --git a/src/Files.App/Utils/RecentItem/RecentItem.cs b/src/Files.App/Utils/RecentItem/RecentItem.cs index 8500ee8a8cea..6d1445ae85c3 100644 --- a/src/Files.App/Utils/RecentItem/RecentItem.cs +++ b/src/Files.App/Utils/RecentItem/RecentItem.cs @@ -1,7 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; using Files.App.UserControls.Widgets; using Microsoft.UI.Xaml.Media.Imaging; using Windows.Storage; diff --git a/src/Files.App/Helpers/StorageCache/IFileListCache.cs b/src/Files.App/Utils/Storage/Cache/IStorageCacheController.cs similarity index 68% rename from src/Files.App/Helpers/StorageCache/IFileListCache.cs rename to src/Files.App/Utils/Storage/Cache/IStorageCacheController.cs index af02cc3c84a7..b258a54a0c5f 100644 --- a/src/Files.App/Helpers/StorageCache/IFileListCache.cs +++ b/src/Files.App/Utils/Storage/Cache/IStorageCacheController.cs @@ -1,15 +1,12 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using System.Threading; -using System.Threading.Tasks; - -namespace Files.App.Helpers.StorageCache +namespace Files.App.Utils.Storage { - internal interface IFileListCache + internal interface IStorageCacheController { public ValueTask ReadFileDisplayNameFromCache(string path, CancellationToken cancellationToken); public ValueTask SaveFileDisplayNameToCache(string path, string displayName); } -} \ No newline at end of file +} diff --git a/src/Files.App/Helpers/StorageCache/FileListCacheController.cs b/src/Files.App/Utils/Storage/Cache/StorageCacheController.cs similarity index 67% rename from src/Files.App/Helpers/StorageCache/FileListCacheController.cs rename to src/Files.App/Utils/Storage/Cache/StorageCacheController.cs index 3a2ff4c1852d..045d32add4cb 100644 --- a/src/Files.App/Helpers/StorageCache/FileListCacheController.cs +++ b/src/Files.App/Utils/Storage/Cache/StorageCacheController.cs @@ -2,26 +2,24 @@ // Licensed under the MIT License. See the LICENSE. using System.Collections.Concurrent; -using System.Threading; -using System.Threading.Tasks; -namespace Files.App.Helpers.StorageCache +namespace Files.App.Utils.Storage { - internal class FileListCacheController : IFileListCache + internal class StorageCacheController : IStorageCacheController { - private static FileListCacheController instance; + private static StorageCacheController instance; - public static FileListCacheController GetInstance() + private readonly ConcurrentDictionary fileNamesCache = new(); + + private StorageCacheController() { - return instance ??= new FileListCacheController(); } - private FileListCacheController() + public static StorageCacheController GetInstance() { + return instance ??= new StorageCacheController(); } - private readonly ConcurrentDictionary fileNamesCache = new(); - public ValueTask ReadFileDisplayNameFromCache(string path, CancellationToken cancellationToken) { return fileNamesCache.TryGetValue(path, out var displayName) ? ValueTask.FromResult(displayName) : ValueTask.FromResult(string.Empty); @@ -38,4 +36,4 @@ public ValueTask SaveFileDisplayNameToCache(string path, string displayName) return ValueTask.CompletedTask; } } -} \ No newline at end of file +} diff --git a/src/Files.App/Helpers/StorageItemCollection/BlockingListEnumerator.cs b/src/Files.App/Utils/Storage/Collection/BlockingListEnumerator.cs similarity index 84% rename from src/Files.App/Helpers/StorageItemCollection/BlockingListEnumerator.cs rename to src/Files.App/Utils/Storage/Collection/BlockingListEnumerator.cs index ee24dda92b2c..df02d4095a6c 100644 --- a/src/Files.App/Helpers/StorageItemCollection/BlockingListEnumerator.cs +++ b/src/Files.App/Utils/Storage/Collection/BlockingListEnumerator.cs @@ -1,37 +1,36 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using System.Collections; -using System.Collections.Generic; - -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { public class BlockingListEnumerator : IEnumerator { private readonly IList m_Inner; + private readonly object m_Lock; + private T m_Current; - private int m_Pos; - public BlockingListEnumerator(IList inner, object @lock) - { - m_Inner = inner; - m_Lock = @lock; - m_Pos = -1; - } + private int m_Pos; public T Current { get { lock (m_Lock) - { return m_Current; - } } } - object IEnumerator.Current => Current; + object IEnumerator.Current + => Current; + + public BlockingListEnumerator(IList inner, object @lock) + { + m_Inner = inner; + m_Lock = @lock; + m_Pos = -1; + } public void Dispose() { diff --git a/src/Files.App/Helpers/StorageItemCollection/BulkConcurrentObservableCollection.cs b/src/Files.App/Utils/Storage/Collection/BulkConcurrentObservableCollection.cs similarity index 97% rename from src/Files.App/Helpers/StorageItemCollection/BulkConcurrentObservableCollection.cs rename to src/Files.App/Utils/Storage/Collection/BulkConcurrentObservableCollection.cs index 1f8066625c3f..bb179c30246a 100644 --- a/src/Files.App/Helpers/StorageItemCollection/BulkConcurrentObservableCollection.cs +++ b/src/Files.App/Utils/Storage/Collection/BulkConcurrentObservableCollection.cs @@ -1,17 +1,9 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.Shared.Extensions; -using System; -using System.Collections; -using System.Collections.Generic; using System.Collections.Specialized; -using System.ComponentModel; -using System.Diagnostics; -using System.Linq; -using System.Threading; -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { [DebuggerTypeProxy(typeof(CollectionDebugView<>))] [DebuggerDisplay("Count = {Count}")] diff --git a/src/Files.App/Helpers/StorageItemCollection/ConcurrentCollection.cs b/src/Files.App/Utils/Storage/Collection/ConcurrentCollection.cs similarity index 99% rename from src/Files.App/Helpers/StorageItemCollection/ConcurrentCollection.cs rename to src/Files.App/Utils/Storage/Collection/ConcurrentCollection.cs index 906032557cb7..3a8aa0bccdab 100644 --- a/src/Files.App/Helpers/StorageItemCollection/ConcurrentCollection.cs +++ b/src/Files.App/Utils/Storage/Collection/ConcurrentCollection.cs @@ -8,6 +8,7 @@ namespace Files.App.Helpers public class ConcurrentCollection : ICollection, IList, ICollection, IList { private readonly object syncRoot = new object(); + private readonly List collection = new List(); public int Count @@ -231,6 +232,7 @@ public void Sort(Comparison comparison) public void Order(Func, IEnumerable> func) { IEnumerable result; + lock (syncRoot) { result = func.Invoke(collection); @@ -242,12 +244,14 @@ public void Order(Func, IEnumerable> func) public void OrderOne(Func, IEnumerable> func, T item) { IList result; + lock (syncRoot) { result = func.Invoke(collection).ToList(); } Remove(item); + var index = result.IndexOf(item); if (index != -1) Insert(index, item); diff --git a/src/Files.App/Utils/Storage/Collection/GroupedCollection.cs b/src/Files.App/Utils/Storage/Collection/GroupedCollection.cs new file mode 100644 index 000000000000..5d0fbc17b01a --- /dev/null +++ b/src/Files.App/Utils/Storage/Collection/GroupedCollection.cs @@ -0,0 +1,80 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.Utils.Storage +{ + public class GroupedCollection : BulkConcurrentObservableCollection, IGroupedCollectionHeader + { + public GroupedHeaderViewModel Model { get; set; } + + public GroupedCollection(IEnumerable items) : base(items) + { + AddEvents(); + } + + public GroupedCollection(string key) : base() + { + AddEvents(); + Model = new GroupedHeaderViewModel() + { + Key = key, + Text = key, + }; + } + + public GroupedCollection(string key, string text) : base() + { + AddEvents(); + Model = new GroupedHeaderViewModel() + { + Key = key, + Text = text, + }; + } + + private void AddEvents() + { + PropertyChanged += GroupedCollection_PropertyChanged; + } + + private void GroupedCollection_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == nameof(Count)) + { + Model.CountText = string.Format( + Count > 1 + ? "GroupItemsCount_Plural".GetLocalizedResource() + : "GroupItemsCount_Singular".GetLocalizedResource(), + Count); + } + } + + public void InitializeExtendedGroupHeaderInfoAsync() + { + if (GetExtendedGroupHeaderInfo is null) + return; + + Model.ResumePropertyChangedNotifications(false); + + GetExtendedGroupHeaderInfo.Invoke(this); + Model.Initialized = true; + + if (isBulkOperationStarted) + Model.PausePropertyChangedNotifications(); + } + + public override void BeginBulkOperation() + { + base.BeginBulkOperation(); + + Model.PausePropertyChangedNotifications(); + } + + public override void EndBulkOperation() + { + base.EndBulkOperation(); + + Model.ResumePropertyChangedNotifications(); + } + } +} diff --git a/src/Files.App/Helpers/StorageItemCollection/GroupedCollection.cs b/src/Files.App/Utils/Storage/Collection/GroupedHeaderViewModel.cs similarity index 51% rename from src/Files.App/Helpers/StorageItemCollection/GroupedCollection.cs rename to src/Files.App/Utils/Storage/Collection/GroupedHeaderViewModel.cs index 234386a0c539..0145d5484368 100644 --- a/src/Files.App/Helpers/StorageItemCollection/GroupedCollection.cs +++ b/src/Files.App/Utils/Storage/Collection/GroupedHeaderViewModel.cs @@ -1,99 +1,11 @@ -// Copyright (c) 2023 Files Community +// Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using CommunityToolkit.Mvvm.ComponentModel; -using Files.App.Extensions; using Microsoft.UI.Xaml.Media; -using System; -using System.Collections.Generic; -using System.ComponentModel; using System.Runtime.CompilerServices; -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { - public class GroupedCollection : BulkConcurrentObservableCollection, IGroupedCollectionHeader - { - public GroupedHeaderViewModel Model { get; set; } - - public GroupedCollection(IEnumerable items) : base(items) - { - AddEvents(); - } - - public GroupedCollection(string key) : base() - { - AddEvents(); - Model = new GroupedHeaderViewModel() - { - Key = key, - Text = key, - }; - } - - public GroupedCollection(string key, string text) : base() - { - AddEvents(); - Model = new GroupedHeaderViewModel() - { - Key = key, - Text = text, - }; - } - - private void AddEvents() - { - PropertyChanged += GroupedCollection_PropertyChanged; - } - - private void GroupedCollection_PropertyChanged(object sender, PropertyChangedEventArgs e) - { - if (e.PropertyName == nameof(Count)) - { - Model.CountText = string.Format(Count > 1 ? "GroupItemsCount_Plural".GetLocalizedResource() : "GroupItemsCount_Singular".GetLocalizedResource(), Count); - } - } - - public void InitializeExtendedGroupHeaderInfoAsync() - { - if (GetExtendedGroupHeaderInfo is null) - { - return; - } - - Model.ResumePropertyChangedNotifications(false); - - GetExtendedGroupHeaderInfo.Invoke(this); - Model.Initialized = true; - if (isBulkOperationStarted) - { - Model.PausePropertyChangedNotifications(); - } - } - - public override void BeginBulkOperation() - { - base.BeginBulkOperation(); - Model.PausePropertyChangedNotifications(); - } - - public override void EndBulkOperation() - { - base.EndBulkOperation(); - Model.ResumePropertyChangedNotifications(); - } - } - - /// - /// This interface is used to allow using x:Bind for the group header template. - ///
- /// This is needed because x:Bind does not work with generic types, however it does work with interfaces. - /// that are implemented by generic types. - ///
- public interface IGroupedCollectionHeader - { - public GroupedHeaderViewModel Model { get; set; } - } - public class GroupedHeaderViewModel : ObservableObject { public string Key { get; set; } @@ -196,4 +108,4 @@ public void ResumePropertyChangedNotifications(bool triggerUpdates = true) // This is true by default to make it easier to initialize groups from a different thread private bool deferPropChangedNotifs = true; } -} \ No newline at end of file +} diff --git a/src/Files.App/Helpers/StorageItemCollection/GroupingHelper.cs b/src/Files.App/Utils/Storage/Collection/GroupingHelper.cs similarity index 98% rename from src/Files.App/Helpers/StorageItemCollection/GroupingHelper.cs rename to src/Files.App/Utils/Storage/Collection/GroupingHelper.cs index d097819988f4..cfdf90d6d203 100644 --- a/src/Files.App/Helpers/StorageItemCollection/GroupingHelper.cs +++ b/src/Files.App/Utils/Storage/Collection/GroupingHelper.cs @@ -3,7 +3,7 @@ using Windows.Storage; -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { public static class GroupingHelper { @@ -166,9 +166,4 @@ public static string GetGroupSizeKey(long size) (16000, "ItemSizeText_Small".GetLocalizedResource(), "16 KiB".ConvertSizeAbbreviation()), }; } - - public interface IGroupableItem - { - public string Key { get; set; } - } } diff --git a/src/Files.App/Utils/Storage/Collection/IGroupableItem.cs b/src/Files.App/Utils/Storage/Collection/IGroupableItem.cs new file mode 100644 index 000000000000..bd3cba2618d6 --- /dev/null +++ b/src/Files.App/Utils/Storage/Collection/IGroupableItem.cs @@ -0,0 +1,10 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.Utils.Storage +{ + public interface IGroupableItem + { + public string Key { get; set; } + } +} diff --git a/src/Files.App/Utils/Storage/Collection/IGroupedCollectionHeader.cs b/src/Files.App/Utils/Storage/Collection/IGroupedCollectionHeader.cs new file mode 100644 index 000000000000..fe35173d0642 --- /dev/null +++ b/src/Files.App/Utils/Storage/Collection/IGroupedCollectionHeader.cs @@ -0,0 +1,16 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.Utils.Storage +{ + /// + /// Represents an interface that is used to allow using x:Bind for the group header template. + ///
+ /// This is needed because x:Bind does not work with generic types, however it does work with interfaces. + /// that are implemented by generic types. + ///
+ public interface IGroupedCollectionHeader + { + public GroupedHeaderViewModel Model { get; set; } + } +} diff --git a/src/Files.App/Helpers/StorageItemCollection/SortingHelper.cs b/src/Files.App/Utils/Storage/Collection/SortingHelper.cs similarity index 97% rename from src/Files.App/Helpers/StorageItemCollection/SortingHelper.cs rename to src/Files.App/Utils/Storage/Collection/SortingHelper.cs index 898cc4d8827b..6a1cf7eaaaee 100644 --- a/src/Files.App/Helpers/StorageItemCollection/SortingHelper.cs +++ b/src/Files.App/Utils/Storage/Collection/SortingHelper.cs @@ -1,12 +1,9 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using System; -using System.Collections.Generic; -using System.Linq; using Windows.Storage; -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { public static class SortingHelper { @@ -95,4 +92,4 @@ static bool FolderThenFileAsync(ListedItem listedItem) return ordered; } } -} \ No newline at end of file +} diff --git a/src/Files.App/Utils/StorageEnumerators/UniversalStorageEnumerator.cs b/src/Files.App/Utils/Storage/Enumerators/UniversalStorageEnumerator.cs similarity index 90% rename from src/Files.App/Utils/StorageEnumerators/UniversalStorageEnumerator.cs rename to src/Files.App/Utils/Storage/Enumerators/UniversalStorageEnumerator.cs index 69be192dcfa9..38eb5ed0a56c 100644 --- a/src/Files.App/Utils/StorageEnumerators/UniversalStorageEnumerator.cs +++ b/src/Files.App/Utils/Storage/Enumerators/UniversalStorageEnumerator.cs @@ -1,23 +1,12 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using CommunityToolkit.Mvvm.DependencyInjection; -using Files.App.Extensions; -using Files.App.Utils.StorageItems; -using Files.App.Helpers; -using Files.Core.Helpers; -using Files.Core.Services.Settings; using Microsoft.Extensions.Logging; using Microsoft.UI.Xaml.Media.Imaging; -using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using Windows.Storage; -namespace Files.App.Utils.StorageEnumerators +namespace Files.App.Utils.Storage { public static class UniversalStorageEnumerator { @@ -27,8 +16,7 @@ public static async Task> ListEntries( CancellationToken cancellationToken, int countLimit, Func, Task> intermediateAction, - Dictionary defaultIconPairs = null - ) + Dictionary defaultIconPairs = null) { var sampler = new IntervalSampler(500); var tempList = new List(); @@ -40,6 +28,7 @@ public static async Task> ListEntries( while (true) { IReadOnlyList items; + uint maxItemsToRetrieve = 300; if (intermediateAction is null) @@ -52,6 +41,7 @@ public static async Task> ListEntries( maxItemsToRetrieve = 32; firstRound = false; } + try { items = await rootFolder.GetItemsAsync(count, maxItemsToRetrieve); @@ -65,9 +55,9 @@ public static async Task> ListEntries( break; } catch (Exception ex) when ( - ex is UnauthorizedAccessException - || ex is FileNotFoundException - || (uint)ex.HResult == 0x80070490) // ERROR_NOT_FOUND + ex is UnauthorizedAccessException || + ex is FileNotFoundException || + (uint)ex.HResult == 0x80070490) // ERROR_NOT_FOUND { // If some unexpected exception is thrown - enumerate this folder file by file - just to be sure items = await EnumerateFileByFile(rootFolder, count, maxItemsToRetrieve); @@ -75,8 +65,10 @@ ex is UnauthorizedAccessException catch (Exception ex) { App.Logger.LogWarning(ex, "Error enumerating directory contents."); + break; } + foreach (var item in items) { var startWithDot = item.Name.StartsWith('.'); @@ -88,9 +80,8 @@ ex is UnauthorizedAccessException if (folder is not null) { if (defaultIconPairs?.ContainsKey(string.Empty) ?? false) - { folder.FileImage = defaultIconPairs[string.Empty]; - } + tempList.Add(folder); } } @@ -104,61 +95,61 @@ ex is UnauthorizedAccessException if (!string.IsNullOrEmpty(fileEntry.FileExtension)) { var lowercaseExtension = fileEntry.FileExtension.ToLowerInvariant(); + if (defaultIconPairs.ContainsKey(lowercaseExtension)) - { fileEntry.FileImage = defaultIconPairs[lowercaseExtension]; - } } } + tempList.Add(fileEntry); } } } + if (cancellationToken.IsCancellationRequested) - { break; - } } + count += maxItemsToRetrieve; if (countLimit > -1 && count >= countLimit) - { break; - } if (intermediateAction is not null && (items.Count == maxItemsToRetrieve || sampler.CheckNow())) { await intermediateAction(tempList); + // clear the temporary list every time we do an intermediate action tempList.Clear(); } } + return tempList; } private static async Task> EnumerateFileByFile(BaseStorageFolder rootFolder, uint startFrom, uint itemsToIterate) { var tempList = new List(); + for (var i = startFrom; i < startFrom + itemsToIterate; i++) { IStorageItem item; try { var results = await rootFolder.GetItemsAsync(i, 1); + item = results?.FirstOrDefault(); if (item is null) - { break; - } } catch (NotImplementedException) { break; } catch (Exception ex) when ( - ex is UnauthorizedAccessException - || ex is FileNotFoundException - || (uint)ex.HResult == 0x80070490) // ERROR_NOT_FOUND + ex is UnauthorizedAccessException || + ex is FileNotFoundException || + (uint)ex.HResult == 0x80070490) // ERROR_NOT_FOUND { continue; } @@ -167,12 +158,17 @@ ex is UnauthorizedAccessException App.Logger.LogWarning(ex, "Error enumerating directory contents."); break; } + tempList.Add(item); } + return tempList; } - public static async Task AddFolderAsync(BaseStorageFolder folder, StorageFolderWithPath currentStorageFolder, CancellationToken cancellationToken) + public static async Task AddFolderAsync( + BaseStorageFolder folder, + StorageFolderWithPath currentStorageFolder, + CancellationToken cancellationToken) { var basicProperties = await folder.GetBasicPropertiesAsync(); if (!cancellationToken.IsCancellationRequested) @@ -238,14 +234,14 @@ public static async Task AddFolderAsync(BaseStorageFolder folder, St }; } } + return null; } public static async Task AddFileAsync( BaseStorageFile file, StorageFolderWithPath currentStorageFolder, - CancellationToken cancellationToken - ) + CancellationToken cancellationToken) { var basicProperties = await file.GetBasicPropertiesAsync(); // Display name does not include extension @@ -260,9 +256,7 @@ CancellationToken cancellationToken var itemThumbnailImgVis = false; if (cancellationToken.IsCancellationRequested) - { return null; - } // TODO: is this needed to be handled here? if (App.LibraryManager.TryGetLibrary(file.Path, out LibraryLocationItem library)) @@ -343,6 +337,7 @@ CancellationToken cancellationToken }; } } + return null; } } diff --git a/src/Files.App/Utils/StorageEnumerators/Win32StorageEnumerator.cs b/src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs similarity index 89% rename from src/Files.App/Utils/StorageEnumerators/Win32StorageEnumerator.cs rename to src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs index daf88361d2b8..d0f287329e69 100644 --- a/src/Files.App/Utils/StorageEnumerators/Win32StorageEnumerator.cs +++ b/src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs @@ -1,10 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; -using Files.App.Helpers.StorageCache; -using Files.Core.Extensions; -using Files.Core.Helpers; using Files.Core.Services.SizeProvider; using Microsoft.UI.Xaml.Media.Imaging; using System.IO; @@ -13,19 +9,20 @@ using static Files.Core.Helpers.NativeFindStorageItemHelper; using FileAttributes = System.IO.FileAttributes; -namespace Files.App.Utils.StorageEnumerators +namespace Files.App.Utils.Storage { public static class Win32StorageEnumerator { private static readonly ISizeProvider folderSizeProvider = Ioc.Default.GetService(); private static readonly string folderTypeTextLocalized = "Folder".GetLocalizedResource(); - private static readonly IFileListCache fileListCache = FileListCacheController.GetInstance(); + + private static readonly IStorageCacheController fileListCache = StorageCacheController.GetInstance(); public static async Task> ListEntries( string path, IntPtr hFile, - Core.Helpers.NativeFindStorageItemHelper.WIN32_FIND_DATA findData, + NativeFindStorageItemHelper.WIN32_FIND_DATA findData, CancellationToken cancellationToken, int countLimit, Func, Task> intermediateAction, @@ -47,9 +44,9 @@ public static async Task> ListEntries( var isHidden = ((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden; var startWithDot = findData.cFileName.StartsWith('.'); if ((!isHidden || - (userSettingsService.FoldersSettingsService.ShowHiddenItems && - (!isSystem || userSettingsService.FoldersSettingsService.ShowProtectedSystemFiles))) && - (!startWithDot || userSettingsService.FoldersSettingsService.ShowDotFiles)) + (userSettingsService.FoldersSettingsService.ShowHiddenItems && + (!isSystem || userSettingsService.FoldersSettingsService.ShowProtectedSystemFiles))) && + (!startWithDot || userSettingsService.FoldersSettingsService.ShowDotFiles)) { if (((FileAttributes)findData.dwFileAttributes & FileAttributes.Directory) != FileAttributes.Directory) { @@ -67,6 +64,7 @@ public static async Task> ListEntries( } } } + tempList.Add(file); ++count; @@ -88,13 +86,12 @@ public static async Task> ListEntries( // Set folder icon (found by empty extension string) folder.FileImage = defaultIconPairs[string.Empty]; } + tempList.Add(folder); ++count; if (userSettingsService.FoldersSettingsService.AreAlternateStreamsVisible) - { tempList.AddRange(EnumAdsForPath(folder.ItemPath, folder)); - } if (CalculateFolderSizes) { @@ -103,46 +100,48 @@ public static async Task> ListEntries( folder.FileSizeBytes = (long)size; folder.FileSize = size.ToSizeString(); } + _ = folderSizeProvider.UpdateAsync(folder.ItemPath, cancellationToken); } } } } } + if (cancellationToken.IsCancellationRequested || count == countLimit) - { break; - } if (intermediateAction is not null && (count == 32 || sampler.CheckNow())) { await intermediateAction(tempList); + // clear the temporary list every time we do an intermediate action tempList.Clear(); } } while (FindNextFile(hFile, out findData)); FindClose(hFile); + return tempList; } private static IEnumerable EnumAdsForPath(string itemPath, ListedItem main) { foreach (var ads in NativeFileOperationsHelper.GetAlternateStreams(itemPath)) - { yield return GetAlternateStream(ads, main); - } } public static ListedItem GetAlternateStream((string Name, long Size) ads, ListedItem main) { string itemType = "File".GetLocalizedResource(); string itemFileExtension = null; + if (ads.Name.Contains('.')) { itemFileExtension = Path.GetExtension(ads.Name); itemType = itemFileExtension.Trim('.') + " " + itemType; } + string adsName = ads.Name.Substring(1, ads.Name.Length - 7); // Remove ":" and ":$DATA" return new AlternateStreamItem() @@ -165,7 +164,7 @@ public static ListedItem GetAlternateStream((string Name, long Size) ads, Listed } public static async Task GetFolder( - Core.Helpers.NativeFindStorageItemHelper.WIN32_FIND_DATA findData, + NativeFindStorageItemHelper.WIN32_FIND_DATA findData, string pathRoot, bool isGitRepo, CancellationToken cancellationToken @@ -176,12 +175,13 @@ CancellationToken cancellationToken DateTime itemModifiedDate; DateTime itemCreatedDate; + try { - FileTimeToSystemTime(ref findData.ftLastWriteTime, out Core.Helpers.NativeFindStorageItemHelper.SYSTEMTIME systemModifiedTimeOutput); + FileTimeToSystemTime(ref findData.ftLastWriteTime, out NativeFindStorageItemHelper.SYSTEMTIME systemModifiedTimeOutput); itemModifiedDate = systemModifiedTimeOutput.ToDateTime(); - FileTimeToSystemTime(ref findData.ftCreationTime, out Core.Helpers.NativeFindStorageItemHelper.SYSTEMTIME systemCreatedTimeOutput); + FileTimeToSystemTime(ref findData.ftCreationTime, out NativeFindStorageItemHelper.SYSTEMTIME systemCreatedTimeOutput); itemCreatedDate = systemCreatedTimeOutput.ToDateTime(); } catch (ArgumentException) @@ -189,19 +189,18 @@ CancellationToken cancellationToken // Invalid date means invalid findData, do not add to list return null; } + var itemPath = Path.Combine(pathRoot, findData.cFileName); + string itemName = await fileListCache.ReadFileDisplayNameFromCache(itemPath, cancellationToken); if (string.IsNullOrEmpty(itemName)) - { itemName = findData.cFileName; - } + bool isHidden = (((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden); double opacity = 1; if (isHidden) - { opacity = Constants.UI.DimItemOpacity; - } if (isGitRepo) { @@ -242,7 +241,7 @@ CancellationToken cancellationToken } public static async Task GetFile( - Core.Helpers.NativeFindStorageItemHelper.WIN32_FIND_DATA findData, + NativeFindStorageItemHelper.WIN32_FIND_DATA findData, string pathRoot, bool isGitRepo, CancellationToken cancellationToken @@ -252,15 +251,16 @@ CancellationToken cancellationToken var itemName = findData.cFileName; DateTime itemModifiedDate, itemCreatedDate, itemLastAccessDate; + try { - FileTimeToSystemTime(ref findData.ftLastWriteTime, out Core.Helpers.NativeFindStorageItemHelper.SYSTEMTIME systemModifiedDateOutput); + FileTimeToSystemTime(ref findData.ftLastWriteTime, out NativeFindStorageItemHelper.SYSTEMTIME systemModifiedDateOutput); itemModifiedDate = systemModifiedDateOutput.ToDateTime(); - FileTimeToSystemTime(ref findData.ftCreationTime, out Core.Helpers.NativeFindStorageItemHelper.SYSTEMTIME systemCreatedDateOutput); + FileTimeToSystemTime(ref findData.ftCreationTime, out NativeFindStorageItemHelper.SYSTEMTIME systemCreatedDateOutput); itemCreatedDate = systemCreatedDateOutput.ToDateTime(); - FileTimeToSystemTime(ref findData.ftLastAccessTime, out Core.Helpers.NativeFindStorageItemHelper.SYSTEMTIME systemLastAccessOutput); + FileTimeToSystemTime(ref findData.ftLastAccessTime, out NativeFindStorageItemHelper.SYSTEMTIME systemLastAccessOutput); itemLastAccessDate = systemLastAccessOutput.ToDateTime(); } catch (ArgumentException) @@ -284,9 +284,7 @@ CancellationToken cancellationToken bool itemEmptyImgVis = true; if (cancellationToken.IsCancellationRequested) - { return null; - } bool isHidden = ((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden; double opacity = isHidden ? Constants.UI.DimItemOpacity : 1; @@ -298,6 +296,7 @@ CancellationToken cancellationToken if (isSymlink) { var targetPath = NativeFileOperationsHelper.ParseSymLink(itemPath); + return new ShortcutItem(null) { PrimaryItemAttribute = StorageItemTypes.File, @@ -322,11 +321,11 @@ CancellationToken cancellationToken else if (FileExtensionHelpers.IsShortcutOrUrlFile(findData.cFileName)) { var isUrl = FileExtensionHelpers.IsWebLinkFile(findData.cFileName); + var shInfo = await FileOperationsHelpers.ParseLinkAsync(itemPath); if (shInfo is null) - { return null; - } + return new ShortcutItem(null) { PrimaryItemAttribute = shInfo.IsFolder ? StorageItemTypes.Folder : StorageItemTypes.File, @@ -423,6 +422,7 @@ CancellationToken cancellationToken }; } } + return null; } } diff --git a/src/Files.App/Helpers/Storage/DeviceManager.cs b/src/Files.App/Utils/Storage/Helpers/DeviceManager.cs similarity index 98% rename from src/Files.App/Helpers/Storage/DeviceManager.cs rename to src/Files.App/Utils/Storage/Helpers/DeviceManager.cs index 36137d032263..989e5071e1d4 100644 --- a/src/Files.App/Helpers/Storage/DeviceManager.cs +++ b/src/Files.App/Utils/Storage/Helpers/DeviceManager.cs @@ -1,11 +1,9 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.Shared; using Microsoft.Management.Infrastructure; -using System; -namespace Files.App +namespace Files.App.Utils.Storage { public sealed class DeviceManager { diff --git a/src/Files.App/Helpers/Storage/DriveHelpers.cs b/src/Files.App/Utils/Storage/Helpers/DriveHelpers.cs similarity index 95% rename from src/Files.App/Helpers/Storage/DriveHelpers.cs rename to src/Files.App/Utils/Storage/Helpers/DriveHelpers.cs index 18ab19b40441..33bfc5df0806 100644 --- a/src/Files.App/Helpers/Storage/DriveHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/DriveHelpers.cs @@ -1,23 +1,15 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using CommunityToolkit.Mvvm.DependencyInjection; -using Files.App.Data.Items; -using Files.App.Extensions; -using Files.App.Utils; -using Files.App.ViewModels; using Microsoft.Management.Infrastructure; -using System; using System.IO; -using System.Linq; -using System.Threading.Tasks; using Windows.Devices.Enumeration; using Windows.Devices.Portable; using Windows.Storage; using Windows.Storage.FileProperties; using DiscUtils.Udf; -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { public static class DriveHelpers { diff --git a/src/Files.App/Helpers/Storage/ErrorCodeConverter.cs b/src/Files.App/Utils/Storage/Helpers/ErrorCodeConverter.cs similarity index 95% rename from src/Files.App/Helpers/Storage/ErrorCodeConverter.cs rename to src/Files.App/Utils/Storage/Helpers/ErrorCodeConverter.cs index 0b63b9372bc4..fe1fac30be12 100644 --- a/src/Files.App/Helpers/Storage/ErrorCodeConverter.cs +++ b/src/Files.App/Utils/Storage/Helpers/ErrorCodeConverter.cs @@ -1,7 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { public static class ErrorCodeConverter { diff --git a/src/Files.App/Helpers/Storage/FileOperationsHelpers.cs b/src/Files.App/Utils/Storage/Helpers/FileOperationsHelpers.cs similarity index 99% rename from src/Files.App/Helpers/Storage/FileOperationsHelpers.cs rename to src/Files.App/Utils/Storage/Helpers/FileOperationsHelpers.cs index b1e18d4fd15e..5d183315bbf1 100644 --- a/src/Files.App/Helpers/Storage/FileOperationsHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/FileOperationsHelpers.cs @@ -1,9 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.Security; -using Files.App.Utils.Shell; -using Files.Core.Helpers; using Microsoft.Extensions.Logging; using Microsoft.Win32; using System.Collections.Concurrent; @@ -15,7 +12,7 @@ using Vanara.Windows.Shell; using Windows.ApplicationModel.DataTransfer; -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { public class FileOperationsHelpers { diff --git a/src/Files.App/Helpers/Storage/FilePropertiesHelpers.cs b/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs similarity index 99% rename from src/Files.App/Helpers/Storage/FilePropertiesHelpers.cs rename to src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs index 71d5ad72ec93..5dfbf15d4eff 100644 --- a/src/Files.App/Helpers/Storage/FilePropertiesHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs @@ -10,7 +10,7 @@ using System.Collections.Concurrent; using Windows.Graphics; -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { /// /// Represents a helper class that helps users open and handle item properties window diff --git a/src/Files.App/Helpers/Storage/FileSecurityHelpers.cs b/src/Files.App/Utils/Storage/Helpers/FileSecurityHelpers.cs similarity index 98% rename from src/Files.App/Helpers/Storage/FileSecurityHelpers.cs rename to src/Files.App/Utils/Storage/Helpers/FileSecurityHelpers.cs index bd22042aeb3c..ea76ec4e2823 100644 --- a/src/Files.App/Helpers/Storage/FileSecurityHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/FileSecurityHelpers.cs @@ -1,13 +1,11 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.Security; -using Files.App.Utils.Shell; using Vanara.PInvoke; using static Vanara.PInvoke.AdvApi32; using SystemSecurity = System.Security.AccessControl; -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { /// /// Represents a helper for file security information. diff --git a/src/Files.App/Helpers/Storage/FileThumbnailHelper.cs b/src/Files.App/Utils/Storage/Helpers/FileThumbnailHelper.cs similarity index 93% rename from src/Files.App/Helpers/Storage/FileThumbnailHelper.cs rename to src/Files.App/Utils/Storage/Helpers/FileThumbnailHelper.cs index 2999e5b74291..aa674e2a1241 100644 --- a/src/Files.App/Helpers/Storage/FileThumbnailHelper.cs +++ b/src/Files.App/Utils/Storage/Helpers/FileThumbnailHelper.cs @@ -1,16 +1,10 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Extensions; -using Files.App.Utils; -using Files.App.Utils.Shell; -using Files.Core.Helpers; -using System; -using System.Threading.Tasks; using Windows.Storage; using Windows.Storage.FileProperties; -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { public static class FileThumbnailHelper { diff --git a/src/Files.App/Utils/StorageFileHelpers/FilesystemResult.cs b/src/Files.App/Utils/Storage/Helpers/FilesystemResult.cs similarity index 96% rename from src/Files.App/Utils/StorageFileHelpers/FilesystemResult.cs rename to src/Files.App/Utils/Storage/Helpers/FilesystemResult.cs index e12ad5f37b19..70950a775652 100644 --- a/src/Files.App/Utils/StorageFileHelpers/FilesystemResult.cs +++ b/src/Files.App/Utils/Storage/Helpers/FilesystemResult.cs @@ -1,7 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -namespace Files.App.Utils +namespace Files.App.Utils.Storage { public class FilesystemResult { diff --git a/src/Files.App/Utils/StorageFileHelpers/FilesystemTasks.cs b/src/Files.App/Utils/Storage/Helpers/FilesystemTasks.cs similarity index 98% rename from src/Files.App/Utils/StorageFileHelpers/FilesystemTasks.cs rename to src/Files.App/Utils/Storage/Helpers/FilesystemTasks.cs index 08569214b679..af9ee64cd6e4 100644 --- a/src/Files.App/Utils/StorageFileHelpers/FilesystemTasks.cs +++ b/src/Files.App/Utils/Storage/Helpers/FilesystemTasks.cs @@ -6,7 +6,7 @@ using System.Runtime.InteropServices; using Windows.Storage; -namespace Files.App.Utils +namespace Files.App.Utils.Storage { public static class FilesystemTasks { diff --git a/src/Files.App/Helpers/Storage/FolderHelpers.cs b/src/Files.App/Utils/Storage/Helpers/FolderHelpers.cs similarity index 92% rename from src/Files.App/Helpers/Storage/FolderHelpers.cs rename to src/Files.App/Utils/Storage/Helpers/FolderHelpers.cs index 9aa7c153aee0..602620409652 100644 --- a/src/Files.App/Helpers/Storage/FolderHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/FolderHelpers.cs @@ -1,14 +1,10 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; -using System; -using System.Collections.Generic; using System.IO; -using System.Threading.Tasks; using static Files.Core.Helpers.NativeFindStorageItemHelper; -namespace Files.App.Utils +namespace Files.App.Utils.Storage { public static class FolderHelpers { diff --git a/src/Files.App/Utils/FtpHelpers.cs b/src/Files.App/Utils/Storage/Helpers/FtpHelpers.cs similarity index 96% rename from src/Files.App/Utils/FtpHelpers.cs rename to src/Files.App/Utils/Storage/Helpers/FtpHelpers.cs index e6f773c672dc..2f7d5f886f42 100644 --- a/src/Files.App/Utils/FtpHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/FtpHelpers.cs @@ -2,10 +2,8 @@ // Licensed under the MIT License. See the LICENSE. using FluentFTP; -using System; -using System.Threading.Tasks; -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { public static class FtpHelpers { diff --git a/src/Files.App/Utils/StorageFileHelpers/IStorageItemWithPath.cs b/src/Files.App/Utils/Storage/Helpers/IStorageItemWithPath.cs similarity index 90% rename from src/Files.App/Utils/StorageFileHelpers/IStorageItemWithPath.cs rename to src/Files.App/Utils/Storage/Helpers/IStorageItemWithPath.cs index e5a5844353ab..91387674077d 100644 --- a/src/Files.App/Utils/StorageFileHelpers/IStorageItemWithPath.cs +++ b/src/Files.App/Utils/Storage/Helpers/IStorageItemWithPath.cs @@ -3,7 +3,7 @@ using Windows.Storage; -namespace Files.App.Utils +namespace Files.App.Utils.Storage { public interface IStorageItemWithPath { diff --git a/src/Files.App/Utils/StorageFileHelpers/StorageFileExtensions.cs b/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs similarity index 97% rename from src/Files.App/Utils/StorageFileHelpers/StorageFileExtensions.cs rename to src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs index 14322b44007c..442f11060dbf 100644 --- a/src/Files.App/Utils/StorageFileHelpers/StorageFileExtensions.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs @@ -1,25 +1,13 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using CommunityToolkit.Mvvm.DependencyInjection; -using Files.App.Data.Items; -using Files.App.Extensions; -using Files.App.Utils.StorageItems; -using Files.App.Helpers; -using Files.App.ViewModels; -using Files.App.Views; -using Files.Shared.Extensions; -using System; -using System.Collections.Generic; using System.Collections.Immutable; using System.IO; -using System.Linq; using System.Text; -using System.Threading.Tasks; using Windows.Storage; using Windows.Storage.Search; -namespace Files.App.Utils +namespace Files.App.Utils.Storage { public static class StorageFileExtensions { diff --git a/src/Files.App/Utils/StorageFileHelpers/StorageFileWithPath.cs b/src/Files.App/Utils/Storage/Helpers/StorageFileWithPath.cs similarity index 94% rename from src/Files.App/Utils/StorageFileHelpers/StorageFileWithPath.cs rename to src/Files.App/Utils/Storage/Helpers/StorageFileWithPath.cs index d2c890db91f9..78450819cb2c 100644 --- a/src/Files.App/Utils/StorageFileHelpers/StorageFileWithPath.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageFileWithPath.cs @@ -1,7 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; using Windows.Storage; using IO = System.IO; diff --git a/src/Files.App/Utils/StorageFileHelpers/StorageFolderWithPath.cs b/src/Files.App/Utils/Storage/Helpers/StorageFolderWithPath.cs similarity index 95% rename from src/Files.App/Utils/StorageFileHelpers/StorageFolderWithPath.cs rename to src/Files.App/Utils/Storage/Helpers/StorageFolderWithPath.cs index 1581be353787..378092eefa77 100644 --- a/src/Files.App/Utils/StorageFileHelpers/StorageFolderWithPath.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageFolderWithPath.cs @@ -1,7 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; using Windows.Storage; using IO = System.IO; diff --git a/src/Files.App/Helpers/Storage/StorageHelpers.cs b/src/Files.App/Utils/Storage/Helpers/StorageHelpers.cs similarity index 97% rename from src/Files.App/Helpers/Storage/StorageHelpers.cs rename to src/Files.App/Utils/Storage/Helpers/StorageHelpers.cs index bedfe3b2bab6..8f5ebf0fe114 100644 --- a/src/Files.App/Helpers/Storage/StorageHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageHelpers.cs @@ -1,13 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils; -using Files.App.Utils.StorageItems; -using Files.Core.Helpers; -using System; -using System.Diagnostics; using System.Runtime.InteropServices; -using System.Threading.Tasks; using Windows.Storage; using Windows.Storage.FileProperties; diff --git a/src/Files.App/Helpers/Storage/StorageItemIconHelpers.cs b/src/Files.App/Utils/Storage/Helpers/StorageItemIconHelpers.cs similarity index 95% rename from src/Files.App/Helpers/Storage/StorageItemIconHelpers.cs rename to src/Files.App/Utils/Storage/Helpers/StorageItemIconHelpers.cs index 54740fc7f10b..c8af4c4a6e3d 100644 --- a/src/Files.App/Helpers/Storage/StorageItemIconHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageItemIconHelpers.cs @@ -1,12 +1,10 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using System; -using System.Threading.Tasks; using Windows.Storage; using Windows.Storage.FileProperties; -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { public static class StorageItemIconHelpers { diff --git a/src/Files.App/Helpers/Storage/StorageSenseHelper.cs b/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs similarity index 86% rename from src/Files.App/Helpers/Storage/StorageSenseHelper.cs rename to src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs index e8a99fb60f14..1ce1ef16291c 100644 --- a/src/Files.App/Helpers/Storage/StorageSenseHelper.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs @@ -1,13 +1,10 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.Shell; -using System; -using System.Threading.Tasks; using Windows.Foundation.Metadata; using Windows.System; -namespace Files.App.Helpers +namespace Files.App.Utils.Storage { internal class StorageSenseHelper { diff --git a/src/Files.App/Utils/StorageHistory/IStorageHistory.cs b/src/Files.App/Utils/Storage/History/IStorageHistory.cs similarity index 92% rename from src/Files.App/Utils/StorageHistory/IStorageHistory.cs rename to src/Files.App/Utils/Storage/History/IStorageHistory.cs index 960ce92657df..c0dce998bfe0 100644 --- a/src/Files.App/Utils/StorageHistory/IStorageHistory.cs +++ b/src/Files.App/Utils/Storage/History/IStorageHistory.cs @@ -1,9 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using System.Collections.Generic; - -namespace Files.App.Utils.FilesystemHistory +namespace Files.App.Utils.Storage { public interface IStorageHistory { diff --git a/src/Files.App/Utils/StorageHistory/IStorageHistoryOperations.cs b/src/Files.App/Utils/Storage/History/IStorageHistoryOperations.cs similarity index 86% rename from src/Files.App/Utils/StorageHistory/IStorageHistoryOperations.cs rename to src/Files.App/Utils/Storage/History/IStorageHistoryOperations.cs index 6d2ed379d136..4309156df56d 100644 --- a/src/Files.App/Utils/StorageHistory/IStorageHistoryOperations.cs +++ b/src/Files.App/Utils/Storage/History/IStorageHistoryOperations.cs @@ -1,10 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using System; -using System.Threading.Tasks; - -namespace Files.App.Utils.FilesystemHistory +namespace Files.App.Utils.Storage { public interface IStorageHistoryOperations : IDisposable { diff --git a/src/Files.App/Utils/StorageHistory/StorageHistory.cs b/src/Files.App/Utils/Storage/History/StorageHistory.cs similarity index 92% rename from src/Files.App/Utils/StorageHistory/StorageHistory.cs rename to src/Files.App/Utils/Storage/History/StorageHistory.cs index 86086f48be67..9a3e45db8abd 100644 --- a/src/Files.App/Utils/StorageHistory/StorageHistory.cs +++ b/src/Files.App/Utils/Storage/History/StorageHistory.cs @@ -1,10 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.Shared.Extensions; -using System.Collections.Generic; - -namespace Files.App.Utils.FilesystemHistory +namespace Files.App.Utils.Storage { public class StorageHistory : IStorageHistory { diff --git a/src/Files.App/Utils/StorageHistory/Helpers/StorageHistoryHelpers.cs b/src/Files.App/Utils/Storage/History/StorageHistoryHelpers.cs similarity index 92% rename from src/Files.App/Utils/StorageHistory/Helpers/StorageHistoryHelpers.cs rename to src/Files.App/Utils/Storage/History/StorageHistoryHelpers.cs index bffdca0c9b63..251696c8c289 100644 --- a/src/Files.App/Utils/StorageHistory/Helpers/StorageHistoryHelpers.cs +++ b/src/Files.App/Utils/Storage/History/StorageHistoryHelpers.cs @@ -1,11 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace Files.App.Utils.FilesystemHistory +namespace Files.App.Utils.Storage { public class StorageHistoryHelpers : IDisposable { diff --git a/src/Files.App/Utils/StorageHistory/StorageHistoryOperations.cs b/src/Files.App/Utils/Storage/History/StorageHistoryOperations.cs similarity index 96% rename from src/Files.App/Utils/StorageHistory/StorageHistoryOperations.cs rename to src/Files.App/Utils/Storage/History/StorageHistoryOperations.cs index 815e40af3d1f..a3d2a66882e7 100644 --- a/src/Files.App/Utils/StorageHistory/StorageHistoryOperations.cs +++ b/src/Files.App/Utils/Storage/History/StorageHistoryOperations.cs @@ -1,18 +1,10 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Helpers; -using Files.Shared.Extensions; -using System; -using System.Collections.Generic; -using System.Diagnostics; using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using Windows.Storage; -namespace Files.App.Utils.FilesystemHistory +namespace Files.App.Utils.Storage { public class StorageHistoryOperations : IStorageHistoryOperations { diff --git a/src/Files.App/Utils/StorageHistory/StorageHistoryWrapper.cs b/src/Files.App/Utils/Storage/History/StorageHistoryWrapper.cs similarity index 92% rename from src/Files.App/Utils/StorageHistory/StorageHistoryWrapper.cs rename to src/Files.App/Utils/Storage/History/StorageHistoryWrapper.cs index 113f17e3ae6b..4ef992a6bfb1 100644 --- a/src/Files.App/Utils/StorageHistory/StorageHistoryWrapper.cs +++ b/src/Files.App/Utils/Storage/History/StorageHistoryWrapper.cs @@ -1,10 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using System; -using System.Collections.Generic; - -namespace Files.App.Utils.FilesystemHistory +namespace Files.App.Utils.Storage { public class StorageHistoryWrapper : IDisposable { diff --git a/src/Files.App/Utils/FilesystemOperations/FileSystemProgress.cs b/src/Files.App/Utils/Storage/Operations/FileSystemProgress.cs similarity index 98% rename from src/Files.App/Utils/FilesystemOperations/FileSystemProgress.cs rename to src/Files.App/Utils/Storage/Operations/FileSystemProgress.cs index 62293539e21e..7909fe3145c1 100644 --- a/src/Files.App/Utils/FilesystemOperations/FileSystemProgress.cs +++ b/src/Files.App/Utils/Storage/Operations/FileSystemProgress.cs @@ -1,7 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -namespace Files.App.Utils +namespace Files.App.Utils.Storage { /// /// Represents a model for file system operation progress. diff --git a/src/Files.App/Utils/FilesystemOperations/Helpers/FilesystemHelpers.cs b/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs similarity index 99% rename from src/Files.App/Utils/FilesystemOperations/Helpers/FilesystemHelpers.cs rename to src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs index 062e916170e7..91405c0eba8c 100644 --- a/src/Files.App/Utils/FilesystemOperations/Helpers/FilesystemHelpers.cs +++ b/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs @@ -15,7 +15,7 @@ using Windows.Storage.Streams; using FileAttributes = System.IO.FileAttributes; -namespace Files.App.Utils +namespace Files.App.Utils.Storage { public sealed class FilesystemHelpers : IFilesystemHelpers { diff --git a/src/Files.App/Utils/FilesystemOperations/FilesystemOperations.cs b/src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs similarity index 99% rename from src/Files.App/Utils/FilesystemOperations/FilesystemOperations.cs rename to src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs index 08390dad2720..d1ec593e98e2 100644 --- a/src/Files.App/Utils/FilesystemOperations/FilesystemOperations.cs +++ b/src/Files.App/Utils/Storage/Operations/FilesystemOperations.cs @@ -1,17 +1,12 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.FilesystemHistory; -using Files.App.Utils.StorageItems; -using Files.Core.Helpers; -using Files.Core.Services; -using Files.Core.ViewModels.Dialogs; using Microsoft.UI.Xaml.Controls; using System.IO; using System.Text; using Windows.Storage; -namespace Files.App.Utils +namespace Files.App.Utils.Storage { /// /// Provides group of file system operation for given page instance. diff --git a/src/Files.App/Utils/FilesystemOperations/Helpers/IFilesystemHelpers.cs b/src/Files.App/Utils/Storage/Operations/IFilesystemHelpers.cs similarity index 99% rename from src/Files.App/Utils/FilesystemOperations/Helpers/IFilesystemHelpers.cs rename to src/Files.App/Utils/Storage/Operations/IFilesystemHelpers.cs index bef8b08822de..083e323b4c2f 100644 --- a/src/Files.App/Utils/FilesystemOperations/Helpers/IFilesystemHelpers.cs +++ b/src/Files.App/Utils/Storage/Operations/IFilesystemHelpers.cs @@ -1,13 +1,10 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using System; -using System.Collections.Generic; -using System.Threading.Tasks; using Windows.ApplicationModel.DataTransfer; using Windows.Storage; -namespace Files.App.Utils +namespace Files.App.Utils.Storage { public interface IFilesystemHelpers : IDisposable { diff --git a/src/Files.App/Utils/FilesystemOperations/IFilesystemOperations.cs b/src/Files.App/Utils/Storage/Operations/IFilesystemOperations.cs similarity index 99% rename from src/Files.App/Utils/FilesystemOperations/IFilesystemOperations.cs rename to src/Files.App/Utils/Storage/Operations/IFilesystemOperations.cs index 209a11816bca..299b4e8d3c68 100644 --- a/src/Files.App/Utils/FilesystemOperations/IFilesystemOperations.cs +++ b/src/Files.App/Utils/Storage/Operations/IFilesystemOperations.cs @@ -1,10 +1,9 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.FilesystemHistory; using Windows.Storage; -namespace Files.App.Utils +namespace Files.App.Utils.Storage { /// /// Represents an interface for file system operations. diff --git a/src/Files.App/Utils/FilesystemOperations/ShellFilesystemOperations.cs b/src/Files.App/Utils/Storage/Operations/ShellFilesystemOperations.cs similarity index 99% rename from src/Files.App/Utils/FilesystemOperations/ShellFilesystemOperations.cs rename to src/Files.App/Utils/Storage/Operations/ShellFilesystemOperations.cs index ffae93c706a6..68f16917b5dd 100644 --- a/src/Files.App/Utils/FilesystemOperations/ShellFilesystemOperations.cs +++ b/src/Files.App/Utils/Storage/Operations/ShellFilesystemOperations.cs @@ -1,16 +1,10 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.FilesystemHistory; -using Files.App.Utils.StorageItems; -using Files.App.Utils.Shell; -using Files.Core.Services; -using Files.Core.Utils.CommandLine; -using Files.Core.ViewModels.Dialogs.FileSystemDialog; using System.IO; using Windows.Storage; -namespace Files.App.Utils +namespace Files.App.Utils.Storage { /// /// Provides group of shell file system operation for given page instance. diff --git a/src/Files.App/Utils/Search/FolderSearch.cs b/src/Files.App/Utils/Storage/Search/FolderSearch.cs similarity index 97% rename from src/Files.App/Utils/Search/FolderSearch.cs rename to src/Files.App/Utils/Storage/Search/FolderSearch.cs index ab9843846031..ee04a3301878 100644 --- a/src/Files.App/Utils/Search/FolderSearch.cs +++ b/src/Files.App/Utils/Storage/Search/FolderSearch.cs @@ -1,23 +1,8 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using CommunityToolkit.Mvvm.DependencyInjection; -using CommunityToolkit.WinUI; -using Files.App.Data.Items; -using Files.App.Extensions; -using Files.App.Utils.StorageItems; -using Files.App.Helpers; -using Files.App.ViewModels; -using Files.Core.Services.Settings; -using Files.Shared.Extensions; using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using Windows.Storage; using Windows.Storage.FileProperties; using Windows.Storage.Search; @@ -25,7 +10,7 @@ using FileAttributes = System.IO.FileAttributes; using WIN32_FIND_DATA = Files.Core.Helpers.NativeFindStorageItemHelper.WIN32_FIND_DATA; -namespace Files.App.Utils.Search +namespace Files.App.Utils.Storage { public class FolderSearch { diff --git a/src/Files.App/Utils/Security/AccessControlEntry.cs b/src/Files.App/Utils/Storage/Security/AccessControlEntry.cs similarity index 97% rename from src/Files.App/Utils/Security/AccessControlEntry.cs rename to src/Files.App/Utils/Storage/Security/AccessControlEntry.cs index 20b6f8cd1b29..4e2c389f32ba 100644 --- a/src/Files.App/Utils/Security/AccessControlEntry.cs +++ b/src/Files.App/Utils/Storage/Security/AccessControlEntry.cs @@ -1,16 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using CommunityToolkit.Mvvm.ComponentModel; -using CommunityToolkit.Mvvm.Input; -using Files.App.Data.Factories; -using Files.App.Extensions; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; - -namespace Files.App.Utils.Security +namespace Files.App.Utils.Storage { /// /// Represents an access control entry (ACE). diff --git a/src/Files.App/Utils/Security/AccessControlEntryFlags.cs b/src/Files.App/Utils/Storage/Security/AccessControlEntryFlags.cs similarity index 97% rename from src/Files.App/Utils/Security/AccessControlEntryFlags.cs rename to src/Files.App/Utils/Storage/Security/AccessControlEntryFlags.cs index 97f27257be6c..6663beb01116 100644 --- a/src/Files.App/Utils/Security/AccessControlEntryFlags.cs +++ b/src/Files.App/Utils/Storage/Security/AccessControlEntryFlags.cs @@ -1,7 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -namespace Files.App.Utils.Security +namespace Files.App.Utils.Storage { /// /// Represents inheritance flags of an ACE diff --git a/src/Files.App/Utils/Security/AccessControlEntryType.cs b/src/Files.App/Utils/Storage/Security/AccessControlEntryType.cs similarity index 90% rename from src/Files.App/Utils/Security/AccessControlEntryType.cs rename to src/Files.App/Utils/Storage/Security/AccessControlEntryType.cs index 52166b26ec68..5808242154cf 100644 --- a/src/Files.App/Utils/Security/AccessControlEntryType.cs +++ b/src/Files.App/Utils/Storage/Security/AccessControlEntryType.cs @@ -1,7 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -namespace Files.App.Utils.Security +namespace Files.App.Utils.Storage { /// /// Represents ACE type. diff --git a/src/Files.App/Utils/Security/AccessControlList.cs b/src/Files.App/Utils/Storage/Security/AccessControlList.cs similarity index 97% rename from src/Files.App/Utils/Security/AccessControlList.cs rename to src/Files.App/Utils/Storage/Security/AccessControlList.cs index 37ed5f912b8a..8f3acb76d0d8 100644 --- a/src/Files.App/Utils/Security/AccessControlList.cs +++ b/src/Files.App/Utils/Storage/Security/AccessControlList.cs @@ -1,7 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -namespace Files.App.Utils.Security +namespace Files.App.Utils.Storage { /// /// Represents an access control list (ACL). diff --git a/src/Files.App/Utils/Security/AccessMaskFlags.cs b/src/Files.App/Utils/Storage/Security/AccessMaskFlags.cs similarity index 97% rename from src/Files.App/Utils/Security/AccessMaskFlags.cs rename to src/Files.App/Utils/Storage/Security/AccessMaskFlags.cs index 1b2753fea4cb..915c2ea730ab 100644 --- a/src/Files.App/Utils/Security/AccessMaskFlags.cs +++ b/src/Files.App/Utils/Storage/Security/AccessMaskFlags.cs @@ -1,9 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using System; - -namespace Files.App.Utils.Security +namespace Files.App.Utils.Storage { /// /// Represents access mask flags of an ACE. diff --git a/src/Files.App/Utils/Security/AccessMaskItem.cs b/src/Files.App/Utils/Storage/Security/AccessMaskItem.cs similarity index 92% rename from src/Files.App/Utils/Security/AccessMaskItem.cs rename to src/Files.App/Utils/Storage/Security/AccessMaskItem.cs index 7351875a39d1..624fc320a8da 100644 --- a/src/Files.App/Utils/Security/AccessMaskItem.cs +++ b/src/Files.App/Utils/Storage/Security/AccessMaskItem.cs @@ -1,10 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using CommunityToolkit.Mvvm.ComponentModel; -using System.ComponentModel; - -namespace Files.App.Utils.Security +namespace Files.App.Utils.Storage { /// /// Represents an access mask details, such as its name and changeability. diff --git a/src/Files.App/Utils/Security/Principal.cs b/src/Files.App/Utils/Storage/Security/Principal.cs similarity index 98% rename from src/Files.App/Utils/Security/Principal.cs rename to src/Files.App/Utils/Storage/Security/Principal.cs index 5139d41ec25b..9efd117413dc 100644 --- a/src/Files.App/Utils/Security/Principal.cs +++ b/src/Files.App/Utils/Storage/Security/Principal.cs @@ -5,7 +5,7 @@ using Vanara.PInvoke; using static Vanara.PInvoke.AdvApi32; -namespace Files.App.Utils.Security +namespace Files.App.Utils.Storage { /// /// Represents a principal of an ACE or an owner of an ACL. diff --git a/src/Files.App/Utils/Security/PrincipalType.cs b/src/Files.App/Utils/Storage/Security/PrincipalType.cs similarity index 92% rename from src/Files.App/Utils/Security/PrincipalType.cs rename to src/Files.App/Utils/Storage/Security/PrincipalType.cs index 3b9718f90b7f..c594aadd3551 100644 --- a/src/Files.App/Utils/Security/PrincipalType.cs +++ b/src/Files.App/Utils/Storage/Security/PrincipalType.cs @@ -1,7 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -namespace Files.App.Utils.Security +namespace Files.App.Utils.Storage { /// /// Represents an ACL owner or an ACE principal type diff --git a/src/Files.App/Utils/BaseStorage/BaseBasicProperties.cs b/src/Files.App/Utils/Storage/StorageBaseItems/BaseBasicProperties.cs similarity index 89% rename from src/Files.App/Utils/BaseStorage/BaseBasicProperties.cs rename to src/Files.App/Utils/Storage/StorageBaseItems/BaseBasicProperties.cs index b0e2f7f6097e..b1e880ecee83 100644 --- a/src/Files.App/Utils/BaseStorage/BaseBasicProperties.cs +++ b/src/Files.App/Utils/Storage/StorageBaseItems/BaseBasicProperties.cs @@ -1,7 +1,7 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public class BaseBasicProperties : BaseStorageItemExtraProperties { diff --git a/src/Files.App/Utils/BaseStorage/BaseBasicStorageItemExtraProperties.cs b/src/Files.App/Utils/Storage/StorageBaseItems/BaseBasicStorageItemExtraProperties.cs similarity index 96% rename from src/Files.App/Utils/BaseStorage/BaseBasicStorageItemExtraProperties.cs rename to src/Files.App/Utils/Storage/StorageBaseItems/BaseBasicStorageItemExtraProperties.cs index bd446839ee02..18ab84748730 100644 --- a/src/Files.App/Utils/BaseStorage/BaseBasicStorageItemExtraProperties.cs +++ b/src/Files.App/Utils/Storage/StorageBaseItems/BaseBasicStorageItemExtraProperties.cs @@ -5,7 +5,7 @@ using Windows.Foundation; using Windows.Storage; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public class BaseBasicStorageItemExtraProperties : BaseStorageItemExtraProperties { diff --git a/src/Files.App/Utils/BaseStorage/BaseStorageFile.cs b/src/Files.App/Utils/Storage/StorageBaseItems/BaseStorageFile.cs similarity index 99% rename from src/Files.App/Utils/BaseStorage/BaseStorageFile.cs rename to src/Files.App/Utils/Storage/StorageBaseItems/BaseStorageFile.cs index cb503901a9eb..4cfdd3159b7f 100644 --- a/src/Files.App/Utils/BaseStorage/BaseStorageFile.cs +++ b/src/Files.App/Utils/Storage/StorageBaseItems/BaseStorageFile.cs @@ -9,7 +9,7 @@ using Windows.Storage.FileProperties; using Windows.Storage.Streams; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public abstract class BaseStorageFile : IBaseStorageFile { diff --git a/src/Files.App/Utils/BaseStorage/BaseStorageFolder.cs b/src/Files.App/Utils/Storage/StorageBaseItems/BaseStorageFolder.cs similarity index 99% rename from src/Files.App/Utils/BaseStorage/BaseStorageFolder.cs rename to src/Files.App/Utils/Storage/StorageBaseItems/BaseStorageFolder.cs index fe4731fea22a..9d602a655262 100644 --- a/src/Files.App/Utils/BaseStorage/BaseStorageFolder.cs +++ b/src/Files.App/Utils/Storage/StorageBaseItems/BaseStorageFolder.cs @@ -7,7 +7,7 @@ using Windows.Storage.FileProperties; using Windows.Storage.Search; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public abstract class BaseStorageFolder : IBaseStorageFolder { diff --git a/src/Files.App/Utils/BaseStorage/BaseStorageItemExtraProperties.cs b/src/Files.App/Utils/Storage/StorageBaseItems/BaseStorageItemExtraProperties.cs similarity index 96% rename from src/Files.App/Utils/BaseStorage/BaseStorageItemExtraProperties.cs rename to src/Files.App/Utils/Storage/StorageBaseItems/BaseStorageItemExtraProperties.cs index bc90b5a4bc71..1c6e8c7a737f 100644 --- a/src/Files.App/Utils/BaseStorage/BaseStorageItemExtraProperties.cs +++ b/src/Files.App/Utils/Storage/StorageBaseItems/BaseStorageItemExtraProperties.cs @@ -6,7 +6,7 @@ using Windows.Foundation.Metadata; using Windows.Storage.FileProperties; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public class BaseStorageItemExtraProperties : IStorageItemExtraProperties { diff --git a/src/Files.App/Utils/BaseStorage/IBaseStorageFile.cs b/src/Files.App/Utils/Storage/StorageBaseItems/IBaseStorageFile.cs similarity index 96% rename from src/Files.App/Utils/BaseStorage/IBaseStorageFile.cs rename to src/Files.App/Utils/Storage/StorageBaseItems/IBaseStorageFile.cs index e3f4008c471e..66af49d24212 100644 --- a/src/Files.App/Utils/BaseStorage/IBaseStorageFile.cs +++ b/src/Files.App/Utils/Storage/StorageBaseItems/IBaseStorageFile.cs @@ -5,7 +5,7 @@ using Windows.Storage; using Windows.Storage.FileProperties; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public interface IBaseStorageFile : IStorageItem2, IStorageFile, IStorageFile2, IStorageItemProperties2, IStorageItemPropertiesWithProvider, IStorageFilePropertiesWithAvailability { diff --git a/src/Files.App/Utils/BaseStorage/IBaseStorageFolder.cs b/src/Files.App/Utils/Storage/StorageBaseItems/IBaseStorageFolder.cs similarity index 98% rename from src/Files.App/Utils/BaseStorage/IBaseStorageFolder.cs rename to src/Files.App/Utils/Storage/StorageBaseItems/IBaseStorageFolder.cs index ef782bf8dfff..e85ef38357de 100644 --- a/src/Files.App/Utils/BaseStorage/IBaseStorageFolder.cs +++ b/src/Files.App/Utils/Storage/StorageBaseItems/IBaseStorageFolder.cs @@ -7,7 +7,7 @@ using Windows.Storage.FileProperties; using Windows.Storage.Search; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public interface IBaseStorageFolder : IStorageItem2, IStorageFolder, IStorageFolder2, IStorageItemProperties2, IStorageItemPropertiesWithProvider, IStorageFolderQueryOperations { diff --git a/src/Files.App/Utils/BaseStorage/ICreateFileWithStream.cs b/src/Files.App/Utils/Storage/StorageBaseItems/ICreateFileWithStream.cs similarity index 91% rename from src/Files.App/Utils/BaseStorage/ICreateFileWithStream.cs rename to src/Files.App/Utils/Storage/StorageBaseItems/ICreateFileWithStream.cs index 2919002eb074..71b036cb5b68 100644 --- a/src/Files.App/Utils/BaseStorage/ICreateFileWithStream.cs +++ b/src/Files.App/Utils/Storage/StorageBaseItems/ICreateFileWithStream.cs @@ -5,7 +5,7 @@ using Windows.Foundation; using Windows.Storage; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public interface ICreateFileWithStream { diff --git a/src/Files.App/Utils/BaseStorage/IPasswordProtectedItem.cs b/src/Files.App/Utils/Storage/StorageBaseItems/IPasswordProtectedItem.cs similarity index 90% rename from src/Files.App/Utils/BaseStorage/IPasswordProtectedItem.cs rename to src/Files.App/Utils/Storage/StorageBaseItems/IPasswordProtectedItem.cs index a2a1df16ad5e..51aab465e67d 100644 --- a/src/Files.App/Utils/BaseStorage/IPasswordProtectedItem.cs +++ b/src/Files.App/Utils/Storage/StorageBaseItems/IPasswordProtectedItem.cs @@ -1,9 +1,12 @@ -using FluentFTP; +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +using FluentFTP; using SevenZip; using System; using Windows.Storage; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public interface IPasswordProtectedItem { @@ -16,10 +19,12 @@ async Task RetryWithCredentials(Func> func, Exception exc var handled = exception is SevenZipOpenFailedException szofex && szofex.Result is OperationResult.WrongPassword || exception is ExtractionFailedException efex && efex.Result is OperationResult.WrongPassword || exception is FtpAuthenticationException; + if (!handled || PasswordRequestedCallback is null) throw exception; Credentials = await PasswordRequestedCallback(this); + return await func(); } @@ -28,10 +33,12 @@ async Task RetryWithCredentials(Func func, Exception exception) var handled = exception is SevenZipOpenFailedException szofex && szofex.Result is OperationResult.WrongPassword || exception is ExtractionFailedException efex && efex.Result is OperationResult.WrongPassword || exception is FtpAuthenticationException; + if (!handled || PasswordRequestedCallback is null) throw exception; Credentials = await PasswordRequestedCallback(this); + await func(); } diff --git a/src/Files.App/Utils/BaseStorage/StorageCredential.cs b/src/Files.App/Utils/Storage/StorageBaseItems/StorageCredential.cs similarity index 88% rename from src/Files.App/Utils/BaseStorage/StorageCredential.cs rename to src/Files.App/Utils/Storage/StorageBaseItems/StorageCredential.cs index 15a3897ca42f..fcdf9ecb1da9 100644 --- a/src/Files.App/Utils/BaseStorage/StorageCredential.cs +++ b/src/Files.App/Utils/Storage/StorageBaseItems/StorageCredential.cs @@ -1,35 +1,37 @@ -using System.Runtime.InteropServices; +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +using System.Runtime.InteropServices; using System.Security; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { // Code from System.Net.NetworkCredential public class StorageCredential { private string _userName = string.Empty; - private object? _password; - public string UserName { - get { return _userName; } - set { _userName = value ?? string.Empty; } + get => _userName; + set => _userName = value ?? string.Empty; } + private object? _password; public string Password { get { SecureString? sstr = _password as SecureString; if (sstr != null) - { return MarshalToString(sstr); - } + return (string?)_password ?? string.Empty; } set { SecureString? old = _password as SecureString; _password = value; + old?.Dispose(); } } @@ -40,9 +42,8 @@ public SecureString SecurePassword { string? str = _password as string; if (str != null) - { return MarshalToSecureString(str); - } + SecureString? sstr = _password as SecureString; return sstr != null ? sstr.Copy() : new SecureString(); } @@ -50,6 +51,7 @@ public SecureString SecurePassword { SecureString? old = _password as SecureString; _password = value?.Copy(); + old?.Dispose(); } } @@ -74,12 +76,11 @@ public StorageCredential(string? userName, SecureString? password) private static string MarshalToString(SecureString sstr) { if (sstr == null || sstr.Length == 0) - { return string.Empty; - } IntPtr ptr = IntPtr.Zero; string result = string.Empty; + try { ptr = Marshal.SecureStringToGlobalAllocUnicode(sstr); @@ -88,24 +89,19 @@ private static string MarshalToString(SecureString sstr) finally { if (ptr != IntPtr.Zero) - { Marshal.ZeroFreeGlobalAllocUnicode(ptr); - } } + return result; } private unsafe SecureString MarshalToSecureString(string str) { if (string.IsNullOrEmpty(str)) - { return new SecureString(); - } fixed (char* ptr = str) - { return new SecureString(ptr, str.Length); - } } } } diff --git a/src/Files.App/Utils/StorageItems/BaseQueryResults.cs b/src/Files.App/Utils/Storage/StorageItems/BaseQueryResults.cs similarity index 98% rename from src/Files.App/Utils/StorageItems/BaseQueryResults.cs rename to src/Files.App/Utils/Storage/StorageItems/BaseQueryResults.cs index ff812c8910f0..832ab5a00870 100644 --- a/src/Files.App/Utils/StorageItems/BaseQueryResults.cs +++ b/src/Files.App/Utils/Storage/StorageItems/BaseQueryResults.cs @@ -1,16 +1,13 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using System.Text.RegularExpressions; using Windows.Foundation; using Windows.Storage; using Windows.Storage.Search; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public class BaseStorageItemQueryResult { diff --git a/src/Files.App/Utils/StorageItems/FtpStorageFile.cs b/src/Files.App/Utils/Storage/StorageItems/FtpStorageFile.cs similarity index 99% rename from src/Files.App/Utils/StorageItems/FtpStorageFile.cs rename to src/Files.App/Utils/Storage/StorageItems/FtpStorageFile.cs index dfab157b4fec..a349ce5eb826 100644 --- a/src/Files.App/Utils/StorageItems/FtpStorageFile.cs +++ b/src/Files.App/Utils/Storage/StorageItems/FtpStorageFile.cs @@ -12,7 +12,7 @@ using Windows.Storage.Streams; using IO = System.IO; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public sealed class FtpStorageFile : BaseStorageFile, IPasswordProtectedItem { diff --git a/src/Files.App/Utils/StorageItems/FtpStorageFolder.cs b/src/Files.App/Utils/Storage/StorageItems/FtpStorageFolder.cs similarity index 99% rename from src/Files.App/Utils/StorageItems/FtpStorageFolder.cs rename to src/Files.App/Utils/Storage/StorageItems/FtpStorageFolder.cs index baa2ae242895..4dffdae21d12 100644 --- a/src/Files.App/Utils/StorageItems/FtpStorageFolder.cs +++ b/src/Files.App/Utils/Storage/StorageItems/FtpStorageFolder.cs @@ -12,7 +12,7 @@ using Windows.Storage.FileProperties; using Windows.Storage.Search; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public sealed class FtpStorageFolder : BaseStorageFolder, IPasswordProtectedItem { diff --git a/src/Files.App/Utils/StorageItems/NativeStorageFile.cs b/src/Files.App/Utils/Storage/StorageItems/NativeStorageFile.cs similarity index 97% rename from src/Files.App/Utils/StorageItems/NativeStorageFile.cs rename to src/Files.App/Utils/Storage/StorageItems/NativeStorageFile.cs index 431dbed2e16a..df396fef8352 100644 --- a/src/Files.App/Utils/StorageItems/NativeStorageFile.cs +++ b/src/Files.App/Utils/Storage/StorageItems/NativeStorageFile.cs @@ -1,22 +1,16 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Extensions; -using Files.App.Helpers; -using Files.Core.Helpers; -using System; -using System.ComponentModel; using System.IO; using System.Runtime.InteropServices; using System.Runtime.InteropServices.WindowsRuntime; -using System.Threading.Tasks; using Windows.Foundation; using Windows.Storage; using Windows.Storage.FileProperties; using Windows.Storage.Streams; using IO = System.IO; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { /// /// Shortcuts and alternate data stream. diff --git a/src/Files.App/Utils/StorageItems/ShellStorageFile.cs b/src/Files.App/Utils/Storage/StorageItems/ShellStorageFile.cs similarity index 98% rename from src/Files.App/Utils/StorageItems/ShellStorageFile.cs rename to src/Files.App/Utils/Storage/StorageItems/ShellStorageFile.cs index 41312bdd5763..64a40a6303a0 100644 --- a/src/Files.App/Utils/StorageItems/ShellStorageFile.cs +++ b/src/Files.App/Utils/Storage/StorageItems/ShellStorageFile.cs @@ -1,18 +1,14 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.Shell; -using Files.Shared; -using System; using System.Runtime.InteropServices.WindowsRuntime; -using System.Threading.Tasks; using Windows.Foundation; using Windows.Storage; using Windows.Storage.FileProperties; using Windows.Storage.Streams; using IO = System.IO; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public class ShortcutStorageFile : ShellStorageFile, IShortcutStorageItem { diff --git a/src/Files.App/Utils/StorageItems/ShellStorageFolder.cs b/src/Files.App/Utils/Storage/StorageItems/ShellStorageFolder.cs similarity index 98% rename from src/Files.App/Utils/StorageItems/ShellStorageFolder.cs rename to src/Files.App/Utils/Storage/StorageItems/ShellStorageFolder.cs index cfd7d59c9163..e576ce096b0b 100644 --- a/src/Files.App/Utils/StorageItems/ShellStorageFolder.cs +++ b/src/Files.App/Utils/Storage/StorageItems/ShellStorageFolder.cs @@ -1,19 +1,13 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.Shell; -using Files.Shared; -using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; -using System.Threading.Tasks; using Windows.Foundation; using Windows.Storage; using Windows.Storage.FileProperties; using Windows.Storage.Search; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public class ShortcutStorageFolder : ShellStorageFolder, IShortcutStorageItem { diff --git a/src/Files.App/Utils/StorageItems/StreamWithContentType.cs b/src/Files.App/Utils/Storage/StorageItems/StreamWithContentType.cs similarity index 99% rename from src/Files.App/Utils/StorageItems/StreamWithContentType.cs rename to src/Files.App/Utils/Storage/StorageItems/StreamWithContentType.cs index 56c12189fe45..8cb1ad5c575c 100644 --- a/src/Files.App/Utils/StorageItems/StreamWithContentType.cs +++ b/src/Files.App/Utils/Storage/StorageItems/StreamWithContentType.cs @@ -8,7 +8,7 @@ using Windows.Foundation; using Windows.Storage.Streams; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public class InputStreamWithDisposeCallback : IInputStream { diff --git a/src/Files.App/Utils/StorageItems/SystemStorageFile.cs b/src/Files.App/Utils/Storage/StorageItems/SystemStorageFile.cs similarity index 98% rename from src/Files.App/Utils/StorageItems/SystemStorageFile.cs rename to src/Files.App/Utils/Storage/StorageItems/SystemStorageFile.cs index bd5902ff0741..45ff4c34ae61 100644 --- a/src/Files.App/Utils/StorageItems/SystemStorageFile.cs +++ b/src/Files.App/Utils/Storage/StorageItems/SystemStorageFile.cs @@ -1,12 +1,8 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Helpers; -using System; -using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices.WindowsRuntime; -using System.Threading.Tasks; using Windows.Foundation; using Windows.Foundation.Metadata; using Windows.Storage; @@ -14,7 +10,7 @@ using Windows.Storage.Streams; using IO = System.IO; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public sealed class SystemStorageFile : BaseStorageFile { diff --git a/src/Files.App/Utils/StorageItems/SystemStorageFolder.cs b/src/Files.App/Utils/Storage/StorageItems/SystemStorageFolder.cs similarity index 98% rename from src/Files.App/Utils/StorageItems/SystemStorageFolder.cs rename to src/Files.App/Utils/Storage/StorageItems/SystemStorageFolder.cs index 8b4ad1cd73a0..ecbb79d15ad0 100644 --- a/src/Files.App/Utils/StorageItems/SystemStorageFolder.cs +++ b/src/Files.App/Utils/Storage/StorageItems/SystemStorageFolder.cs @@ -1,18 +1,14 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; -using System.Threading.Tasks; using Windows.Foundation; using Windows.Foundation.Metadata; using Windows.Storage; using Windows.Storage.FileProperties; using Windows.Storage.Search; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public sealed class SystemStorageFolder : BaseStorageFolder { diff --git a/src/Files.App/Utils/StorageItems/VirtualStorageFile.cs b/src/Files.App/Utils/Storage/StorageItems/VirtualStorageFile.cs similarity index 99% rename from src/Files.App/Utils/StorageItems/VirtualStorageFile.cs rename to src/Files.App/Utils/Storage/StorageItems/VirtualStorageFile.cs index f3b9ee3ebc1d..7c938f5e6c54 100644 --- a/src/Files.App/Utils/StorageItems/VirtualStorageFile.cs +++ b/src/Files.App/Utils/Storage/StorageItems/VirtualStorageFile.cs @@ -9,7 +9,7 @@ using Windows.Storage.Streams; using IO = System.IO; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public class VirtualStorageFile : BaseStorageFile { diff --git a/src/Files.App/Utils/StorageItems/VirtualStorageFolder.cs b/src/Files.App/Utils/Storage/StorageItems/VirtualStorageFolder.cs similarity index 99% rename from src/Files.App/Utils/StorageItems/VirtualStorageFolder.cs rename to src/Files.App/Utils/Storage/StorageItems/VirtualStorageFolder.cs index 6eef2a81eaa8..47e890f50ae8 100644 --- a/src/Files.App/Utils/StorageItems/VirtualStorageFolder.cs +++ b/src/Files.App/Utils/Storage/StorageItems/VirtualStorageFolder.cs @@ -7,7 +7,7 @@ using Windows.Storage.FileProperties; using Windows.Storage.Search; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public class VirtualStorageFolder : BaseStorageFolder { diff --git a/src/Files.App/Utils/StorageItems/VirtualStorageItem.cs b/src/Files.App/Utils/Storage/StorageItems/VirtualStorageItem.cs similarity index 97% rename from src/Files.App/Utils/StorageItems/VirtualStorageItem.cs rename to src/Files.App/Utils/Storage/StorageItems/VirtualStorageItem.cs index a132a4db9995..81b3a1eabeff 100644 --- a/src/Files.App/Utils/StorageItems/VirtualStorageItem.cs +++ b/src/Files.App/Utils/Storage/StorageItems/VirtualStorageItem.cs @@ -1,17 +1,14 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Helpers; -using System; using System.IO; using System.Runtime.InteropServices.WindowsRuntime; -using System.Threading.Tasks; using Windows.Foundation; using Windows.Storage; using Windows.Storage.FileProperties; using static Files.Core.Helpers.NativeFindStorageItemHelper; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { /// /// Implements IStorageItem, allowing us to get an instance of IStorageItem for a ListedItem diff --git a/src/Files.App/Utils/StorageItems/ZipStorageFile.cs b/src/Files.App/Utils/Storage/StorageItems/ZipStorageFile.cs similarity index 98% rename from src/Files.App/Utils/StorageItems/ZipStorageFile.cs rename to src/Files.App/Utils/Storage/StorageItems/ZipStorageFile.cs index cab66f3b0dfe..53fe4a91de1d 100644 --- a/src/Files.App/Utils/StorageItems/ZipStorageFile.cs +++ b/src/Files.App/Utils/Storage/StorageItems/ZipStorageFile.cs @@ -1,23 +1,16 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Extensions; -using Files.App.Helpers; -using Files.Core.Helpers; using SevenZip; -using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; -using System.Threading.Tasks; using Windows.Foundation; using Windows.Storage; using Windows.Storage.FileProperties; using Windows.Storage.Streams; using IO = System.IO; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public sealed class ZipStorageFile : BaseStorageFile, IPasswordProtectedItem { diff --git a/src/Files.App/Utils/StorageItems/ZipStorageFolder.cs b/src/Files.App/Utils/Storage/StorageItems/ZipStorageFolder.cs similarity index 99% rename from src/Files.App/Utils/StorageItems/ZipStorageFolder.cs rename to src/Files.App/Utils/Storage/StorageItems/ZipStorageFolder.cs index dbc1846f3cf5..e59a1436be6e 100644 --- a/src/Files.App/Utils/StorageItems/ZipStorageFolder.cs +++ b/src/Files.App/Utils/Storage/StorageItems/ZipStorageFolder.cs @@ -1,19 +1,12 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Extensions; -using Files.App.Helpers; -using Files.Core.Helpers; -using Files.Shared.Extensions; using SevenZip; using SQLitePCL; using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; -using System.Threading.Tasks; using Windows.ApplicationModel; using Windows.Foundation; using Windows.Storage; @@ -21,7 +14,7 @@ using Windows.Storage.Search; using IO = System.IO; -namespace Files.App.Utils.StorageItems +namespace Files.App.Utils.Storage { public sealed class ZipStorageFolder : BaseStorageFolder, ICreateFileWithStream, IPasswordProtectedItem { diff --git a/src/Files.App/ViewModels/LayoutModes/BaseLayoutViewModel.cs b/src/Files.App/ViewModels/LayoutModes/BaseLayoutViewModel.cs index 33736b6aceaa..b839e0d7b411 100644 --- a/src/Files.App/ViewModels/LayoutModes/BaseLayoutViewModel.cs +++ b/src/Files.App/ViewModels/LayoutModes/BaseLayoutViewModel.cs @@ -1,7 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Input; using System.IO; diff --git a/src/Files.App/ViewModels/MainPageViewModel.cs b/src/Files.App/ViewModels/MainPageViewModel.cs index 86626e68b187..5866f1116a09 100644 --- a/src/Files.App/ViewModels/MainPageViewModel.cs +++ b/src/Files.App/ViewModels/MainPageViewModel.cs @@ -1,7 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; using Files.App.UserControls.MultitaskingControl; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Input; diff --git a/src/Files.App/ViewModels/Previews/BasePreviewModel.cs b/src/Files.App/ViewModels/Previews/BasePreviewModel.cs index e908434e1dfc..c58e73ea19e3 100644 --- a/src/Files.App/ViewModels/Previews/BasePreviewModel.cs +++ b/src/Files.App/ViewModels/Previews/BasePreviewModel.cs @@ -1,7 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; using Files.App.ViewModels.Properties; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Media.Imaging; diff --git a/src/Files.App/ViewModels/Properties/Items/CombinedFileProperties.cs b/src/Files.App/ViewModels/Properties/Items/CombinedFileProperties.cs index d1372a888096..874d24c60d01 100644 --- a/src/Files.App/ViewModels/Properties/Items/CombinedFileProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/CombinedFileProperties.cs @@ -1,7 +1,6 @@ // Copyright(c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; using Microsoft.UI.Dispatching; namespace Files.App.ViewModels.Properties diff --git a/src/Files.App/ViewModels/Properties/Items/DriveProperties.cs b/src/Files.App/ViewModels/Properties/Items/DriveProperties.cs index 0596781ecc21..aaa5a5e40cef 100644 --- a/src/Files.App/ViewModels/Properties/Items/DriveProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/DriveProperties.cs @@ -1,7 +1,6 @@ using Files.App.Data.Items; using Files.App.Extensions; using Files.App.Utils; -using Files.App.Utils.StorageItems; using Files.App.Helpers; using Microsoft.Extensions.Logging; using System; diff --git a/src/Files.App/ViewModels/Properties/Items/FileProperties.cs b/src/Files.App/ViewModels/Properties/Items/FileProperties.cs index d0de00b405f8..33f166828ef5 100644 --- a/src/Files.App/ViewModels/Properties/Items/FileProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/FileProperties.cs @@ -1,7 +1,6 @@ // Copyright(c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; using Files.Core.Helpers; using Microsoft.UI.Dispatching; using System.IO; diff --git a/src/Files.App/ViewModels/Properties/Items/FileProperty.cs b/src/Files.App/ViewModels/Properties/Items/FileProperty.cs index 0436d3f860a5..70bd644e23e4 100644 --- a/src/Files.App/ViewModels/Properties/Items/FileProperty.cs +++ b/src/Files.App/ViewModels/Properties/Items/FileProperty.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See the LICENSE. using Files.App.Converters; -using Files.App.Utils.StorageItems; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Data; using System.Text.Json; diff --git a/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs b/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs index 4fb30616d561..ab24eef38633 100644 --- a/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See the LICENSE. using ByteSizeLib; -using Files.App.Utils.StorageItems; using Files.App.Utils.Shell; using Microsoft.Extensions.Logging; using Microsoft.UI.Dispatching; diff --git a/src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs b/src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs index 107ce00982ba..64c1debe9d6b 100644 --- a/src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs @@ -1,7 +1,6 @@ using CommunityToolkit.Mvvm.DependencyInjection; using Files.App.Extensions; using Files.App.Utils; -using Files.App.Utils.StorageItems; using Files.App.Helpers; using Microsoft.Extensions.Logging; using Microsoft.UI.Dispatching; diff --git a/src/Files.App/ViewModels/Properties/SecurityAdvancedViewModel.cs b/src/Files.App/ViewModels/Properties/SecurityAdvancedViewModel.cs index 8d4ae7deac36..025317349c40 100644 --- a/src/Files.App/ViewModels/Properties/SecurityAdvancedViewModel.cs +++ b/src/Files.App/ViewModels/Properties/SecurityAdvancedViewModel.cs @@ -1,7 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.Security; using Microsoft.UI.Xaml; using Vanara.PInvoke; using Windows.Storage; diff --git a/src/Files.App/ViewModels/Properties/SecurityViewModel.cs b/src/Files.App/ViewModels/Properties/SecurityViewModel.cs index a3ac248f4e0b..73c0e0bca0d7 100644 --- a/src/Files.App/ViewModels/Properties/SecurityViewModel.cs +++ b/src/Files.App/ViewModels/Properties/SecurityViewModel.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See the LICENSE. using CommunityToolkit.WinUI; -using Files.App.Utils.Security; using Microsoft.UI.Xaml; using Vanara.PInvoke; using Windows.Storage; diff --git a/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs b/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs index 5059e6541178..3b385184769b 100644 --- a/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs +++ b/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs @@ -1,7 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.StorageItems; using Files.App.Utils.Shell; using Microsoft.Extensions.Logging; using Microsoft.Win32; diff --git a/src/Files.App/Views/LayoutModes/BaseLayout.cs b/src/Files.App/Views/LayoutModes/BaseLayout.cs index 3c26d773f3d8..24fcc09e17de 100644 --- a/src/Files.App/Views/LayoutModes/BaseLayout.cs +++ b/src/Files.App/Views/LayoutModes/BaseLayout.cs @@ -446,7 +446,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs eventArgs) { var displayName = App.LibraryManager.TryGetLibrary(navigationArguments.SearchPathParam, out var lib) ? lib.Text : navigationArguments.SearchPathParam; ParentShellPageInstance.UpdatePathUIToWorkingDirectory(null, string.Format("SearchPagePathBoxOverrideText".GetLocalizedResource(), navigationArguments.SearchQuery, displayName)); - var searchInstance = new Utils.Search.FolderSearch + var searchInstance = new Utils.Storage.FolderSearch { Query = navigationArguments.SearchQuery, Folder = navigationArguments.SearchPathParam, diff --git a/src/Files.App/Views/LayoutModes/ColumnViewBase.xaml b/src/Files.App/Views/LayoutModes/ColumnViewBase.xaml index 5f84f062d166..873fcf796d1a 100644 --- a/src/Files.App/Views/LayoutModes/ColumnViewBase.xaml +++ b/src/Files.App/Views/LayoutModes/ColumnViewBase.xaml @@ -10,6 +10,7 @@ xmlns:helpers="using:Files.App.Helpers" xmlns:local="using:Files.App.Views.LayoutModes" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:storage="using:Files.App.Utils.Storage" xmlns:uc="using:Files.App.UserControls" xmlns:wct="using:CommunityToolkit.WinUI.UI" xmlns:wctconverters="using:CommunityToolkit.WinUI.UI.Converters" @@ -332,7 +333,7 @@ - + - + @@ -427,7 +428,7 @@ VerticalAlignment="Center" FontSize="16" Style="{StaticResource SubtitleTextBlockStyle}" - Text="{x:Bind ((helpers:IGroupedCollectionHeader)Group).Model.Text, Mode=OneWay}" /> + Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.Text, Mode=OneWay}" /> + Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.CountText, Mode=OneWay}" + Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource NegatedBoolToVisibilityConverter}}" /> + Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.Subtext, Mode=OneWay}" + Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" /> + Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.CountText, Mode=OneWay}" + Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" /> diff --git a/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml b/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml index 123f3918ef58..8dd3576bf016 100644 --- a/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml +++ b/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml @@ -13,6 +13,7 @@ xmlns:icore="using:Microsoft.Xaml.Interactions.Core" xmlns:local="using:Files.App.Views.LayoutModes" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:storage="using:Files.App.Utils.Storage" xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls" xmlns:uc="using:Files.App.UserControls" xmlns:wct="using:CommunityToolkit.WinUI.UI" @@ -1366,7 +1367,7 @@ - + - + + Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.Text, Mode=OneWay}" /> + Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.CountText, Mode=OneWay}" + Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource NegatedBoolToVisibilityConverter}}" /> + Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.Subtext, Mode=OneWay}" + Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" /> + Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.CountText, Mode=OneWay}" + Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" /> diff --git a/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml b/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml index 73c84e2154f5..7c913af3ecc1 100644 --- a/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml +++ b/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml @@ -12,6 +12,7 @@ xmlns:icore="using:Microsoft.Xaml.Interactions.Core" xmlns:local="using:Files.App.Views.LayoutModes" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:storage="using:Files.App.Utils.Storage" xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls" xmlns:tui="using:CommunityToolkit.WinUI.UI" xmlns:uc="using:Files.App.UserControls" @@ -588,7 +589,7 @@ - + @@ -702,7 +703,7 @@ Height="24" HorizontalAlignment="Center" VerticalAlignment="Center" - Source="{x:Bind ((helpers:IGroupedCollectionHeader)Group).Model.ImageSource, Mode=OneWay}" + Source="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ImageSource, Mode=OneWay}" Stretch="Uniform" /> + Glyph="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.Icon, Mode=OneWay}" /> + Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.Text, Mode=OneWay}" /> + Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.CountText, Mode=OneWay}" + Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource NegatedBoolToVisibilityConverter}}" /> + Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.Subtext, Mode=OneWay}" + Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" /> + Text="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.CountText, Mode=OneWay}" + Visibility="{x:Bind ((storage:IGroupedCollectionHeader)Group).Model.ShowCountTextBelow, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" /> diff --git a/src/Files.App/Views/Properties/SecurityAdvancedPage.xaml b/src/Files.App/Views/Properties/SecurityAdvancedPage.xaml index 63925c420348..7333b9ce76ab 100644 --- a/src/Files.App/Views/Properties/SecurityAdvancedPage.xaml +++ b/src/Files.App/Views/Properties/SecurityAdvancedPage.xaml @@ -8,7 +8,7 @@ xmlns:helpers="using:Files.App.Helpers" xmlns:i="using:Microsoft.Xaml.Interactivity" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:security="using:Files.App.Utils.Security" + xmlns:security="using:Files.App.Utils.Storage" xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls" xmlns:uc="using:Files.App.UserControls" xmlns:vm="using:Files.App.ViewModels.Properties" diff --git a/src/Files.App/Views/Properties/SecurityPage.xaml b/src/Files.App/Views/Properties/SecurityPage.xaml index 26b0e8074b18..f48efc9e1562 100644 --- a/src/Files.App/Views/Properties/SecurityPage.xaml +++ b/src/Files.App/Views/Properties/SecurityPage.xaml @@ -6,7 +6,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:helpers="using:Files.App.Helpers" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:security="using:Files.App.Utils.Security" + xmlns:security="using:Files.App.Utils.Storage" xmlns:vm="using:Files.App.ViewModels.Properties" xmlns:wctconverters="using:CommunityToolkit.WinUI.UI.Converters" DataContext="{x:Bind SecurityViewModel, Mode=OneWay}" diff --git a/src/Files.App/Views/Shells/BaseShellPage.cs b/src/Files.App/Views/Shells/BaseShellPage.cs index 70867d9fc6c4..f603b4409a57 100644 --- a/src/Files.App/Views/Shells/BaseShellPage.cs +++ b/src/Files.App/Views/Shells/BaseShellPage.cs @@ -1,9 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Data.Commands; -using Files.App.Utils.FilesystemHistory; -using Files.App.Utils.Search; using Files.App.UserControls.MultitaskingControl; using Files.Core.Services; using Microsoft.UI.Input; diff --git a/src/Files.App/Views/Shells/IShellPage.cs b/src/Files.App/Views/Shells/IShellPage.cs index 58fda4445e74..2cb6f695aece 100644 --- a/src/Files.App/Views/Shells/IShellPage.cs +++ b/src/Files.App/Views/Shells/IShellPage.cs @@ -1,7 +1,6 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.FilesystemHistory; using Files.App.UserControls.MultitaskingControl; namespace Files.App.Views.Shells diff --git a/src/Files.Core.Storage/Files.Core.Storage.csproj b/src/Files.Core.Storage/Files.Core.Storage.csproj index 224fd2108c99..2f251f813488 100644 --- a/src/Files.Core.Storage/Files.Core.Storage.csproj +++ b/src/Files.Core.Storage/Files.Core.Storage.csproj @@ -10,9 +10,4 @@ win10-x86;win10-x64;win10-arm64 - - - - - diff --git a/src/Files.Sdk.Storage/DirectStorage/IDirectCopy.cs b/src/Files.Sdk.Storage/DirectStorage/IDirectCopy.cs deleted file mode 100644 index ba86c6f34764..000000000000 --- a/src/Files.Sdk.Storage/DirectStorage/IDirectCopy.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Files.Sdk.Storage.ModifiableStorage; -using Files.Sdk.Storage.NestedStorage; -using System.Threading; -using System.Threading.Tasks; - -namespace Files.Sdk.Storage.DirectStorage -{ - /// - /// Provides direct copy operation of storage objects. - /// - public interface IDirectCopy : IModifiableFolder - { - /// - /// Creates a copy of the provided storable item in this folder. - /// - Task CreateCopyOfAsync(INestedStorable itemToCopy, bool overwrite = default, CancellationToken cancellationToken = default); - } -} diff --git a/src/Files.Sdk.Storage/DirectStorage/IDirectMove.cs b/src/Files.Sdk.Storage/DirectStorage/IDirectMove.cs deleted file mode 100644 index 7a21edcc9b30..000000000000 --- a/src/Files.Sdk.Storage/DirectStorage/IDirectMove.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Files.Sdk.Storage.ModifiableStorage; -using Files.Sdk.Storage.NestedStorage; -using System.Threading; -using System.Threading.Tasks; - -namespace Files.Sdk.Storage.DirectStorage -{ - /// - /// Provides direct move operation of storage objects. - /// - public interface IDirectMove : IModifiableFolder - { - /// - /// Moves a storable item out of the provided folder, and into this folder. Returns the new item that resides in this folder. - /// - Task MoveFromAsync(INestedStorable itemToMove, IModifiableFolder source, bool overwrite = default, CancellationToken cancellationToken = default); - } -} diff --git a/src/Files.Sdk.Storage/NestedStorage/INestedFile.cs b/src/Files.Sdk.Storage/NestedStorage/INestedFile.cs deleted file mode 100644 index b1a262ffcdb4..000000000000 --- a/src/Files.Sdk.Storage/NestedStorage/INestedFile.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Files.Sdk.Storage.NestedStorage -{ - /// - /// Represents a file that resides within a traversable folder structure. - /// - public interface INestedFile : IFile, INestedStorable - { - } -} diff --git a/src/Files.Sdk.Storage/NestedStorage/INestedFolder.cs b/src/Files.Sdk.Storage/NestedStorage/INestedFolder.cs deleted file mode 100644 index d73c723adb37..000000000000 --- a/src/Files.Sdk.Storage/NestedStorage/INestedFolder.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Files.Sdk.Storage.NestedStorage -{ - /// - /// Represents a folder that resides within a traversable folder structure. - /// - public interface INestedFolder : IFolder, INestedStorable - { - } -} diff --git a/src/Files.Sdk.Storage/NestedStorage/INestedStorable.cs b/src/Files.Sdk.Storage/NestedStorage/INestedStorable.cs deleted file mode 100644 index 3463db7d4bd6..000000000000 --- a/src/Files.Sdk.Storage/NestedStorage/INestedStorable.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -namespace Files.Sdk.Storage.NestedStorage -{ - /// - /// Represents a storable resource that resides within a traversable folder structure. - /// - public interface INestedStorable : IStorable - { - /// - /// Gets the containing folder for this item, if any. - /// - Task GetParentAsync(CancellationToken cancellationToken = default); - } -}