Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: Expose SystemTime accessors on fs::Metadata #30865

Merged
merged 1 commit into from
Feb 5, 2016

Conversation

alexcrichton
Copy link
Member

These accessors are used to get at the last modification, last access, and
creation time of the underlying file. Currently not all platforms provide the
creation time, so that currently returns Option.

@alexcrichton
Copy link
Member Author

cc @rust-lang/libs, we'll likely want to discuss this a bit before landing, especially the choice about returning Option<SystemTime> from created (and of course some minor bikeshedding)

r? @aturon

@Gankra
Copy link
Contributor

Gankra commented Jan 13, 2016

Could you elaborate on the "not all platforms support this" aspect? It seems from the PR that this is known to succeed or fail at compile time, which seems to imply that it fits in with our platform-specific extension traits. Are we expecting some platforms to have "truly conditional" support, or is the extension trait too annoying?

@pitdicker
Copy link
Contributor

A creation time (birth time) is in the works for a few filesystems on Linux (like btrfs, ext4 and jfs), but most filesystems and older kernels will not support it. So an option looks right.

@alexcrichton
Copy link
Member Author

@gankro currently it's a statically made decision based on the OS, but @pitdicker brings up an interesting point I had not thought of!

/// Returns the last access time of this metadata.
///
/// The returned value corresponds to the `atime` field of `stat` on Unix
/// platforms and the `ftLastAccessTime` field on Windows platforms.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may also be good to point out that even though all platforms do provide this value, not all platforms will actually keep it updated. I know at least on Windows there is an option to disable updating of the last access time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux too, with noatime.

@brson
Copy link
Contributor

brson commented Jan 16, 2016

File access time is such a misfeature I wonder if this might not be very futureproof. Maybe places we might want to run std won't support that feature. I don't have concrete examples though, and there are probably lots of places were we've wed std to the union of unix + windows.

@retep998
Copy link
Member

Maybe make all of the file times be Option just in case there is that weird platform or filesystem that doesn't have them.

@alexcrichton alexcrichton added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jan 16, 2016
@aturon
Copy link
Member

aturon commented Jan 28, 2016

Maybe make all of the file times be Option just in case there is that weird platform or filesystem that doesn't have them.

Not a bad idea (especially for the case of filesystem variance). Though I wonder if Result might be better, so that we can potentially provide detailed error information in the future.

@alexcrichton
Copy link
Member Author

Updated with some tweaked docs and all methods returning io::Result instead of some fallible and some infallible

@aturon
Copy link
Member

aturon commented Jan 29, 2016

r=me implementation-wise. Given that these are all unstable, I'm OK going ahead and landing, but if you'd rather wait till the next libs meeting, that's fine too.

@alexcrichton
Copy link
Member Author

Cool, I'm fine waiting for the libs meeting, wanna be sure we're on the same page.

@alexcrichton
Copy link
Member Author

@bors: r=aturon cf74cd917feee816b2b7c5babe6aa6c99c87e40c

(carrying over from the libs triage meeting)

@alexcrichton
Copy link
Member Author

Oh, and discussed during libs triage today, we concluded that it's fine to add these functions as unstable for now. We may want to revisit signatures and/or naming, but the functionality seems good.

@alexcrichton alexcrichton removed the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Feb 4, 2016
@bors
Copy link
Contributor

bors commented Feb 4, 2016

⌛ Testing commit cf74cd9 with merge 7ded903...

@bors
Copy link
Contributor

bors commented Feb 4, 2016

💔 Test failed - auto-mac-64-nopt-t

@alexcrichton
Copy link
Member Author

@bors: r=aturon

@bors
Copy link
Contributor

bors commented Feb 4, 2016

📌 Commit 208cd38 has been approved by aturon

@bors
Copy link
Contributor

bors commented Feb 4, 2016

⌛ Testing commit 208cd38 with merge 13cb16a...

@bors
Copy link
Contributor

bors commented Feb 4, 2016

💔 Test failed - auto-mac-64-opt

@alexcrichton
Copy link
Member Author

@bors: r=aturon 32cf074

@bors
Copy link
Contributor

bors commented Feb 4, 2016

☔ The latest upstream changes (presumably #31360) made this pull request unmergeable. Please resolve the merge conflicts.

These accessors are used to get at the last modification, last access, and
creation time of the underlying file. Currently not all platforms provide the
creation time, so that currently returns `Option`.
@alexcrichton
Copy link
Member Author

@bors: r=aturon d1681bb

@bors
Copy link
Contributor

bors commented Feb 5, 2016

⌛ Testing commit d1681bb with merge 7bcced7...

bors added a commit that referenced this pull request Feb 5, 2016
These accessors are used to get at the last modification, last access, and
creation time of the underlying file. Currently not all platforms provide the
creation time, so that currently returns `Option`.
@bors bors merged commit d1681bb into rust-lang:master Feb 5, 2016
@alexcrichton alexcrichton deleted the mtime-system-time branch February 8, 2016 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants