wasi-filesystem icon indicating copy to clipboard operation
wasi-filesystem copied to clipboard

Support file-dir duality

Open SoniEx2 opened this issue 1 year ago • 2 comments

It would be nice if the filesystem API were allowed to support file-dir duality, tho we wouldn't expect most implementations to support it.

Many filesystems, from Mac "System 7" to Windows NTFS, and beyond, exhibit some form of file-dir duality. Whether the wasi runtime should expose it is another question, and will depend on the wasi runtime's goals, but it would be nice if it were at least allowed.

SoniEx2 avatar May 12 '23 14:05 SoniEx2

What is file-dir duality? And how would applications use it?

sunfishcode avatar May 18 '23 23:05 sunfishcode

sometimes you really want both file and dir contents in the same filesystem node. some systems use these for resource forks. since POSIX doesn't have file-dir duality, and arguably forbids file-dir duality, most POSIX apps use the .d convention. a dir ending in .d is a dir associated with the file lacking the .d. this is most commonly seen in /etc, where you'll have a file like profile and dir like profile.d will hold extra scripts related to profile, or you'll have user.conf and user.conf.d again following roughly the same structure. (these files really wanna be under their parent's namespace, but POSIX doesn't allow it. isn't that unfortunate? we could fix it tho!)

programming languages could use file-dir duality to allow submodules to be loaded from a file-dir node: instead of having, say, foo.rs and foo/bar.rs, you could have foo.rs and foo.rs/bar.rs. the main benefit of this comes when you expose these through a tab-completion interface: file-dir duality allows e.g. f<tab> to always expand to foo.rs, only requiring additional typing for submodules. without file-dir duality, every tab-completion option - except the .d convention, for things that support it - requires multiple <tab>s to complete.

SoniEx2 avatar May 19 '23 00:05 SoniEx2