-
Shouldn't it be either
- there also exist
create_file
andread_file
just likecreate_dir
andread_dir
, or - there exist
Dir
struct and you use it viaDir::create
andDir::open
.
- there also exist
-
Shouldn't it be either
-
Permissions
is independently created fromFile
and set to it byset_permissions
, or -
Permissions
is only returned byMetadata::permissons
as a&mut
andset_readonly
is all you have to do (you don't have to doset_permissions
after that).
-
-
Why
FileType
is 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.