{-# LINE 1 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} {-# LANGUAGE CApiFFI #-} module System.Directory.Internal.C_utimensat where {-# LINE 6 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} {-# LINE 7 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} {-# LINE 9 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} {-# LINE 10 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} {-# LINE 12 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} {-# LINE 13 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} {-# LINE 15 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} import Prelude () import System.Directory.Internal.Prelude import Data.Time.Clock.POSIX (POSIXTime) import qualified System.Posix as Posix data CTimeSpec = CTimeSpec EpochTime CLong instance Storable CTimeSpec where sizeOf :: CTimeSpec -> Int sizeOf CTimeSpec _ = (Int 8) {-# LINE 24 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} alignment _ = 4 {-# LINE 25 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} poke p (CTimeSpec sec nsec) = do ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p sec {-# LINE 27 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} ((\hsc_ptr -> pokeByteOff hsc_ptr 4)) p nsec {-# LINE 28 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} peek p = do sec <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p {-# LINE 30 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} nsec <- (\hsc_ptr -> peekByteOff hsc_ptr 4) p {-# LINE 31 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} return (CTimeSpec sec nsec) utimeOmit :: CTimeSpec utimeOmit :: CTimeSpec utimeOmit = EpochTime -> CLong -> CTimeSpec CTimeSpec (Int32 -> EpochTime CTime Int32 0) (CLong 1073741822) {-# LINE 35 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-} toCTimeSpec :: POSIXTime -> CTimeSpec toCTimeSpec :: POSIXTime -> CTimeSpec toCTimeSpec POSIXTime t = EpochTime -> CLong -> CTimeSpec CTimeSpec (Int32 -> EpochTime CTime Int32 sec) (Rational -> CLong forall b. Integral b => Rational -> b forall a b. (RealFrac a, Integral b) => a -> b truncate (Rational -> CLong) -> Rational -> CLong forall a b. (a -> b) -> a -> b $ Rational 10 Rational -> Int -> Rational forall a b. (Num a, Integral b) => a -> b -> a ^ (Int 9 :: Int) Rational -> Rational -> Rational forall a. Num a => a -> a -> a * Rational frac) where (Int32 sec, Rational frac) = if Rational frac' Rational -> Rational -> Bool forall a. Ord a => a -> a -> Bool < Rational 0 then (Int32 sec' Int32 -> Int32 -> Int32 forall a. Num a => a -> a -> a - Int32 1, Rational frac' Rational -> Rational -> Rational forall a. Num a => a -> a -> a + Rational 1) else (Int32 sec', Rational frac') (Int32 sec', Rational frac') = Rational -> (Int32, Rational) forall b. Integral b => Rational -> (b, Rational) forall a b. (RealFrac a, Integral b) => a -> (b, a) properFraction (POSIXTime -> Rational forall a. Real a => a -> Rational toRational POSIXTime t) foreign import capi "sys/stat.h utimensat" c_utimensat :: Posix.Fd -> CString -> Ptr CTimeSpec -> CInt -> IO CInt {-# LINE 46 "libraries/directory/System/Directory/Internal/C_utimensat.hsc" #-}