@hipsterelectron @zwol Did you miss openat()/the whold *at() family of functions added in POSIX 2008? I think these are exactly what you want. The operate on a relative pathname relative to a given open directory fd, rather than implicitly using the process-global current working directory (which behaves like a hidden file descriptor).
@hipsterelectron @zwol Probably because Rust is allergic to POSIX and wants non-POSIX Windows runtimes to be first-class...
@hipsterelectron Unfortunately there are two philosophies here:
1. POSIX is one of "many" types of platforms, special-cased like "all" the others.
2. POSIX is the agreed-upon standard for how software interfaces with the operating system, and on the ONE system that doesn't at least try to provide it, you patch things up as needed.
Unfortunately Rust seems to be in camp 1...
@dalias i am 100% with you https://circumstances.run/@hipsterelectron/114103048857987680 i like that python's path library explicitly separates the two types of paths into separate types (and even allows you to test your code on windows paths without a windows box) instead of rust trying to find a common ground and failing
@hipsterelectron @dalias those who don't learn from Common Lisp pathnames are doomed to reinvent them?
@hipsterelectron @dalias its standard pathname type is both overengineered and underspecified in a way that this conversation reminded me of. they had a similar goal of unifying diverse platforms, but it ended up creating portability issues among lisp implementations of its own https://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node204.html
Note that a pathname is not necessarily the name of a specific file. Rather, it is a specification (possibly only a partial specification) of how to access a file. A pathname need not correspond to any file that actually exists, and more than one pathname can refer to the same file.
@hipsterelectron @joe @dalias oh oh! it's like file URIs! we think?
file URIs are neat.
(java is big on URIs for everything, it works alright)
@lispi314 @hipsterelectron Sorry I can't be bothered to reply to repeated delete-and-redraft. Doesn't your instance have edit if needed??
@dalias @hipsterelectron while posix is common in the server space, it is not the main or even a supported API used by programs on most other platforms, and so it makes sense that the OS interface APIs provided model a common denominator across platforms (which is not posix most importantly)
When you pretend everything is posix, your OS APIs will be modeled after POSIX as well, hardcoding design decisions that are simply not supported on other oses in the same way, if at all.
For example, you might provide a call to get or set the current permissions of a file. on posix this is a simple wrapper around stat
and chmod
, but what about platforms that only let you mark a file as read only?
you can implement the get the file mode call, sure, but setting it will simply not behave like posix chmod, no matter how hard you try. this will introduce bugs in software that simply doesn’t know or hasn’t accounted for these differences
And this example isn’t taken out of nowhere — that would be how files work without ACLs in windows