-
Shouldn't it be either
- there also exist
create_fileandread_filejust likecreate_dirandread_dir, or - there exist
Dirstruct and you use it viaDir::createandDir::open.
- there also exist
-
Shouldn't it be either
-
Permissionsis independently created fromFileand set to it byset_permissions, or -
Permissionsis only returned byMetadata::permissonsas a&mutandset_readonlyis all you have to do (you don't have to doset_permissionsafter that).
-
-
Why
FileTypeis a struct with mutually exclusiveis_*methods instead of being an enum with same variants:enum FileType { Dir, File, Symlink }
1 Like
The short version is that files are complicated, and a filepath could exist but be not a directory, file, or symlink.
There's IIRC active (but intermittent) work in this area to add a type for an "open" filehandle to a directory. It doesn't exist currently because this wasn't a semantic that std was confident saying was both
- reasonably portable between OSes, and
- generally a desirable operation.
The filesystem is inherently a shared, aliased resource (e.g. with other processes on a multitasking OS). As such, using "pseudo atomic" modifications is a better model of the actual behavior, and helps manage TOCTOU style issues.
11 Likes
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.