{-# LINE 1 "System/Directory/Internal/C_utimensat.hsc" #-}
{-# LANGUAGE CApiFFI #-}
module System.Directory.Internal.C_utimensat where
{-# LINE 6 "System/Directory/Internal/C_utimensat.hsc" #-}
{-# LINE 7 "System/Directory/Internal/C_utimensat.hsc" #-}
{-# LINE 9 "System/Directory/Internal/C_utimensat.hsc" #-}
{-# LINE 10 "System/Directory/Internal/C_utimensat.hsc" #-}
{-# LINE 12 "System/Directory/Internal/C_utimensat.hsc" #-}
{-# LINE 13 "System/Directory/Internal/C_utimensat.hsc" #-}
{-# LINE 15 "System/Directory/Internal/C_utimensat.hsc" #-}
import Prelude ()
import System.Directory.Internal.Prelude
import Data.Time.Clock.POSIX (POSIXTime)
data CTimeSpec = CTimeSpec EpochTime CLong
instance Storable CTimeSpec where
sizeOf _ = (16)
{-# LINE 24 "System/Directory/Internal/C_utimensat.hsc" #-}
alignment _ = (8)
{-# LINE 26 "System/Directory/Internal/C_utimensat.hsc" #-}
poke p (CTimeSpec sec nsec) = do
((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p sec
{-# LINE 28 "System/Directory/Internal/C_utimensat.hsc" #-}
((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p nsec
{-# LINE 29 "System/Directory/Internal/C_utimensat.hsc" #-}
peek p = do
sec <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p
{-# LINE 31 "System/Directory/Internal/C_utimensat.hsc" #-}
nsec <- (\hsc_ptr -> peekByteOff hsc_ptr 8) p
{-# LINE 32 "System/Directory/Internal/C_utimensat.hsc" #-}
return (CTimeSpec sec nsec)
c_AT_FDCWD :: CInt
c_AT_FDCWD = (-100)
{-# LINE 36 "System/Directory/Internal/C_utimensat.hsc" #-}
utimeOmit :: CTimeSpec
utimeOmit = CTimeSpec (CTime 0) (1073741822)
{-# LINE 39 "System/Directory/Internal/C_utimensat.hsc" #-}
toCTimeSpec :: POSIXTime -> CTimeSpec
toCTimeSpec t = CTimeSpec (CTime sec) (truncate $ 10 ^ (9 :: Int) * frac)
where
(sec, frac) = if frac' < 0 then (sec' - 1, frac' + 1) else (sec', frac')
(sec', frac') = properFraction (toRational t)
foreign import capi "sys/stat.h utimensat" c_utimensat
:: CInt -> CString -> Ptr CTimeSpec -> CInt -> IO CInt
{-# LINE 50 "System/Directory/Internal/C_utimensat.hsc" #-}