Ticket #6160 (closed feature request: fixed)

Opened 12 months ago

Last modified 9 months ago

support sub-second resolutions for file timestamps

Reported by: redneb Owned by:
Priority: normal Milestone: 7.6.1
Component: libraries/unix Version: 7.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Currently all file timestamps related functions (accessTime, modificationTime, statusChangeTime, setFileTimes) offer resolution of one second. Most modern posix systems support better resolutions for file timestamps.

Attachments

Change History

Changed 12 months ago by redneb

The above patch introduces 3 new functions:

accessTimeHiRes       :: FileStatus -> POSIXTime
modificationTimeHiRes :: FileStatus -> POSIXTime
statusChangeTimeHiRes :: FileStatus -> POSIXTime

When I have time I will send a patch for setFileTimes.

Changed 11 months ago by igloo

  • status changed from new to patch
  • difficulty set to Unknown

Changed 11 months ago by simonmar

I see no reason not to have this, except that it introduces a dependency from unix on time (one might expect the dependency to go the other way, because time needs access to POSIX interfaces to get the current time for example, but time does its own FFI).

Any objections, or shall we just apply it?

Changed 10 months ago by simonpj

  • owner set to pcapriotti

Changed 10 months ago by pcapriotti

  • status changed from patch to closed
  • resolution set to fixed
  • milestone set to 7.6.1

Applied, thanks.

commit 9acb33c819356a49068ec041c38e438d335e9781
Author: Marios Titas <redneb@gmx.com>
Date:   Wed Jun 13 02:52:03 2012 -0400

    Extract high resolution timestamps from FileStatus
    
    Signed-off-by: Paolo Capriotti <p.capriotti@gmail.com>

Changed 10 months ago by redneb

  • owner pcapriotti deleted
  • status changed from closed to new
  • resolution fixed deleted

I am reopening this to post the second part of what I promised earlier, ie operations for changing file timestamps. The above patch introduces 5 new functions:

setFileTimesHiRes :: FilePath -> POSIXTime -> POSIXTime -> IO ()
setFdTimesHiRes :: Fd -> POSIXTime -> POSIXTime -> IO ()
setSymbolicLinkTimesHiRes :: FilePath -> POSIXTime -> POSIXTime -> IO ()
touchFd :: Fd -> IO ()
touchSymbolicLink :: FilePath -> IO ()

This should complete the file timestamp related operations.

Changed 10 months ago by pcapriotti

  • status changed from new to patch

Changed 10 months ago by simonmar

I think it would be good to note in the documentation for these functions that they are not POSIX and therefore might not be available on all platforms, and that they might thrown an error if the platform does not support the underlying API.

Changed 10 months ago by redneb

I updated the patch so that the documentation includes a note that some of these functions are not supported on all platforms.

By the way, there is a similar issue with the already existing setSymbolicLinkOwnerAndGroup function: currently it is exported by System.Posix.Files only on platforms that support this operation. I think it should be exported everywhere and raise an exception on platforms that do not support it.

Changed 9 months ago by pcapriotti

  • status changed from patch to closed
  • resolution set to fixed

Thank you for the patch. Applied as:

commit 62e07b8a423a78556e2f5d86d1affe7cca4c8896
Author: Marios Titas <redneb@gmx.com>
Date:   Sun Aug 12 15:46:22 2012 -0400

    Add functions for setting file times with high resolution
Note: See TracTickets for help on using tickets.