Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upstd: Stabilize a number of new fs features #25844
Conversation
rust-highfive
assigned
huonw
May 27, 2015
This comment has been minimized.
This comment has been minimized.
|
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
r? @aturon |
rust-highfive
assigned
aturon
and unassigned
huonw
May 27, 2015
alexcrichton
added
beta-nominated
T-libs
labels
May 27, 2015
This comment has been minimized.
This comment has been minimized.
|
Does this let Cargo build on stable? IIRC, it was only missing some FS labels. I'm |
This comment has been minimized.
This comment has been minimized.
|
It does indeed! Cargo also needs the |
This comment has been minimized.
This comment has been minimized.
|
With this |
alexcrichton
force-pushed the
alexcrichton:stabilize-fs-features
branch
3 times, most recently
from
1bd9143
to
ab0e4d7
May 28, 2015
This comment has been minimized.
This comment has been minimized.
|
Yay! I think this also lets |
willem66745
referenced this pull request
May 29, 2015
Open
postponed: mtime based reload of config file #1
alexcrichton
added
the
final-comment-period
label
Jun 2, 2015
This comment has been minimized.
This comment has been minimized.
|
This PR is now entering the final comment period for stabilizing these APIs! |
This comment has been minimized.
This comment has been minimized.
|
Should os::windows::fs::MetadataExt::{creation_time, last_access_time, last_write_time} be left unstable until a suitable time type exists, or perhaps renamed in the same style as |
This comment has been minimized.
This comment has been minimized.
|
I personally view |
This comment has been minimized.
This comment has been minimized.
|
Works for me. |
This comment has been minimized.
This comment has been minimized.
|
|
Stebalien
reviewed
Jun 5, 2015
| @@ -663,15 +623,17 @@ impl Permissions { | |||
| } | |||
| } | |||
|
|
|||
| #[unstable(feature = "file_type", reason = "recently added API")] | |||
| impl FileType { | |||
This comment has been minimized.
This comment has been minimized.
Stebalien
Jun 5, 2015
Contributor
I probably missed the discussion but why is this not an (extensible) enum? This seems like a really good candidate. Yes, some of the variants won't make sense on certain platforms but I don't think that's really an issue (we'll just have extra variants) and being able to match on filetype would be really nice.
This comment has been minimized.
This comment has been minimized.
Stebalien
Jun 5, 2015
Contributor
Variants:
enum FileType {
// Common
Directory, File, Symlink,
// Windows Only
ReparsePoint,
// Unix Only
CharDev, BlockDev, NamedPipe, Socket,
#[doc(hidden)]
__non_exhaustive
}
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jun 5, 2015
Author
Member
We're currently not necessarily considering a hidden/unstable variant to be an "unstable enum", it was mostly just how ErrorKind worked out. The set of file types also varies quite a bit across platforms, and the extra types made somewhat more sense to provide through extension traits instead of via this enum.
Finally, using an opaque structure allows one day accessing the raw bits used to determine the file type which may contain some unknown information.
This comment has been minimized.
This comment has been minimized.
Stebalien
Jun 5, 2015
Contributor
This actually makes it easier to write cross-platform code because the coder doesn't need to care about the platform: they just handle all cases on all platforms (when possible).
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jun 5, 2015
Author
Member
It's somewhat of a fine line between being able to write cross-platform code while still understand what is indeed cross platform. If we were to have an exhaustive enum which is the union of all file types on all platforms, it's suddenly not clear what file types come up on which platforms. Which is to say that it's not clear to me that having a union is indeed more cross platform as you're probably still going to have platform-specific code handling various file types on various platforms.
This comment has been minimized.
This comment has been minimized.
Stebalien
Jun 5, 2015
Contributor
We're currently not necessarily considering a hidden/unstable variant to be an "unstable enum", it was mostly just how ErrorKind worked out.
Given that we're already doing this, I don't see why we shouldn't do it here.
The set of file types also varies quite a bit across platforms, and the extra types made somewhat more sense to provide through extension traits instead of via this enum.
The problem with extension traits is that they force the user to care about the platform. With an enum, I could write:
fn format_filetype(s: &mut String, entry: &DirEntry) {
match entry.file_type() {
File => s.push('f'),
NamedPipe => s.push('p'),
ReparsePoint => s.push('r'),
Other => s.push('?'),
// ...
}
}With extension traits, I need one function per platform (each one importing a different extension trait). Extension traits are useful when some set of functionality is nonsensical on a platform but in this case, the extra file types make sense, they just aren't used.
Finally, using an opaque structure allows one day accessing the raw bits used to determine the file type which may contain some unknown information.
This unknown information is stored in the Metadata structure. Are you worried about unknown file types or something? Pretty much by definition, a file should only have one type so an enum should always be able to describe it.
This comment has been minimized.
This comment has been minimized.
Stebalien
Jun 6, 2015
Contributor
Sorry, I'm not re-loading before posting... For now, I feel that the enum is small enough that this isn't really an issue however, I can see this becoming an issue in the future as more platforms are added and this enum grows. So I see your point.
This comment has been minimized.
This comment has been minimized.
|
triage: beta-accepted |
alexcrichton
added
the
beta-accepted
label
Jun 9, 2015
alexcrichton
force-pushed the
alexcrichton:stabilize-fs-features
branch
from
ab0e4d7
to
c72cf72
Jun 10, 2015
This comment has been minimized.
This comment has been minimized.
|
re-r? @aturon I've rebased and updated this PR to include a snippet in |
retep998
reviewed
Jun 10, 2015
| pub type c_float = f32; | ||
| pub type c_double = f64; | ||
| #[cfg(target_arch = "aarch64")] | ||
| #[stable(feature = "raw_os", since = "1.0.0")] pub type c_char = u8; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
alexcrichton
force-pushed the
alexcrichton:stabilize-fs-features
branch
from
c72cf72
to
ec68c4a
Jun 10, 2015
This comment has been minimized.
This comment has been minimized.
|
This has gone through FCP and been reviewed by the core team, and we're ready to land the stabilization! @bors: r+ |
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton commentedMay 27, 2015
This commit stabilizes the following APIs, slating them all to be cherry-picked
into the 1.1 release.
The
os::unix::fs::Metadatastructure was also removed entirely, moving all ofits associated methods into the
os::unix::fs::MetadataExttrait instead. Themethods are all marked as
#[stable]still.As some minor cleanup, some deprecated and unstable fs apis were also removed:
Features that were explicitly left unstable include:
expansion RFC.
the set of functionality exposed is appropriate.
question as it always returns a verbatim path. Additionally the Unix
implementation is susceptible to buffer overflows on long paths unfortunately.
this time.