New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KJ Filesystem API #384

Merged
merged 5 commits into from Apr 29, 2017

Conversation

Projects
None yet
1 participant
@kentonv
Member

kentonv commented Oct 24, 2016

I've long wanted a filesystem API that:

  • Is resistant to path injection bugs.
  • Uses a representation of paths that is easy to manipulate (flat strings with / as separators are actually incredibly tedious!).
  • Canonicalizes ".." logically (by removing the previous path component) rather than physically (by climbing the directory tree), especially when dealing with the current working directory.
  • Is RAII.
  • Does not assume a singleton filesystem (= implements abstract interfaces so that you can provide a different implementation when desired).
  • Throws exceptions on error, but lets you opt-in to programatically handling the kinds of errors that one commonly wants to handle (namely, doesn't-exist and already-exists).
  • Directly supports the write-to-temp-then-atomically-replace pattern.
  • Directly supports the common operations "recursively delete directory" and "automatically create parent directories".
  • Directly supports a copy operation, with smart semantics around sparse files.
  • Makes mmap easy.
  • Automatically opens all file descriptors close-on-exec.
  • Utilizes Linux features like renameat2(), FICLONE (copy-on-write files), O_TMPFILE, etc. when available, but falls back to generic POSIX when not.
  • Much more...

So this is my attempt.

@kentonv kentonv force-pushed the filesystem branch from a51c34b to af4ea40 Dec 1, 2016

@kentonv kentonv force-pushed the filesystem branch from af4ea40 to 3f7ff30 Apr 7, 2017

@kentonv

This comment has been minimized.

Member

kentonv commented Apr 7, 2017

(I just merged everything except the filesystem API itself. Github seems very confused about this...)

@kentonv kentonv force-pushed the filesystem branch 3 times, most recently from d13f449 to e0d3908 Apr 26, 2017

kentonv added some commits Sep 12, 2016

Add KJ Filesystem API.
This has three main parts:
* The Path data structure, a more-explicit approach to file paths.
* The File/Directory abstract interfaces.
* The "InMemory" implementations of File and Directory.

Disk-based implementations will come in a future commit.

@kentonv kentonv force-pushed the filesystem branch from e0d3908 to 6d4c05d Apr 27, 2017

@kentonv

This comment has been minimized.

Member

kentonv commented Apr 29, 2017

Gonna merge this because I'm using it in a project, although currently only Ekam will build it. I guess we need a Win32 version before we can make it part of the main builds.

I already cut the 0.6 release branch so this will land in 0.7.

@kentonv kentonv merged commit b1701b8 into master Apr 29, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@kentonv kentonv deleted the filesystem branch Apr 29, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment