/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Utils/Storage/StorageItems/VirtualStorageFolder.cs
124 строки
7 KB
Yair
Code Quality: Replaced localized strings with constants
25 мар 2025, 06:30
25 мар 2025, 06:30
3df6c02
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Storage; using Windows.Storage.FileProperties; using Windows.Storage.Search; namespace Files.App.Utils.Storage { public sealed partial class VirtualStorageFolder : BaseStorageFolder { public override string Path { get; } public override string Name { get; } public override string DisplayName => Name; public override string DisplayType => Strings.Folder.GetLocalizedResource(); public override string FolderRelativeId => $"0\\{Name}"; public override DateTimeOffset DateCreated { get; } public override Windows.Storage.FileAttributes Attributes { get; } = Windows.Storage.FileAttributes.Directory; public override IStorageItemExtraProperties Properties => new BaseBasicStorageItemExtraProperties(this); public VirtualStorageFolder(string cFileName) { Path = ""; Name = cFileName; } public override IAsyncOperation<StorageFolder> ToStorageFolderAsync() => throw new NotSupportedException(); public override bool IsEqual(IStorageItem item) => item?.Path == Path; public override bool IsOfType(StorageItemTypes type) => type is StorageItemTypes.Folder; public override IAsyncOperation<IndexedState> GetIndexedStateAsync() => Task.FromResult(IndexedState.NotIndexed).AsAsyncOperation(); public override IAsyncOperation<BaseStorageFolder> GetParentAsync() => throw new NotSupportedException(); public override IAsyncOperation<BaseBasicProperties> GetBasicPropertiesAsync() { return Task.FromResult(new BaseBasicProperties()).AsAsyncOperation(); } public override IAsyncOperation<IStorageItem> GetItemAsync(string name) { return Task.FromResult<IStorageItem>(null).AsAsyncOperation(); } public override IAsyncOperation<IStorageItem> TryGetItemAsync(string name) { return Task.FromResult<IStorageItem>(null).AsAsyncOperation(); } public override IAsyncOperation<IReadOnlyList<IStorageItem>> GetItemsAsync() { return Task.FromResult<IReadOnlyList<IStorageItem>>(new List<IStorageItem>().AsReadOnly()) .AsAsyncOperation(); } public override IAsyncOperation<IReadOnlyList<IStorageItem>> GetItemsAsync(uint startIndex, uint maxItemsToRetrieve) => AsyncInfo.Run<IReadOnlyList<IStorageItem>>(async (cancellationToken) => (await GetItemsAsync()).Skip((int)startIndex).Take((int)maxItemsToRetrieve).ToList()); public override IAsyncOperation<BaseStorageFile> GetFileAsync(string name) => AsyncInfo.Run(async (cancellationToken) => await GetItemAsync(name) as BaseStorageFile); public override IAsyncOperation<IReadOnlyList<BaseStorageFile>> GetFilesAsync() => AsyncInfo.Run<IReadOnlyList<BaseStorageFile>>(async (cancellationToken) => (await GetItemsAsync())?.OfType<FtpStorageFile>().ToList()); public override IAsyncOperation<IReadOnlyList<BaseStorageFile>> GetFilesAsync(CommonFileQuery query) => AsyncInfo.Run(async (cancellationToken) => await GetFilesAsync()); public override IAsyncOperation<IReadOnlyList<BaseStorageFile>> GetFilesAsync(CommonFileQuery query, uint startIndex, uint maxItemsToRetrieve) => AsyncInfo.Run<IReadOnlyList<BaseStorageFile>>(async (cancellationToken) => (await GetFilesAsync()).Skip((int)startIndex).Take((int)maxItemsToRetrieve).ToList()); public override IAsyncOperation<BaseStorageFolder> GetFolderAsync(string name) => AsyncInfo.Run(async (cancellationToken) => await GetItemAsync(name) as BaseStorageFolder); public override IAsyncOperation<IReadOnlyList<BaseStorageFolder>> GetFoldersAsync() => AsyncInfo.Run<IReadOnlyList<BaseStorageFolder>>(async (cancellationToken) => (await GetItemsAsync())?.OfType<FtpStorageFolder>().ToList()); public override IAsyncOperation<IReadOnlyList<BaseStorageFolder>> GetFoldersAsync(CommonFolderQuery query) => AsyncInfo.Run(async (cancellationToken) => await GetFoldersAsync()); public override IAsyncOperation<IReadOnlyList<BaseStorageFolder>> GetFoldersAsync(CommonFolderQuery query, uint startIndex, uint maxItemsToRetrieve) => AsyncInfo.Run<IReadOnlyList<BaseStorageFolder>>(async (cancellationToken) => (await GetFoldersAsync()).Skip((int)startIndex).Take((int)maxItemsToRetrieve).ToList()); public override IAsyncOperation<BaseStorageFile> CreateFileAsync(string desiredName) => CreateFileAsync(desiredName, CreationCollisionOption.FailIfExists); public override IAsyncOperation<BaseStorageFile> CreateFileAsync(string desiredName, CreationCollisionOption options) => throw new NotSupportedException(); public override IAsyncOperation<BaseStorageFolder> CreateFolderAsync(string desiredName) => CreateFolderAsync(desiredName, CreationCollisionOption.FailIfExists); public override IAsyncOperation<BaseStorageFolder> CreateFolderAsync(string desiredName, CreationCollisionOption options) => throw new NotSupportedException(); public override IAsyncOperation<BaseStorageFolder> MoveAsync(IStorageFolder destinationFolder) => throw new NotSupportedException(); public override IAsyncOperation<BaseStorageFolder> MoveAsync(IStorageFolder destinationFolder, NameCollisionOption option) => throw new NotSupportedException(); public override IAsyncAction RenameAsync(string desiredName) => RenameAsync(desiredName, NameCollisionOption.FailIfExists); public override IAsyncAction RenameAsync(string desiredName, NameCollisionOption option) => throw new NotSupportedException(); public override IAsyncAction DeleteAsync() => throw new NotSupportedException(); public override IAsyncAction DeleteAsync(StorageDeleteOption option) => DeleteAsync(); public override bool AreQueryOptionsSupported(QueryOptions queryOptions) => false; public override bool IsCommonFileQuerySupported(CommonFileQuery query) => false; public override bool IsCommonFolderQuerySupported(CommonFolderQuery query) => false; public override StorageItemQueryResult CreateItemQuery() => throw new NotSupportedException(); public override BaseStorageItemQueryResult CreateItemQueryWithOptions(QueryOptions queryOptions) => new(this, queryOptions); public override StorageFileQueryResult CreateFileQuery() => throw new NotSupportedException(); public override StorageFileQueryResult CreateFileQuery(CommonFileQuery query) => throw new NotSupportedException(); public override BaseStorageFileQueryResult CreateFileQueryWithOptions(QueryOptions queryOptions) => new(this, queryOptions); public override StorageFolderQueryResult CreateFolderQuery() => throw new NotSupportedException(); public override StorageFolderQueryResult CreateFolderQuery(CommonFolderQuery query) => throw new NotSupportedException(); public override BaseStorageFolderQueryResult CreateFolderQueryWithOptions(QueryOptions queryOptions) => new(this, queryOptions); public override IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(ThumbnailMode mode) => Task.FromResult<StorageItemThumbnail>(null).AsAsyncOperation(); public override IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(ThumbnailMode mode, uint requestedSize) => Task.FromResult<StorageItemThumbnail>(null).AsAsyncOperation(); public override IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(ThumbnailMode mode, uint requestedSize, ThumbnailOptions options) => Task.FromResult<StorageItemThumbnail>(null).AsAsyncOperation(); } }