tinyrange / pkg2

Package Metadata Database
https://pkg2.thrush-map.ts.net/
Apache License 2.0
2 stars 0 forks source link

Make the filesystem POSIX-compliant. #7

Closed Vbitz closed 2 weeks ago

Vbitz commented 1 month ago

Right now the file system handling code is highly simplified with a simple array of files (and directories) for the .tar archives. The git repository handling code is better in this regard with a tree structure that can be navigated though.

I'd like to take this a few steps further and provide a POSIX like interface to all archives. For example you should be able to do...

fs = open("file.tar.gz").read_archive(".tar.gz")

f = fs["hello/world.txt"]

print(f.read()) # Prints out the contents of f.

fs2 = open("file2.tar.gz").read_archive(".tar.gz")

fs["hello"] = fs2["world"] # Overwrite the hello directory with the world directory from fs2.

Indexing into a filesystem or a directory is like calling open and file handles can be passed around or copied between filesystems (since the filesystem doesn't represent real contents on disk but rather a in-memory structure.

The POSIX side is necessary for #5 since Makefiles and the shell rely on a POSIX-compliant filesystem as a base.

Vbitz commented 1 month ago

This commit adds the first step towards that https://github.com/tinyrange/pkg2/commit/40b22275a150651f9cffecd2b4ac63f3219976ef

It adds a new heretical filesystem API. This is not yet exposed to the shell_context system.

Vbitz commented 2 weeks ago

v2 includes this new filesystem. It's not yet POSIX-compliant but that will happen as I keep working on the shell emulator system.