├── .nuke
├── src
├── key.snk
├── Files
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── PathKind.cs
│ ├── DeletionOption.cs
│ ├── NameCollisionOption.cs
│ ├── Files.csproj
│ ├── IFileSystemElement.cs
│ ├── CreationCollisionOption.cs
│ ├── StorageFolderProperties.cs
│ ├── StorageFileProperties.cs
│ ├── Diagram.cd
│ ├── KnownFolder.cs
│ └── StorageElementProperties.cs
├── global.json
├── Files.Tests
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Mocks
│ │ ├── StorageFileMocks.cs
│ │ ├── StorageFolderMocks.cs
│ │ ├── StoragePathMocks.cs
│ │ └── FileSystemMocks.cs
│ ├── Files.Tests.csproj
│ ├── StorageFileTests.cs
│ ├── StorageFolderTests.cs
│ └── PathInformationTests.cs
├── Files.FileSystems.InMemory
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Files.FileSystems.InMemory.csproj
│ ├── FsTree
│ │ ├── FileNode.cs
│ │ ├── FileContent.cs
│ │ ├── FolderNode.cs
│ │ ├── FileContentReadWriteTracker.cs
│ │ ├── ElementNode.cs
│ │ └── FsDataStorage.cs
│ ├── DefaultKnownFolderProvider.cs
│ ├── IKnownFolderProvider.cs
│ ├── IInMemoryStoragePathProvider.cs
│ ├── InMemoryFileSystemOptions.cs
│ └── InMemoryFileSystem.cs
├── Files.FileSystems.Physical
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Utilities
│ │ ├── ConversionExtensions.cs
│ │ ├── FsHelper.cs
│ │ └── FilePolyfills.cs
│ ├── Files.FileSystems.Physical.csproj
│ └── PhysicalFileSystem.cs
├── Files.Specification.Tests
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── FileSystemTestContext.cs
│ ├── PathProvider.cs
│ ├── Assertions
│ │ ├── StorageElementAssertions.cs
│ │ ├── StorageFileAssertions.cs
│ │ └── StoragePathAssertions.cs
│ ├── Stubs
│ │ ├── StoragePathStub.cs
│ │ └── FileSystemStub.cs
│ ├── Files.Specification.Tests.csproj
│ ├── Attributes
│ │ └── DynamicInstanceDataAttribute.cs
│ ├── Setup
│ │ └── Default.cs
│ └── FileSystemTestBase.cs
├── Files.FileSystems.InMemory.Tests
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Files.FileSystems.InMemory.Tests.csproj
│ ├── DefaultInMemoryStoragePathTests.cs
│ ├── InMemoryFileSystemTests.cs
│ ├── InMemoryFileSystemTestContext.cs
│ ├── InMemoryStorageFolderTests.cs
│ └── InMemoryStorageFileTests.cs
├── Files.FileSystems.Physical.Tests
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── PhysicalStorageFileTests.cs
│ ├── PhysicalStorageFolderTests.cs
│ ├── PhysicalFileSystemTestContext.cs
│ ├── Files.FileSystems.Physical.Tests.csproj
│ ├── PhysicalStoragePathTests.cs
│ └── PhysicalFileSystemTests.cs
├── Files.FileSystems.WindowsStorage
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Utilities
│ │ ├── WinStorageItemExtensions.cs
│ │ ├── AsyncExtensions.cs
│ │ ├── ConversionExtensions.cs
│ │ ├── ExceptionConverter.cs
│ │ └── FsHelper.cs
│ ├── Files.FileSystems.WindowsStorage.csproj
│ └── WindowsStorageFileSystem.cs
├── Files.FileSystems.WindowsStorage.Tests
│ ├── Assets
│ │ ├── StoreLogo.png
│ │ ├── SplashScreen.scale-200.png
│ │ ├── LockScreenLogo.scale-200.png
│ │ ├── Square44x44Logo.scale-200.png
│ │ ├── Wide310x150Logo.scale-200.png
│ │ ├── Square150x150Logo.scale-200.png
│ │ └── Square44x44Logo.targetsize-24_altform-unplated.png
│ ├── UnitTestApp.xaml
│ ├── WindowsStorageStorageFileTests.cs
│ ├── WindowsStorageStorageFolderTests.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ └── Default.rd.xml
│ ├── WindowsStorageFileSystemTestContext.cs
│ ├── UnitTestApp.xaml.cs
│ ├── PhysicalStoragePathTests.cs
│ ├── Package.appxmanifest
│ ├── Files.FileSystems.WindowsStorage.Tests.GeneratedMSBuildEditorConfig.editorconfig
│ └── WindowsStorageFileSystemTests.cs
├── nuget.config
├── Files.Shared
│ ├── StringExtensions.cs
│ ├── Files.Shared.projitems
│ ├── Files.Shared.shproj
│ └── EnumInfo.cs
├── Default.ruleset
├── Files.Shared.PhysicalStoragePath
│ ├── Files.Shared.PhysicalStoragePath.projitems
│ ├── Files.Shared.PhysicalStoragePath.shproj
│ ├── Utilities
│ │ ├── Platform.cs
│ │ ├── PhysicalPathHelper.cs
│ │ └── PhysicalPathHelper.CaseSensitivity.cs
│ └── PhysicalStoragePath.cs
├── Tests.ruleset
└── Directory.Build.props
├── assets
├── Icon.design
├── Icon128x128.png
├── Icon256x256.png
└── Icon64x64.png
├── doc
└── assets
│ └── core-api-overview-class-diagram.png
├── .github
├── ISSUE_TEMPLATE
│ ├── question.md
│ ├── documentation_issue.md
│ ├── feature_request.md
│ └── bug_report.md
├── dependabot.yml
└── pull_request_template.md
├── .gitignore
├── LICENSE
├── CHANGELOG.md
└── azure-pipelines.yml
/.nuke:
--------------------------------------------------------------------------------
1 | src/Files.sln
2 |
--------------------------------------------------------------------------------
/src/key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/src/key.snk
--------------------------------------------------------------------------------
/assets/Icon.design:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/assets/Icon.design
--------------------------------------------------------------------------------
/assets/Icon128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/assets/Icon128x128.png
--------------------------------------------------------------------------------
/assets/Icon256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/assets/Icon256x256.png
--------------------------------------------------------------------------------
/assets/Icon64x64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/assets/Icon64x64.png
--------------------------------------------------------------------------------
/src/Files/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | [assembly: CLSCompliant(false)]
4 |
--------------------------------------------------------------------------------
/src/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "msbuild-sdks": {
3 | "MSBuild.Sdk.Extras": "2.1.2"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/src/Files.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | [assembly: CLSCompliant(false)]
4 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.InMemory/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | [assembly: CLSCompliant(false)]
4 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.Physical/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | [assembly: CLSCompliant(false)]
4 |
--------------------------------------------------------------------------------
/src/Files.Specification.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | [assembly: CLSCompliant(false)]
4 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.InMemory.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | [assembly: CLSCompliant(false)]
4 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.Physical.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | [assembly: CLSCompliant(false)]
4 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | [assembly: CLSCompliant(false)]
4 |
--------------------------------------------------------------------------------
/doc/assets/core-api-overview-class-diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/doc/assets/core-api-overview-class-diagram.png
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/Assets/StoreLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/src/Files.FileSystems.WindowsStorage.Tests/Assets/StoreLogo.png
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/Assets/SplashScreen.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/src/Files.FileSystems.WindowsStorage.Tests/Assets/SplashScreen.scale-200.png
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/Assets/LockScreenLogo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/src/Files.FileSystems.WindowsStorage.Tests/Assets/LockScreenLogo.scale-200.png
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/Assets/Square44x44Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/src/Files.FileSystems.WindowsStorage.Tests/Assets/Square44x44Logo.scale-200.png
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/Assets/Wide310x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/src/Files.FileSystems.WindowsStorage.Tests/Assets/Wide310x150Logo.scale-200.png
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/Assets/Square150x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/src/Files.FileSystems.WindowsStorage.Tests/Assets/Square150x150Logo.scale-200.png
--------------------------------------------------------------------------------
/src/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manuelroemer/Files/HEAD/src/Files.FileSystems.WindowsStorage.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Question
3 | about: Ask any kind of question.
4 | title: ''
5 | labels: question
6 | assignees: ''
7 | ---
8 |
9 | # Question
10 | ## Your Question
11 |
12 |
13 | TODO.
14 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/UnitTestApp.xaml:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/Files.Specification.Tests/FileSystemTestContext.cs:
--------------------------------------------------------------------------------
1 | namespace Files.Specification.Tests
2 | {
3 | using System.Threading.Tasks;
4 |
5 | public abstract class FileSystemTestContext
6 | {
7 | public abstract FileSystem FileSystem { get; }
8 |
9 | public abstract Task GetTestFolderAsync();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Files.Specification.Tests/PathProvider.cs:
--------------------------------------------------------------------------------
1 | namespace Files.Specification.Tests
2 | {
3 | ///
4 | /// Creates a new path which is built on the given base path.
5 | ///
6 | ///
7 | /// Another path which should be used as the parent path of the new path which will be returned.
8 | ///
9 | public delegate StoragePath PathProvider(StoragePath basePath);
10 | }
11 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.Physical.Tests/PhysicalStorageFileTests.cs:
--------------------------------------------------------------------------------
1 | namespace Files.FileSystems.Physical.Tests
2 | {
3 | using Files.Specification.Tests;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | [TestClass]
7 | public sealed class PhysicalStorageFileTests : StorageFileSpecificationTests
8 | {
9 | public PhysicalStorageFileTests()
10 | : base(PhysicalFileSystemTestContext.Instance) { }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Files.Shared/StringExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace Files.Shared
2 | {
3 | internal static class StringExtensions
4 | {
5 | internal static string? ToNullIfEmpty(this string str)
6 | {
7 | return string.IsNullOrEmpty(str) ? null : str;
8 | }
9 |
10 | internal static bool Contains(this string str, char[] characters)
11 | {
12 | return str.IndexOfAny(characters) >= 0;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.Physical.Tests/PhysicalStorageFolderTests.cs:
--------------------------------------------------------------------------------
1 | namespace Files.FileSystems.Physical.Tests
2 | {
3 | using Files.Specification.Tests;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | [TestClass]
7 | public sealed class PhysicalStorageFolderTests : StorageFolderSpecificationTests
8 | {
9 | public PhysicalStorageFolderTests()
10 | : base(PhysicalFileSystemTestContext.Instance) { }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Files/PathKind.cs:
--------------------------------------------------------------------------------
1 | namespace Files
2 | {
3 | ///
4 | /// Defines whether a path is relative or absolute.
5 | ///
6 | public enum PathKind
7 | {
8 | ///
9 | /// The path is an absolute path.
10 | ///
11 | Absolute,
12 |
13 | ///
14 | /// The path is a relative path.
15 | ///
16 | Relative,
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/documentation_issue.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Documentation Issue
3 | about: A suggestion regarding the documentation, both problems and suggestions.
4 | title: ''
5 | labels: documentation
6 | assignees: ''
7 | ---
8 |
9 | # Documentation Issue
10 | ## Description
11 |
12 |
13 | TODO.
14 |
15 |
16 | ## Discussion
17 |
18 |
19 | *None.*
20 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature Request
3 | about: Suggest an idea for this project.
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 | ---
8 |
9 | # New Feature Proposal
10 | ## Description
11 |
12 |
13 | TODO.
14 |
15 |
16 | ## Discussion
17 |
18 |
19 | *None.*
20 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/WindowsStorageStorageFileTests.cs:
--------------------------------------------------------------------------------
1 | namespace Files.FileSystems.WindowsStorage.Tests
2 | {
3 | using Files.Specification.Tests;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | [TestClass]
7 | public sealed class WindowsStorageStorageFileTests : StorageFileSpecificationTests
8 | {
9 | public WindowsStorageStorageFileTests()
10 | : base(WindowsStorageFileSystemTestContext.Instance) { }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/WindowsStorageStorageFolderTests.cs:
--------------------------------------------------------------------------------
1 | namespace Files.FileSystems.WindowsStorage.Tests
2 | {
3 | using Files.Specification.Tests;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | [TestClass]
7 | public sealed class WindowsStorageStorageFolderTests : StorageFolderSpecificationTests
8 | {
9 | public WindowsStorageStorageFolderTests()
10 | : base(WindowsStorageFileSystemTestContext.Instance) { }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: nuget
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 | open-pull-requests-limit: 10
8 | ignore:
9 | - dependency-name: Microsoft.NET.Test.Sdk
10 | versions:
11 | - "> 16.5.0"
12 | - dependency-name: Nuke.Common
13 | versions:
14 | - 5.1.0
15 | - dependency-name: MSTest.TestFramework
16 | versions:
17 | - 2.2.1
18 | - 2.2.2
19 | - dependency-name: MSTest.TestAdapter
20 | versions:
21 | - 2.2.1
22 | - 2.2.2
23 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage/Utilities/WinStorageItemExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace Files.FileSystems.WindowsStorage.Utilities
2 | {
3 | using System.IO;
4 | using Files.Shared;
5 | using Windows.Storage;
6 |
7 | internal static class WinStorageItemExtensions
8 | {
9 | internal static string GetPathOrThrow(this IStorageItem storageItem)
10 | {
11 | return storageItem.Path ?? throw new IOException(
12 | ExceptionStrings.WindowsStorageCompatibility.WindowsStorageElementHasNoPath()
13 | );
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Files.Tests/Mocks/StorageFileMocks.cs:
--------------------------------------------------------------------------------
1 | namespace Files.Tests.Mocks
2 | {
3 | using Moq;
4 | using static Files.Tests.Mocks.FileSystemMocks;
5 | using static Files.Tests.Mocks.StoragePathMocks;
6 |
7 | public static class StorageFileMocks
8 | {
9 | public static Mock CreateOrdinalFileMock() =>
10 | Create(CreateOrdinalFsMock().Object, CreateOrdinalPathMock().Object);
11 |
12 | public static Mock Create(FileSystem fileSystem, StoragePath path)
13 | {
14 | return new Mock(fileSystem, path) { CallBase = true };
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Files.Tests/Mocks/StorageFolderMocks.cs:
--------------------------------------------------------------------------------
1 | namespace Files.Tests.Mocks
2 | {
3 | using Moq;
4 | using static Files.Tests.Mocks.FileSystemMocks;
5 | using static Files.Tests.Mocks.StoragePathMocks;
6 |
7 | public static class StorageFolderMocks
8 | {
9 | public static Mock CreateOrdinalFolderMock() =>
10 | Create(CreateOrdinalFsMock().Object, CreateOrdinalPathMock().Object);
11 |
12 | public static Mock Create(FileSystem fileSystem, StoragePath path)
13 | {
14 | return new Mock(fileSystem, path) { CallBase = true };
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | # New Pull Request
2 | ## Prerequisites
3 |
4 |
5 | - [ ] All new/updated public APIs are documented via XML comments.
6 | - [ ] `CHANGELOG.md` has been updated.
7 |
8 |
9 | ## Change Type
10 |
11 | - [ ] New Feature(s)
12 | - [ ] Bug Fix(es)
13 | - [ ] Documentation Update(s)
14 |
15 |
16 | ## Description
17 |
18 |
19 | TODO.
20 |
21 |
22 | ## Discussion
23 |
24 |
25 | *None.*
26 |
--------------------------------------------------------------------------------
/src/Files.Tests/Files.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net5.0
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Files/DeletionOption.cs:
--------------------------------------------------------------------------------
1 | namespace Files
2 | {
3 | ///
4 | /// Defines different ways to react to a missing element during a deletion attempt.
5 | ///
6 | public enum DeletionOption
7 | {
8 | ///
9 | /// If the element does not exist (for example because it has already been deleted)
10 | /// the operation should throw an exception.
11 | ///
12 | Fail,
13 |
14 | ///
15 | /// If the element or one of its parent folders does not exist (for example because
16 | /// it has already been deleted) the operation should not fail, but exit without any errors.
17 | ///
18 | IgnoreMissing,
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Files.Shared/Files.Shared.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | f03ebc81-80be-4b62-90a4-9368a4624d9f
7 |
8 |
9 | Files.Shared
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Files.Specification.Tests/Assertions/StorageElementAssertions.cs:
--------------------------------------------------------------------------------
1 | namespace Files.Specification.Tests.Assertions
2 | {
3 | using System.Threading.Tasks;
4 | using Shouldly;
5 |
6 | public static class StorageElementAssertions
7 | {
8 | public static async Task ShouldExistAsync(this StorageElement element)
9 | {
10 | var exists = await element.ExistsAsync();
11 | exists.ShouldBeTrue($"The element at {element.Path} should exist, but doesn't.");
12 | }
13 |
14 | public static async Task ShouldNotExistAsync(this StorageElement element)
15 | {
16 | var exists = await element.ExistsAsync();
17 | exists.ShouldBeFalse($"The element at {element.Path} should not exist, but does.");
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("Files.FileSystems.WindowsStorage.Tests")]
6 | [assembly: AssemblyDescription("")]
7 | [assembly: AssemblyConfiguration("")]
8 | [assembly: AssemblyCompany("")]
9 | [assembly: AssemblyProduct("Files.FileSystems.WindowsStorage.Tests")]
10 | [assembly: AssemblyCopyright("Copyright © 2020")]
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: AssemblyMetadata("TargetPlatform", "UAP")]
14 |
15 | // [assembly: AssemblyVersion("1.0.*")]
16 | [assembly: AssemblyVersion("1.0.0.0")]
17 | [assembly: AssemblyFileVersion("1.0.0.0")]
18 | [assembly: ComVisible(false)]
19 | [assembly: CLSCompliant(false)]
20 |
--------------------------------------------------------------------------------
/src/Default.ruleset:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage/Utilities/AsyncExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace Files.FileSystems.WindowsStorage.Utilities
2 | {
3 | using System;
4 | using System.Runtime.CompilerServices;
5 | using System.Threading;
6 | using Windows.Foundation;
7 |
8 | internal static class AsyncExtensions
9 | {
10 | internal static ConfiguredTaskAwaitable AsAwaitable(
11 | this IAsyncAction asyncAction,
12 | CancellationToken cancellationToken
13 | )
14 | {
15 | return asyncAction.AsTask(cancellationToken).ConfigureAwait(false);
16 | }
17 |
18 | internal static ConfiguredTaskAwaitable AsAwaitable(
19 | this IAsyncOperation asyncOperation,
20 | CancellationToken cancellationToken
21 | )
22 | {
23 | return asyncOperation.AsTask(cancellationToken).ConfigureAwait(false);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.InMemory.Tests/Files.FileSystems.InMemory.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net5.0
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Files/NameCollisionOption.cs:
--------------------------------------------------------------------------------
1 | namespace Files
2 | {
3 | ///
4 | /// Defines different ways to react to name collisions during file and folder operations.
5 | ///
6 | public enum NameCollisionOption
7 | {
8 | ///
9 | /// The method should throw an exception if a file or folder already exists at the destination.
10 | ///
11 | Fail = CreationCollisionOption.Fail,
12 |
13 | ///
14 | /// Any existing file or folder at the destination should be replaced.
15 | ///
16 | /// Specifying this flag only replaces elements of the same type.
17 | /// If a folder already exists in the location where a file is supposed to be copied or moved,
18 | /// the operation will fail (and vice versa).
19 | ///
20 | ReplaceExisting = CreationCollisionOption.ReplaceExisting,
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # MacOS
2 | .DS_Store
3 | .AppleDouble
4 | .LSOverride
5 |
6 | # Visual Studio
7 | .vs/
8 | Generated\ Files/
9 | [Tt]est[Rr]esult*/
10 | [Bb]uild[Ll]og.*
11 |
12 | # Visual Studio Code
13 | .vscode/*
14 | !.vscode/settings.json
15 | !.vscode/tasks.json
16 | !.vscode/launch.json
17 | !.vscode/extensions.json
18 |
19 | # JetBrains Rider and ReSharper
20 | .idea/
21 | *.sln.iml
22 | *.DotSettings.user
23 | _ReSharper*/
24 | *.[Rr]e[Ss]harper
25 |
26 | # .NET Core
27 | project.lock.json
28 | project.fragment.lock.json
29 | artifacts/
30 |
31 | # NuGet
32 | *.nupkg
33 | **/[Pp]ackages/*
34 | !**/[Pp]ackages/build/
35 | *.nuget.props
36 | *.nuget.targets
37 |
38 | # User-specific files
39 | *.rsuser
40 | *.suo
41 | *.user
42 | *.userosscache
43 | *.sln.docstates
44 | *.userprefs
45 |
46 | # Build results
47 | [Dd]ebug/
48 | [Dd]ebugPublic/
49 | [Rr]elease/
50 | [Rr]eleases/
51 | x64/
52 | x86/
53 | [Aa][Rr][Mm]/
54 | [Aa][Rr][Mm]64/
55 | bld/
56 | [Bb]in/
57 | [Oo]bj/
58 | [Ll]og/
59 | AppPackages
60 | BundleArtifacts
61 |
62 | # Temporary
63 | .tmp
64 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.Physical/Utilities/ConversionExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace Files.FileSystems.Physical.Utilities
2 | {
3 | using System;
4 | using System.IO;
5 | using Files.Shared;
6 |
7 | internal static class ConversionExtensions
8 | {
9 | public static bool ToOverwriteBool(this NameCollisionOption options) => options switch
10 | {
11 | NameCollisionOption.Fail => false,
12 | NameCollisionOption.ReplaceExisting => true,
13 | _ => throw new NotSupportedException(ExceptionStrings.Enum.UnsupportedValue(options)),
14 | };
15 |
16 | public static FileMode ToFileMode(this CreationCollisionOption options) => options switch
17 | {
18 | CreationCollisionOption.Fail => FileMode.CreateNew,
19 | CreationCollisionOption.ReplaceExisting => FileMode.Create,
20 | CreationCollisionOption.UseExisting => FileMode.OpenOrCreate,
21 | _ => throw new NotSupportedException(ExceptionStrings.Enum.UnsupportedValue(options)),
22 | };
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Files.Shared.PhysicalStoragePath/Files.Shared.PhysicalStoragePath.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | fd470c52-aebe-4967-8252-ebc1b586d6b2
7 |
8 |
9 | Files.Shared.PhysicalStoragePath
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Files/Files.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0;netstandard2.1;net5.0
4 |
5 | A modern, immutable, async-first abstraction of hierarchical file systems with a consistent and developer friendly API that allows seamless switching between multiple underlying file system manifestations, while also fixing and hiding the flaws and inconsistencies of the wrapped APIs.
6 |
7 | This package provides the Core API of the Files libraries which defines the API contract and abstractions. In addition, it provides several extensions and conveniences which simplify working with the Core API.
8 | You should use the abstractions provided by this package for your implementations. Nontheless, you must also install a package which provides a concrete implementation of these file system abstractions.
9 |
10 | Learn more about Files at https://github.com/manuelroemer/Files.
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Files.Shared/Files.Shared.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | f03ebc81-80be-4b62-90a4-9368a4624d9f
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Manuel Römer
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.InMemory/Files.FileSystems.InMemory.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0;netstandard2.1;net5.0
4 |
5 | A modern, immutable, async-first abstraction of hierarchical file systems with a consistent and developer friendly API that allows seamless switching between multiple underlying file system manifestations, while also fixing and hiding the flaws and inconsistencies of the wrapped APIs.
6 |
7 | This package provides an in-memory FileSystem implementation which is specifically designed for testing. The InMemoryFileSystem is completely independent of any real-world file system and can thus run in any testing configuration. In addition, each InMemoryFileSystem is isolated, leading to predictable testing states.
8 |
9 | Learn more about Files at https://github.com/manuelroemer/Files.
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/WindowsStorageFileSystemTestContext.cs:
--------------------------------------------------------------------------------
1 | namespace Files.FileSystems.WindowsStorage.Tests
2 | {
3 | using System.Threading.Tasks;
4 | using Files.Specification.Tests;
5 | using Files.Specification.Tests.Setup;
6 |
7 | public sealed class WindowsStorageFileSystemTestContext : FileSystemTestContext
8 | {
9 | public static WindowsStorageFileSystemTestContext Instance { get; } =
10 | new WindowsStorageFileSystemTestContext();
11 |
12 | public override FileSystem FileSystem { get; } = new WindowsStorageFileSystem();
13 |
14 | private WindowsStorageFileSystemTestContext()
15 | {
16 | Default.Setup(FileSystem);
17 | }
18 |
19 | public override async Task GetTestFolderAsync()
20 | {
21 | var folder = FileSystem
22 | .GetFolder(KnownFolder.TemporaryData)
23 | .GetFolder("TestFolder");
24 | await folder.CreateAsync(recursive: true, CreationCollisionOption.ReplaceExisting).ConfigureAwait(false);
25 | return folder;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Files.Shared.PhysicalStoragePath/Files.Shared.PhysicalStoragePath.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | fd470c52-aebe-4967-8252-ebc1b586d6b2
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage.Tests/UnitTestApp.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Files.FileSystems.WindowsStorage.Tests
2 | {
3 | using System;
4 | using System.Diagnostics;
5 | using Microsoft.VisualStudio.TestPlatform.TestExecutor;
6 | using Windows.ApplicationModel.Activation;
7 | using Windows.UI.Xaml;
8 | using Windows.UI.Xaml.Controls;
9 |
10 | public sealed partial class App
11 | {
12 | public App()
13 | {
14 | InitializeComponent();
15 | }
16 |
17 | protected override void OnLaunched(LaunchActivatedEventArgs e)
18 | {
19 | if (!(Window.Current.Content is Frame rootFrame))
20 | {
21 | rootFrame = new Frame();
22 | rootFrame.NavigationFailed += (sender, e) =>
23 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
24 | Window.Current.Content = rootFrame;
25 | }
26 |
27 | DebugSettings.EnableFrameRateCounter = Debugger.IsAttached;
28 | UnitTestClient.CreateDefaultUI();
29 | Window.Current.Activate();
30 | UnitTestClient.Run(e.Arguments);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.Physical.Tests/PhysicalFileSystemTestContext.cs:
--------------------------------------------------------------------------------
1 | namespace Files.FileSystems.Physical.Tests
2 | {
3 | using System.Reflection;
4 | using System.Threading.Tasks;
5 | using Files;
6 | using Files.Specification.Tests;
7 | using Files.Specification.Tests.Setup;
8 |
9 | public sealed class PhysicalFileSystemTestContext : FileSystemTestContext
10 | {
11 | public static PhysicalFileSystemTestContext Instance { get; } = new PhysicalFileSystemTestContext();
12 |
13 | public override FileSystem FileSystem => new PhysicalFileSystem();
14 |
15 | private PhysicalFileSystemTestContext()
16 | {
17 | Default.Setup(FileSystem);
18 | }
19 |
20 | public override async Task GetTestFolderAsync()
21 | {
22 | var folder = FileSystem
23 | .GetFolder(KnownFolder.TemporaryData)
24 | .GetFolder(Assembly.GetExecutingAssembly().GetName().Name ?? "")
25 | .GetFolder("TestFolder");
26 | await folder.CreateAsync(recursive: true, CreationCollisionOption.ReplaceExisting).ConfigureAwait(false);
27 | return folder;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Files.Specification.Tests/Stubs/StoragePathStub.cs:
--------------------------------------------------------------------------------
1 | namespace Files.Specification.Tests.Stubs
2 | {
3 | using Files;
4 |
5 | ///
6 | /// A providing incredibly simplified, canned results.
7 | /// This is mainly introduced for testing foreign file system support.
8 | ///
9 | public sealed class StoragePathStub : StoragePath
10 | {
11 | // This class is mainly introduced for having a foreign file system member.
12 | // The properties/methods (apart from ToString()) should ideally never be used and do not
13 | // have to make any sense, as long as they return a valid object.
14 |
15 | public override PathKind Kind => PathKind.Absolute;
16 | public override StoragePath? Root => this;
17 | public override StoragePath? Parent => null;
18 | public override StoragePath FullPath => this;
19 | public override string Name => ToString();
20 | public override string NameWithoutExtension => ToString();
21 | public override string? Extension => "";
22 |
23 | public StoragePathStub(FileSystem fileSystem, string path)
24 | : base(fileSystem, path) { }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.WindowsStorage/Files.FileSystems.WindowsStorage.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | uap10.0.16299
4 | $(DefineConstants);UAP
5 |
6 | A modern, immutable, async-first abstraction of hierarchical file systems with a consistent and developer friendly API that allows seamless switching between multiple underlying file system manifestations, while also fixing and hiding the flaws and inconsistencies of the wrapped APIs.
7 |
8 | This package provides a FileSystem implementation which interacts with the local machine's file system via UWP's Windows.Storage APIs. This implementation is designed for applications targeting the UWP which, due to sandbox restrictions, cannot use .NET's System.IO APIs.
9 |
10 | Learn more about Files at https://github.com/manuelroemer/Files.
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.Physical.Tests/Files.FileSystems.Physical.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0;
5 | netcoreapp2.1;
6 | netcoreapp2.2;
7 | netcoreapp3.0;
8 | netcoreapp3.1;
9 | net5.0
10 |
11 |
12 | $(TargetFrameworks);
13 | net48
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/Files/IFileSystemElement.cs:
--------------------------------------------------------------------------------
1 | namespace Files
2 | {
3 | ///
4 | /// Represents an element which is associated with an arbitrary file system.
5 | /// See remarks for details.
6 | ///
7 | ///
8 | /// The interface is implemented by every member
9 | /// which can be created by the class.
10 | /// The interface gives you access to the file system with which the implementing element
11 | /// is associated. This enables you to easily create other elements of the same file system
12 | /// implementation without direct access to the instance:
13 | ///
14 | ///
15 | /// StorageFile GetFileFromPath(StoragePath path)
16 | /// {
17 | /// FileSystem fs = path.FileSystem;
18 | /// return fs.GetFile(path);
19 | /// }
20 | ///
21 | ///
22 | public interface IFileSystemElement
23 | {
24 | ///
25 | /// Gets the file system with which this element is associated.
26 | ///
27 | FileSystem FileSystem { get; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Files.FileSystems.InMemory.Tests/DefaultInMemoryStoragePathTests.cs:
--------------------------------------------------------------------------------
1 | namespace Files.FileSystems.InMemory.Tests
2 | {
3 | using System.Collections.Generic;
4 | using Files.Specification.Tests;
5 | using Files.Specification.Tests.Setup;
6 | using Microsoft.VisualStudio.TestTools.UnitTesting;
7 |
8 | [TestClass]
9 | public sealed class DefaultInMemoryStoragePathTests : StoragePathSpecificationTests
10 | {
11 | public override IEnumerable