Skip to content

Commit d6dea00

Browse files
committed
Add documentation on timestamp resolution limitations on HFS+.
1 parent 7207bae commit d6dea00

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

System/Posix/Files.hsc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,10 @@ setFileTimes name atime mtime = do
345345

346346
-- | Like 'setFileTimes' but timestamps can have sub-second resolution.
347347
--
348-
-- Note: calls @utimensat@ or @utimes@.
348+
-- Note: calls @utimensat@ or @utimes@. Support for high resolution timestamps
349+
-- is filesystem dependent with the following limitations:
350+
--
351+
-- - HFS+ volumes on OS X truncate the sub-second part of the timestamp.
349352
--
350353
-- @since 2.7.0.0
351354
setFileTimesHiRes :: FilePath -> POSIXTime -> POSIXTime -> IO ()
@@ -366,7 +369,10 @@ setFileTimesHiRes name atime mtime =
366369
-- This operation is not supported on all platforms. On these platforms,
367370
-- this function will raise an exception.
368371
--
369-
-- Note: calls @utimensat@ or @lutimes@.
372+
-- Note: calls @utimensat@ or @lutimes@. Support for high resolution timestamps
373+
-- is filesystem dependent with the following limitations:
374+
--
375+
-- - HFS+ volumes on OS X truncate the sub-second part of the timestamp.
370376
--
371377
-- @since 2.7.0.0
372378
setSymbolicLinkTimesHiRes :: FilePath -> POSIXTime -> POSIXTime -> IO ()

System/Posix/Files/ByteString.hsc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,11 @@ setFileTimes name atime mtime = do
351351

352352
-- | Like 'setFileTimes' but timestamps can have sub-second resolution.
353353
--
354-
-- Note: calls @utimensat@ or @utimes@.
354+
-- Note: calls @utimensat@ or @utimes@. Support for high resolution timestamps
355+
-- is filesystem dependent with the following limitations:
356+
--
357+
-- - HFS+ volumes on OS X truncate the sub-second part of the timestamp.
358+
--
355359
setFileTimesHiRes :: RawFilePath -> POSIXTime -> POSIXTime -> IO ()
356360
#ifdef HAVE_UTIMENSAT
357361
setFileTimesHiRes name atime mtime =
@@ -370,7 +374,11 @@ setFileTimesHiRes name atime mtime =
370374
-- This operation is not supported on all platforms. On these platforms,
371375
-- this function will raise an exception.
372376
--
373-
-- Note: calls @utimensat@ or @lutimes@.
377+
-- Note: calls @utimensat@ or @lutimes@. Support for high resolution timestamps
378+
-- is filesystem dependent with the following limitations:
379+
--
380+
-- - HFS+ volumes on OS X truncate the sub-second part of the timestamp.
381+
--
374382
setSymbolicLinkTimesHiRes :: RawFilePath -> POSIXTime -> POSIXTime -> IO ()
375383
#if HAVE_UTIMENSAT
376384
setSymbolicLinkTimesHiRes name atime mtime =

System/Posix/Files/Common.hsc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ setFileCreationMask mask = c_umask mask
231231
-- 'FileStatus' type.
232232
--
233233
-- Note: see @chmod@.
234+
--
235+
-- Limitations: Support for high resolution timestamps is filesystem dependent:
236+
--
237+
-- - HFS+ volumes on OS X only support whole-second times.
238+
--
234239
newtype FileStatus = FileStatus (ForeignPtr CStat)
235240

236241
-- | ID of the device on which this file resides.
@@ -252,15 +257,18 @@ specialDeviceID :: FileStatus -> DeviceID
252257
fileSize :: FileStatus -> FileOffset
253258
-- | Time of last access.
254259
accessTime :: FileStatus -> EpochTime
255-
-- | Time of last access in sub-second resolution.
260+
-- | Time of last access in sub-second resolution. Depends on the timestamp resolution of the
261+
-- underlying filesystem.
256262
accessTimeHiRes :: FileStatus -> POSIXTime
257263
-- | Time of last modification.
258264
modificationTime :: FileStatus -> EpochTime
259-
-- | Time of last modification in sub-second resolution.
265+
-- | Time of last modification in sub-second resolution. Depends on the timestamp resolution of the
266+
-- underlying filesystem.
260267
modificationTimeHiRes :: FileStatus -> POSIXTime
261268
-- | Time of last status change (i.e. owner, group, link count, mode, etc.).
262269
statusChangeTime :: FileStatus -> EpochTime
263270
-- | Time of last status change (i.e. owner, group, link count, mode, etc.) in sub-second resolution.
271+
-- Depends on the timestamp resolution of the underlying filesystem.
264272
statusChangeTimeHiRes :: FileStatus -> POSIXTime
265273

266274
deviceID (FileStatus stat) =
@@ -465,7 +473,11 @@ foreign import ccall unsafe "futimes"
465473
-- This operation is not supported on all platforms. On these platforms,
466474
-- this function will raise an exception.
467475
--
468-
-- Note: calls @futimens@ or @futimes@.
476+
-- Note: calls @futimens@ or @futimes@. Support for high resolution timestamps
477+
-- is filesystem dependent with the following limitations:
478+
--
479+
-- - HFS+ volumes on OS X truncate the sub-second part of the timestamp.
480+
--
469481
--
470482
-- @since 2.7.0.0
471483
setFdTimesHiRes :: Fd -> POSIXTime -> POSIXTime -> IO ()

0 commit comments

Comments
 (0)