|
2 | 2 |
|
3 | 3 | A virtual file system implementation in modern C#. |
4 | 4 |
|
5 | | -When writing applications in .NET, you often need to write or read the contents of a file. .NET provides `System.IO` |
6 | | -namespace dedicated to this purpose. But how do we deal with the filesystem when testing our code? |
7 | | - |
8 | | -"Virtual File System" is an attempt to solve this problem. Currently, this library is at an early stage of development. |
9 | | -If you need additional functionality, I invite you to open an issue to discuss it. |
10 | | - |
11 | | -## Badges |
12 | | - |
13 | | -_Social buttons_ |
14 | | - |
15 | 5 | [](https://github.com/Atypical-Consulting/VirtualFileSystem "Go to GitHub repo") |
16 | 6 | [](https://opensource.org/licenses/BSD-3-Clause) |
17 | 7 | [](https://github.com/Atypical-Consulting/VirtualFileSystem) |
18 | 8 | [](https://github.com/Atypical-Consulting/VirtualFileSystem) |
19 | 9 |
|
20 | | -_Repo metadata_ |
21 | | - |
22 | 10 | [](https://github.com/Atypical-Consulting/VirtualFileSystem/releases/) |
23 | 11 | [](https://github.com/Atypical-Consulting/VirtualFileSystem/issues) |
24 | 12 | [](https://github.com/Atypical-Consulting/VirtualFileSystem/pulls) |
25 | 13 | [](https://github.com/Atypical-Consulting/VirtualFileSystem/graphs/contributors) |
26 | 14 | [](https://github.com/Atypical-Consulting/VirtualFileSystem/commits/master) |
27 | 15 |
|
28 | | -_Call-to-Action buttons_ |
| 16 | +[](https://www.nuget.org/packages/Atypical.VirtualFileSystem) |
| 17 | +[](https://www.nuget.org/packages/Atypical.VirtualFileSystem) |
| 18 | + |
| 19 | +## Table of contents |
| 20 | + |
| 21 | +<!-- TOC --> |
| 22 | +* [Virtual File System](#virtual-file-system) |
| 23 | + * [Table of contents](#table-of-contents) |
| 24 | + * [Introduction](#introduction) |
| 25 | + * [What is a virtual file system and why should I use it?](#what-is-a-virtual-file-system-and-why-should-i-use-it) |
| 26 | + * [Features](#features) |
| 27 | + * [We use the lastest C# features](#we-use-the-lastest-c-features) |
| 28 | + * [Installation](#installation) |
| 29 | + * [NuGet](#nuget) |
| 30 | + * [Source](#source) |
| 31 | + * [Usage](#usage) |
| 32 | + * [Creating a virtual file system, add some files and print the content of the root directory as an ASCII tree](#creating-a-virtual-file-system-add-some-files-and-print-the-content-of-the-root-directory-as-an-ascii-tree) |
| 33 | + * [Documentation](#documentation) |
| 34 | + * [Contributing](#contributing) |
| 35 | + * [License](#license) |
| 36 | + * [Contact](#contact) |
| 37 | + * [Acknowledgements](#acknowledgements) |
| 38 | + * [Changelog](#changelog) |
| 39 | + * [Contributors](#contributors) |
| 40 | +<!-- TOC --> |
| 41 | + |
| 42 | +## Introduction |
29 | 43 |
|
30 | | -[](https://atypical-consulting.github.io/VirtualFileSystem/) |
31 | | -[](/docs/ "Go to project documentation") |
| 44 | +When writing applications in .NET, you often need to write or read the contents of a file. .NET provides `System.IO` |
| 45 | +namespace dedicated to this purpose. But how do we deal with the filesystem when testing our code? |
32 | 46 |
|
33 | | -## What is a virtual file system and why should I use it? |
| 47 | +**Virtual File System** is an attempt to solve this problem. Currently, this library is at an early stage of |
| 48 | +development. If you need additional functionality, I invite you to open an issue to discuss it. |
| 49 | + |
| 50 | +### What is a virtual file system and why should I use it? |
34 | 51 |
|
35 | 52 | A virtual file system is a data structure that represents a file system in memory. It is used to simulate a file system |
36 | 53 | on a computer. It is useful for testing purposes, for example, when you want to test a file system without actually |
37 | 54 | creating files on the hard drive. |
38 | 55 |
|
39 | | -## We use the lastest C# features |
| 56 | +## Features |
| 57 | + |
| 58 | +- [x] Create a virtual file system |
| 59 | +- [x] Create a virtual file or directory |
| 60 | +- [ ] ... |
| 61 | + |
| 62 | +### We use the lastest C# features |
40 | 63 |
|
41 | 64 | This library targets .NET 7.0 and uses the latest C# features. It is written in C# 11.0 and uses the new `init` |
42 | 65 | properties, `record` types, `switch` expressions, `using` declarations, and more. |
43 | 66 |
|
44 | 67 | I invite you to read the [C# 11.0 documentation](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-11) to |
45 | 68 | learn more about these features. |
46 | 69 |
|
| 70 | +## Installation |
| 71 | + |
| 72 | +### NuGet |
| 73 | + |
| 74 | +VirtualFileSystem is available on [NuGet](https://www.nuget.org/packages/VirtualFileSystem/). |
| 75 | + |
| 76 | +You can install it using the .NET Core CLI: |
| 77 | + |
| 78 | +```bash |
| 79 | +dotnet add package Atypical.VirtualFileSystem |
| 80 | +``` |
| 81 | + |
| 82 | +or by adding a package reference to your project file: |
| 83 | + |
| 84 | +```xml |
| 85 | +<PackageReference Include="Atypical.VirtualFileSystem" Version="0.1.1" /> |
| 86 | +``` |
| 87 | + |
| 88 | +### Source |
| 89 | + |
| 90 | +You can also clone the repository and build the project yourself. |
| 91 | + |
| 92 | +```bash |
| 93 | +git clone |
| 94 | +cd VirtualFileSystem |
| 95 | +dotnet build |
| 96 | +``` |
| 97 | + |
| 98 | +## Usage |
| 99 | + |
| 100 | +### Creating a virtual file system, add some files and print the content of the root directory as an ASCII tree |
| 101 | + |
| 102 | +```csharp |
| 103 | +IVirtualFileSystem vfs = new VFS() |
| 104 | + .CreateFile("dir1/file1.txt") |
| 105 | + .CreateFile("dir1/file2.txt") |
| 106 | + .CreateFile("dir1/file3.txt") |
| 107 | + .CreateFile("dir2/file1.txt") |
| 108 | + .CreateFile("dir2/file2.txt") |
| 109 | + .CreateFile("dir2/file3.txt") |
| 110 | + .CreateFile("dir3/file1.txt") |
| 111 | + .CreateFile("dir3/file2.txt") |
| 112 | + .CreateFile("dir3/file3.txt"); |
| 113 | + |
| 114 | +string tree = vfs.ToString(); |
| 115 | + |
| 116 | +// sample output (the order of the files is alphabetical) |
| 117 | +string expected = """ |
| 118 | + vfs:// |
| 119 | + ├── superheroes |
| 120 | + │ ├── batman.txt |
| 121 | + │ ├── superman.txt |
| 122 | + │ └── wonderwoman.txt |
| 123 | + ├── villains |
| 124 | + │ ├── joker.txt |
| 125 | + │ ├── lexluthor.txt |
| 126 | + │ └── penguin.txt |
| 127 | + └── world |
| 128 | + ├── gotham.txt |
| 129 | + ├── metropolis.txt |
| 130 | + └── themyscira.txt |
| 131 | + """; |
| 132 | +``` |
| 133 | + |
| 134 | +## Documentation |
| 135 | + |
| 136 | +The documentation is still a work in progress. |
| 137 | + |
| 138 | +One goal of **Virtual File System** is to provide a complete documentation of the library on **GitHub Pages**. For now, |
| 139 | +you can read the XML documentation generated on build. |
| 140 | + |
| 141 | +All summaries are written in English. If you want to help us translate the documentation, please open an issue to |
| 142 | +discuss it. |
| 143 | + |
| 144 | +## Contributing |
| 145 | + |
| 146 | +Contributions are welcome! Please read the [contribution guidelines](CONTRIBUTING.md) first. |
| 147 | + |
47 | 148 | ## License |
48 | 149 |
|
49 | 150 | This project is licensed under the terms of the BSD-3-Clause license. |
50 | 151 | If you use this library in your project, please consider adding a link to this repository in your project's README. |
51 | 152 |
|
52 | 153 | This project is maintained by [Atypical Consulting](https://www.atypical.consulting/). If you need help with this |
53 | 154 | project, please contact us from this repository by opening an issue. |
| 155 | + |
| 156 | +## Contact |
| 157 | + |
| 158 | +You can contact us by opening an issue on this repository. |
| 159 | + |
| 160 | +## Acknowledgements |
| 161 | + |
| 162 | +* [All Contributors](../../contributors) |
| 163 | +* [Atypical Consulting](https://www.atypical.consulting/) |
| 164 | + |
| 165 | +## Changelog |
| 166 | + |
| 167 | +Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. |
| 168 | + |
| 169 | +## Contributors |
| 170 | + |
| 171 | +[](http://contrib.rocks) |
0 commit comments