pathtype 0.5.2 → 0.5.3
raw patch · 4 files changed
+37/−8 lines, 4 filesdep +timedep ~directory
Dependencies added: time
Dependency ranges changed: directory
Files
- System/Path/Directory.hs +23/−3
- System/Path/IO.hs +0/−1
- Test.hs +1/−1
- pathtype.cabal +13/−3
System/Path/Directory.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE CPP, OverloadedStrings #-} -- | This module provides type-safe access to directory manipulations. -- -- It is designed to be imported instead of "System.Directory".@@ -71,15 +71,20 @@ import Control.Applicative import Control.Arrow import Data.List+import Data.Time import GHC.Exts(IsString(..)) import System.Directory (Permissions) import qualified System.Directory as SD import System.IO hiding (FilePath) import System.IO.Error-import System.Time import Test.QuickCheck import Text.Printf +-- directory < 1.2 used old-time; to present a consistent API we convert it+-- time:Data.Time.UTCTime.+#if !(MIN_VERSION_directory(1,2,0))+import System.Time+#endif ------------------------------------------------------------------------ -- Actions on directories@@ -203,8 +208,23 @@ ------------------------------------------------------------------------ -- Timestamps -getModificationTime :: AbsRelClass ar => Path ar fd -> IO ClockTime+getModificationTime :: AbsRelClass ar => Path ar fd -> IO UTCTime+#if MIN_VERSION_directory(1,2,0) getModificationTime p = SD.getModificationTime (getPathString p)+#else+-- directory < 1.2 used the old-time package, convert to UTCTime+getModificationTime p = convertTime <$> SD.getModificationTime (getPathString p)+ where+ convertTime clock = UTCTime day (fromIntegral sec)+ where+ calendar = toUTCTime clock+ day = addDays (toInteger (ctYDay calendar)) yearStart+ yearStart = fromGregorian (toInteger (ctYear calendar)) 1 1+ hour = ctHour calendar+ min = hour * 60 + ctMin calendar+ sec = min * 60 + ctSec calendar+#endif+ ------------------------------------------------------------------------
System/Path/IO.hs view
@@ -104,7 +104,6 @@ withBinaryFile, openBinaryFile, openTempFile, openBinaryTempFile) import qualified System.IO as SIO import System.IO.Error-import System.Time import Test.QuickCheck import Text.Printf
Test.hs view
@@ -25,7 +25,7 @@ writeFile testModule $ unlines $ templateHead ++ outLines ++ templateTail - let args = ["-e","TestModule.main",testModule]+ let args = ["-optP-include", "-optPdist/build/autogen/cabal_macros.h", "-e","TestModule.main",testModule] ghc = "ghc" stdinput = ""
pathtype.cabal view
@@ -1,5 +1,5 @@ Name: pathtype-Version: 0.5.2+Version: 0.5.3 Synopsis: Type-safe replacement for System.FilePath etc Description: This package provides type-safe access to filepath manipulations. .@@ -78,7 +78,7 @@ License: BSD3 Category: System License-file: LICENSE-Author: Ben Moseley+Author: Ben Moseley, Ben Millwood Maintainer: ben@moseley.name HomePage: http://code.haskell.org/pathtype Build-Type: Simple@@ -89,8 +89,18 @@ type: darcs location: http://code.haskell.org/pathtype +flag old-time+ description: Build with directory < 1.2 and old-time+ default: True+ Library- Build-Depends: base >= 4 && < 5, directory >= 1 && < 2, old-time >= 1.0 && < 2, QuickCheck >= 2.1.0.1 && < 3+ Build-Depends: base >= 4 && < 5, time >= 1.0 && < 2, QuickCheck >= 2.1.0.1 && < 3++ if flag(old-time)+ Build-Depends: directory >= 1 && < 1.2, old-time >= 1.0 && < 2+ else+ Build-Depends: directory >= 1.2 && < 2+ Exposed-modules: System.Path, System.Path.Directory, System.Path.IO, System.Path.Posix, System.Path.Windows Extensions: EmptyDataDecls, PatternGuards, FlexibleInstances, Rank2Types, OverloadedStrings, CPP