nefilim

📁 file system as used by traverse

MIT License

Stars
0

nefilim: file system as used by traverse

Introduction

Nefilim is a file system abstraction used internally with snivilised packages for file system operations. In particular, it is the file system used by the directory walker as implemented by the traverse package.

An important note has to be acknowledged about usage of the file systems defined here and their comparison to the ones as defined in the Go standard library.

There are 2 ways of interacting with the file system in Go. The primary way that seems most intuitive would be to use those functions as defined within the os package, eg, we can open a file using os.Open:

os.Open("~/foo.txt")

... or we can use the os.DirFS. However, this method uses a different concept. We can't directly open a file. We first need to create a new file system and to do so to access the local file system, we would use os.DirFS first:

localFS := os.DirFS("/foo")

where /foo represents an absolute path we have access to. The result is a file system instance as represented by the fs.FS interface. We can now open a file via this instance, but the crucial difference now is that we can now only use relative paths, where the path we specify is relative to the rooted path specified when we created the file system earlier:

localFS.Open("foo.txt")

The file system defined in Nefilim, provides access to the file system in the latter case, but not yet the former (there are plans to create another abstraction that enables the more traditional way of accessing the file system, as denoted by the first example above).

Another rationale for this repo was to fill the gap left by the standard library in that there are no writer file system interfaces, so they are defined here, primarily for the purposes of snivilised projects, but also for the benefit of third parties. Contained within is an abstraction tat defines a file system as required by traverse, but this particular instance only requires a subset of the full, set of operations one would expect of an file system, but there is also a Universal File System which will contain the full set of operations, such as Copy, which is currently not required by traverse.

There are also a few minor adjustments and additions that should be noted, such as:

  • a slightly different name for creating new directories, Mkdir as defined in the standard packages is replaced by a more user friendly MakeDir.

  • a new Move operation, which is similar to Rename but is defined to separate out the move semantics from rename; ie, Move will only move an item to a different directory. If a same directory move is detected, then this will be rejected with an appropriate error and the client is guided to use Rename instead.

  • a new Change operation is defined, that is like Move, but is stricter in that it enforces the use of a name as the to parameter denoting the destination; ie, it is prohibited to specify another relative directory as the Change operation assumes the destination should reside in the same directory as the source.

The semantics of Rename has not been changed so clients can expect consistent behaviour when compared to the standard package.

Other than these changes, the functionality in Nefilim aims to mirror the standard package as much as possible.

Features

Usage

coming soon ...