All Projects → bobvanderlinden → Sharpfilesystem

bobvanderlinden / Sharpfilesystem

Licence: mit
A virtual file system for .NET written in C#

Projects that are alternatives of or similar to Sharpfilesystem

Nohost
A web server in your web browser
Stars: ✭ 164 (-15.03%)
Mutual labels:  filesystem
Val
VirtualDOM abstraction layer - give yourself better integration and full control over the DOM with any virtual DOM library that uses a Hyperscript-like API such as React and Preact.
Stars: ✭ 181 (-6.22%)
Mutual labels:  virtual
Filehound
Flexible and fluent interface for searching the file system
Stars: ✭ 190 (-1.55%)
Mutual labels:  filesystem
Autojump
A cd command that learns - easily navigate directories from the command line
Stars: ✭ 13,289 (+6785.49%)
Mutual labels:  filesystem
Zinnia.unity
A collection of design patterns for solving common problems.
Stars: ✭ 177 (-8.29%)
Mutual labels:  virtual
Go Billy
The missing interface filesystem abstraction for Go
Stars: ✭ 184 (-4.66%)
Mutual labels:  filesystem
Onedriver
A native Linux filesystem for Microsoft OneDrive
Stars: ✭ 163 (-15.54%)
Mutual labels:  filesystem
Botany
command line virtual plant buddy
Stars: ✭ 192 (-0.52%)
Mutual labels:  virtual
Lfs
A thing to get information on your mounted disks
Stars: ✭ 178 (-7.77%)
Mutual labels:  filesystem
Chubaofs
ChubaoFS (abbrev. CBFS) is a cloud native distributed file system and object store.
Stars: ✭ 2,482 (+1186.01%)
Mutual labels:  filesystem
Tus Ruby Server
Ruby server for tus resumable upload protocol
Stars: ✭ 172 (-10.88%)
Mutual labels:  filesystem
Dokanx
user-mode filesystem framework for Windows
Stars: ✭ 173 (-10.36%)
Mutual labels:  filesystem
Containerfs
a cluster filesystem for containers
Stars: ✭ 264 (+36.79%)
Mutual labels:  filesystem
Sharesniffer
Network share sniffer and auto-mounter for crawling remote file systems
Stars: ✭ 168 (-12.95%)
Mutual labels:  filesystem
Phoenixfs
🔥 a versioning filesystem inspired by git
Stars: ✭ 191 (-1.04%)
Mutual labels:  filesystem
Command
A library to build command line applications using PHP
Stars: ✭ 164 (-15.03%)
Mutual labels:  filesystem
Pdf Archiver
A tool for tagging files and archiving tasks.
Stars: ✭ 182 (-5.7%)
Mutual labels:  filesystem
Aaru
Aaru Data Preservation Suite
Stars: ✭ 193 (+0%)
Mutual labels:  filesystem
Draxt
draxt.js – NodeList/jQuery-like package for File System (node.js)
Stars: ✭ 192 (-0.52%)
Mutual labels:  filesystem
Littlefs
A little fail-safe filesystem designed for microcontrollers
Stars: ✭ 2,488 (+1189.12%)
Mutual labels:  filesystem

SharpFileSystem

AppVeyor Travis license

SharpFileSystem is a Virtual File System (VFS) implementation for .NET to allow access to different filesystems in the same way for normal files and directories.

Motivation

After looking a long time for a VFS for .NET, so that I could read files and directories in archives (zip and rar) the same way as any ordinary files and directories. I couldn't find any complete solution for this problem, so I decided to implement a VFS myself. Also what I didn't like in the ordinary filesystems was the path-system. It allowed relative paths (like ..), which can often lead to security issues without explicit checking. It allows referring to directories the same way as referring to files. This often leads to strange behavior, like copying a directory (source) to another directory (destination), here it is often vague whether the destination directory should be overwritten or if it should copy the source-directory inside the destination-directory.

Goals

  • Using multiple types of filesystems (ie. zip, rar, ftp, etc) in the same way.
  • A way to combine these systems to structure multiple parts of your program resources and configurations.
  • A way to restrict or hide parts of your filesystem to parts of your program.
  • A robust way of handling paths.

Features

At the moment the following filesystems are implemented:

  • PhysicalFileSystem: gives access to the real operating system filesystem (uses System.IO of .NET/Mono).
  • MemoryFileSystem: simulates a filesystem in-memory.
  • SevenZipFileSystem: gives access to any 7-Zip supported archive.

There are also filesystems that alter the exposed structure of existing filesystems. These allow you to mix different systems together to get the desired file-structure:

  • ReadOnlyFileSystem: Only allows read-operations on the wrapped filesystem.
  • MergedFileSystem: Merges multiple filesystems into a single file-structure.
  • FileSystemMounter: A unix-like mount system, which mounts other filesystems to a specified path.
  • SubFileSystem: Allows you to create a filesystem from a directory of another filesystem and therefore restricts access to parent-directories.
  • SeamlessSevenZipFileSystem: Allows access to 7-Zip archives as if they're directories.

Implementation

At the heart of the system there is the IFileSystem interface. This describes the operations that should be provided by every filesystem:

public interface IFileSystem : IDisposable
{
	ICollection<FileSystemPath> GetEntities(FileSystemPath path);
	bool Exists(FileSystemPath path);
	Stream CreateFile(FileSystemPath path);
	Stream OpenFile(FileSystemPath path, FileAccess access);
	void CreateDirectory(FileSystemPath path);
	void Delete(FileSystemPath path);
}

Normally in .NET/Mono we refer to files by their path coded as a string. This sometimes leads to inconsistencies, which is why I've created the type FileSystemPath to encapsulate the path in SharpFileSystem. There are operations that help create and alter the path, but the rules of using them are more strict, which creates a much more robust environment for the programmer:

  • Independent of the OS, the directory-separator is always /.
  • All paths always start with /. This means: there are no relative paths.
  • All paths that refer to a directory end with /.
  • All paths that refer to a file do not end with /.
  • The path cannot be manipulated as a string, only new paths can be created through a small set of operations (like System.IO.Path.Combine for .NET).

Some examples of using FileSystemPath:

Operation Result
var root = FileSystemPath.Root /
var mydir = root.AppendDirectory("mydir") /mydir/
var myfile = mydir.AppendFile("myfile") /mydir/myfile
myfile.AppendFile("myfile2") Error: The specified FileSystemPath is not a directory.
mydir.ParentPath /
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].