packages feed

unix-compat 0.3.0.2 → 0.4.0.0

raw patch · 6 files changed

+78/−18 lines, 6 filesdep +timedep ~directory

Dependencies added: time

Dependency ranges changed: directory

Files

src/System/PosixCompat/Files.hsc view
@@ -124,8 +124,12 @@ import System.IO (IOMode(..), openFile, hFileSize, hSetFileSize, hClose) import System.IO.Error import System.PosixCompat.Types-import System.Time (ClockTime(..), getClockTime) +import System.PosixCompat.Internal.Time (+      getClockTime, clockTimeToEpochTime+    , modificationTimeToEpochTime+    )+ #ifdef __GLASGOW_HASKELL__ import GHC.IO.Handle.FD (fdToHandle) #endif@@ -297,7 +301,7 @@     do perm  <- liftM permsToMode $ getPermissions path        typ   <- getFileType path        size  <- if typ == regularFileMode then getFileSize path else return 0-       mtime <- liftM clockTimeToEpochTime $ getModificationTime path+       mtime <- liftM modificationTimeToEpochTime $ getModificationTime path        return $ FileStatus                 { deviceID         = -1                 , fileID           = -1@@ -332,10 +336,6 @@ getFileSize :: FilePath -> IO FileOffset getFileSize path =     bracket (openFile path ReadMode) hClose (liftM fromIntegral . hFileSize)--clockTimeToEpochTime :: ClockTime -> EpochTime-clockTimeToEpochTime (TOD s _) = fromInteger s-  getFdStatus :: Fd -> IO FileStatus getFdStatus _ = unsupported "getFdStatus"
+ src/System/PosixCompat/Internal/Time.hs view
@@ -0,0 +1,46 @@+{-# LANGUAGE CPP #-}+{-+Compatibility wrapper to help manage the transition from+old-time to time packages. Only used at all on win32.+-}+module System.PosixCompat.Internal.Time (+      ClockTime+    , getClockTime+    , clockTimeToEpochTime+    , ModificationTime+    , modificationTimeToEpochTime+    ) where++import System.Posix.Types (EpochTime)++#ifdef OLD_TIME++import System.Time (ClockTime(TOD), getClockTime)++clockTimeToEpochTime :: ClockTime -> EpochTime+clockTimeToEpochTime (TOD s _) = fromInteger s++type ModificationTime = ClockTime++modificationTimeToEpochTime :: ModificationTime -> EpochTime+modificationTimeToEpochTime = clockTimeToEpochTime++#else++import Data.Time.Clock (UTCTime)+import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime, utcTimeToPOSIXSeconds)++type ClockTime = POSIXTime++getClockTime :: IO ClockTime+getClockTime = getPOSIXTime++clockTimeToEpochTime :: ClockTime -> EpochTime+clockTimeToEpochTime = fromInteger . floor++type ModificationTime = UTCTime++modificationTimeToEpochTime :: UTCTime -> EpochTime+modificationTimeToEpochTime = clockTimeToEpochTime . utcTimeToPOSIXSeconds++#endif
src/System/PosixCompat/Temp.hs view
@@ -21,7 +21,7 @@ -- can use our own implementation of mkstemp.  import System.IO (Handle)-import Foreign.C (CInt, CString, withCString, peekCString, throwErrnoIfMinus1)+import Foreign.C (CInt(..), CString, withCString, peekCString, throwErrnoIfMinus1) import GHC.IO.Handle.FD (fdToHandle)  -- | 'mkstemp' - make a unique filename and open it for
src/System/PosixCompat/Time.hs view
@@ -18,16 +18,16 @@  import Control.Monad (liftM) import System.Posix.Types (EpochTime)-import System.Time (ClockTime(..), getClockTime) +import System.PosixCompat.Internal.Time (+      getClockTime, clockTimeToEpochTime+    )+ -- | The portable version of @epochTime@ calls 'getClockTime' to obtain the --   number of seconds that have elapsed since the epoch (Jan 01 00:00:00 GMT --   1970). epochTime :: IO EpochTime epochTime = liftM clockTimeToEpochTime getClockTime--clockTimeToEpochTime :: ClockTime -> EpochTime-clockTimeToEpochTime (TOD s _) = fromInteger s  #endif 
src/System/PosixCompat/Unistd.hs view
@@ -25,7 +25,7 @@  import Control.Concurrent (threadDelay) import Foreign.C.String (CString, peekCString)-import Foreign.C.Types (CInt, CSize)+import Foreign.C.Types (CInt(..), CSize(..)) import Foreign.Marshal.Array (allocaArray)  data SystemID = SystemID {
unix-compat.cabal view
@@ -1,5 +1,5 @@ name:           unix-compat-version:        0.3.0.2+version:        0.4.0.0 synopsis:       Portable POSIX-compatibility layer. description:    This package provides portable implementations of parts                 of the unix package. This package re-exports the unix@@ -19,6 +19,10 @@   type:     git   location: git://github.com/jystic/unix-compat.git +flag old-time+  description: build against old-time package+  default: False+ Library   hs-source-dirs: src   ghc-options: -Wall@@ -35,16 +39,26 @@     System.PosixCompat.User    if os(windows)-    build-depends: old-time >= 1.0.0.0 && < 1.2.0.0     c-sources:       cbits/HsUname.c       cbits/mktemp.c -    if impl(ghc < 7)-      build-depends: directory == 1.0.*-      cpp-options: -DDIRECTORY_1_0+    if flag(old-time)+      build-depends: old-time >= 1.0.0.0 && < 1.2.0.0+      cpp-options: -DOLD_TIME++      if impl(ghc < 7)+        build-depends: directory == 1.0.*+        cpp-options: -DDIRECTORY_1_0+      else+        build-depends: directory == 1.1.*     else-      build-depends: directory == 1.1.*+      build-depends: time >= 1.0 && < 1.5+      build-depends: directory >= 1.2 && < 1.3++    other-modules:+      System.PosixCompat.Internal.Time+   else     build-depends: unix >= 2.4 && < 2.7     include-dirs: include