Skip to content

Tracking Issue for feature(file_set_times): FileTimes and File::set_times #98245

Description

@joshtriplett

Feature gate: #![feature(file_set_times)]

This is a tracking issue for setting file accesses/modification timestamps via the File::set_times function and associated FileTimes structure.

Public API

// std::fs

#[derive(Copy, Clone, Debug, Default)]
pub struct FileTimes { /* ... */ };

impl FileTimes {
    pub fn new() -> Self;
    pub fn set_accessed(self, t: SystemTime) -> Self;
    pub fn set_modified(self, t: SystemTime) -> Self;
}

impl File {
    pub fn set_times(&self, times: FileTimes) -> std::io::Result<()>;
    pub fn set_modified(&self, t: SystemTime) -> std::io::Result<()>;
}
// std::os::ios::fs
// std::os::macos::fs
// std::os::watchos::fs
// std::os::windows::fs

pub trait FileTimesExt: Sealed {
    fn set_created(self, t: SystemTime) -> Self;
}

impl FileTimesExt for std::fs::FileTimes;

Steps / History

Activity

  1. added
    T-libs-api[DEPRECATED; DO NOT USE]
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Jun 19, 2022
  2. m-ou-se commented on Jun 20, 2022

    @m-ou-se
    Member

    I wonder if it would be good to have a file.set_last_modified(time) short-hand for file.set_times(FileTimes::new().set_modified(time)). FileTimes nicely allows platforms to have a FileTimesExt trait to add more times, but it's a bit verbose for simple use cases.

  3. joshtriplett commented on Jun 20, 2022

    @joshtriplett
    MemberAuthor

    @m-ou-se No fundamental objection, though I don't think we should provide an alias for accessed (less common to set in isolation, and if we had both people might be tempted to call both rather than making one call to set_times).

    Also, I'd probably call it set_modified for symmetry with the various uses of modified.

  4. joshtriplett commented on Jun 20, 2022

    @joshtriplett
    MemberAuthor

    @m-ou-se Done.

  5. sunfishcode commented on Jun 23, 2022

    @sunfishcode
    Member

    On Unix-family platforms, there's a mechanism for setting a timestamp to the current time (UTIME_NOW), which doesn't appear to be covered in this API. One can get the same effect by using a timestamp of SystemTime::now(); is that fast enough? I expect it is on Linux with the vDSO, but I don't know about other platforms.

  6. added a commit that references this issue on Oct 1, 2022
  7. sargun commented on Oct 12, 2022

    @sargun

    One thing I noticed is that there's no way to set the AT_SYMLINK_NOFOLLOW flag for this call. We might want to expose that.

  8. silence-coding commented on Oct 14, 2022

    @silence-coding

    Is there a planned stabilization time for this feature?

  9. Zerowalker commented on Jan 8, 2023

    @Zerowalker

    is it possible to at created times here as well?
    I know it exists in Windows, not sure about Unix but i would expect it's a thing there as well.

  10. rbtcollins commented on Feb 10, 2023

    @rbtcollins
    Contributor

    statx is needed for birth time support, and its getting more and more support, but it still pretty new as these things go. https://www.phoronix.com/news/FAT-File-Creation-Birth-5.19 for instance adding support for FAT32 support.

    @sargun This seems to be operating on the FD - does NOFOLLOW make any sense when not operating with paths?

  11. 10 remaining items

  12. added
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.
    on Sep 6, 2023
  13. added
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    and removed
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    on Oct 5, 2023
  14. rfcbot commented on Oct 5, 2023

    @rfcbot

    🔔 This is now entering its final comment period, as per the review above. 🔔

  15. added
    to-announceAnnounce this issue on triage meeting
    and removed
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    on Oct 15, 2023
  16. rfcbot commented on Oct 15, 2023

    @rfcbot

    The final comment period, with a disposition to merge, as per the review above, is now complete.

    As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

    This will be merged soon.

  17. ChrisDenton commented on Oct 25, 2023

    @ChrisDenton
    Member

    FCP is completed! Anyone feel like making a stabilization PR?

  18. added a commit that references this issue on Oct 31, 2023
  19. added a commit that references this issue on Nov 1, 2023
  20. chenyukang commented on Jan 28, 2024

    @chenyukang
    Member

    Closing this issue since stabilization PR is finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions