Skip to content

Commit e21c372

Browse files
committed
Update with changes from the implementation
1 parent f58e6cc commit e21c372

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

text/0517-io-os-reform.md

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -728,13 +728,14 @@ passing in Rust strings and literals directly, for example).
728728
* `rename`. Take `AsPath` bound.
729729
* `remove_file` (renamed from `unlink`). Take `AsPath` bound.
730730

731-
* `file_attr` (renamed from `stat`). Take `AsPath` bound. Yield a new
732-
struct, `FileAttr`, with no public fields, but `size`, `kind` and
733-
`permissions` accessors. The various `os::platform` modules will offer
734-
extension methods on this structure.
735-
736-
* `set_permissions` (renamed from `chmod`). Take `AsPath` bound, and a
737-
`FilePermissions` value. The `FilePermissions` type will be revamped
731+
* `metadata` (renamed from `stat`). Take `AsPath` bound. Yield a new
732+
struct, `Metadata`, with no public fields, but `len`, `is_dir`,
733+
`is_file`, `perms`, `accessed` and `modified` accessors. The various
734+
`os::platform` modules will offer extension methods on this
735+
structure.
736+
737+
* `set_perms` (renamed from `chmod`). Take `AsPath` bound, and a
738+
`Perms` value. The `Perms` type will be revamped
738739
as a struct with private implementation; see below.
739740

740741
**Directories**:
@@ -762,8 +763,8 @@ passing in Rust strings and literals directly, for example).
762763
The `File` type will largely stay as it is today, except that it will
763764
use the `AsPath` bound everywhere.
764765

765-
The `stat` method will be renamed to `attr`, yield a `FileAttr`, and
766-
take `&self`.
766+
The `stat` method will be renamed to `metadata`, yield a `Metadata`
767+
structure (as described above), and take `&self`.
767768

768769
The `fsync` method will be renamed to `sync_all`, and `datasync` will be
769770
renamed to `sync_data`. (Although the latter is not available on
@@ -774,39 +775,42 @@ filesystems.)
774775
The `path` method wil remain `#[unstable]`, as we do not yet want to
775776
commit to its API.
776777

777-
The `open_opts` function (renamed from `open_mode`) will take an `OpenOptions`
778-
struct, which will encompass today's `FileMode` and `FileAccess` and support a
779-
builder-style API.
778+
The `open_mode` function will be removed in favor of and will take an
779+
`OpenOptions` struct, which will encompass today's `FileMode` and
780+
`FileAccess` and support a builder-style API.
780781

781782
#### File kinds
782783
[File kinds]: #file-kinds
783784

784-
The `FileType` module will be renamed to `FileKind`, and the
785-
underlying `enum` will be hidden (to allow for platform differences
786-
and growth). It will expose at least `is_file` and `is_dir`; the other
787-
methods need to be audited for compatibility across
785+
The `FileType` type will be removed. As mentioned above, `is_file` and
786+
`is_dir` will be provided directly on `Meatadata`; the other types
787+
need to be audited for compatibility across
788788
platforms. Platform-specific kinds will be relegated to extension
789789
traits in `std::os::platform`.
790790

791+
It's possible that an
792+
[extensible](https://github.com/rust-lang/rfcs/pull/757) `Kind` will
793+
be added in the future.
794+
791795
#### File permissions
792796
[File permissions]: #file-permissions
793797

794798
The permission models on Unix and Windows vary greatly -- even between
795799
different filesystems within the same OS. Rather than offer an API
796800
that has no meaning on some platforms, we will initially provide a
797-
very limited `FilePermissions` structure in `std::fs`, and then rich
801+
very limited `Perms` structure in `std::fs`, and then rich
798802
extension traits in `std::os::unix` and `std::os::windows`. Over time,
799803
if clear cross-platform patterns emerge for richer permissions, we can
800-
grow the `FilePermissions` structure.
804+
grow the `Perms` structure.
801805

802-
On the Unix side, the constructors and accessors for `FilePermissions`
806+
On the Unix side, the constructors and accessors for `Perms`
803807
will resemble the flags we have today; details are left to the implementation.
804808

805809
On the Windows side, initially there will be no extensions, as Windows
806810
has a very complex permissions model that will take some time to build
807811
out.
808812

809-
For `std::fs` itself, `FilePermissions` will provide constructors and
813+
For `std::fs` itself, `Perms` will provide constructors and
810814
accessors for "world readable" -- and that is all. At the moment, that
811815
is all that is known to be compatible across the platforms that Rust
812816
supports.
@@ -819,11 +823,6 @@ This trait will essentially remain stay as it is (renamed from
819823

820824
#### Items to move to `os::platform`
821825

822-
* `change_file_times` will move to `os::unix` and remain `#[unstable]`
823-
*for now* (cf `SetFileTime` on Windows). Eventually we will add back
824-
a cross-platform function, when we have grown a notion of time in
825-
`std` and have a good compatibility story across all platforms.
826-
827826
* `lstat` will move to `os::unix` and remain `#[unstable]` *for now*
828827
since it is not yet implemented for Windows.
829828

@@ -834,7 +833,7 @@ This trait will essentially remain stay as it is (renamed from
834833
function in `std::fs`.
835834

836835
* In general, offer all of the `stat` fields as an extension trait on
837-
`FileAttr` (e.g. `os::unix::FileAttrExt`).
836+
`Metadata` (e.g. `os::unix::MetadataExt`).
838837

839838
### `std::net`
840839
[std::net]: #stdnet

0 commit comments

Comments
 (0)