summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-29 19:51:56 -0400
committerjoe <joe@jerkface.net>2014-04-29 19:51:56 -0400
commit243302a3ead05d463f4de092cb334ea06ae34ad3 (patch)
tree8739724416ac601700da468fc59ffe328925923f
parent26b4148a6c14d868df624c1a1144e556e68e76cd (diff)
implemented getInputFileTime
-rw-r--r--KeyRing.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/KeyRing.hs b/KeyRing.hs
index 3765f42..f9720fa 100644
--- a/KeyRing.hs
+++ b/KeyRing.hs
@@ -93,10 +93,11 @@ import qualified Crypto.Hash.SHA1 as SHA1
93import qualified Data.Text as T ( Text, unpack, pack, 93import qualified Data.Text as T ( Text, unpack, pack,
94 strip, reverse, drop, break, dropAround ) 94 strip, reverse, drop, break, dropAround )
95import qualified System.Posix.Types as Posix 95import qualified System.Posix.Types as Posix
96import System.Posix.Files ( modificationTime, getFileStatus 96import System.Posix.Files ( modificationTime, getFileStatus, getFdStatus
97 , setFileCreationMask, setFileTimes ) 97 , setFileCreationMask, setFileTimes )
98import System.FilePath ( takeDirectory ) 98import System.FilePath ( takeDirectory )
99import System.IO (hPutStrLn,withFile,IOMode(..)) 99import System.IO (hPutStrLn,withFile,IOMode(..))
100import Foreign.C.Types ( CTime )
100import Data.IORef 101import Data.IORef
101import System.Posix.IO ( fdToHandle ) 102import System.Posix.IO ( fdToHandle )
102import qualified Data.Traversable as Traversable ( mapM ) 103import qualified Data.Traversable as Traversable ( mapM )
@@ -845,6 +846,16 @@ readInputFileL ctx inp = do
845 let fname = resolveInputFile ctx inp 846 let fname = resolveInputFile ctx inp
846 fmap L.concat $ mapM L.readFile fname 847 fmap L.concat $ mapM L.readFile fname
847 848
849
850getInputFileTime :: InputFileContext -> InputFile -> IO CTime
851getInputFileTime ctx (FileDesc fd) = do
852 handleIO_ (error $ "&"++show fd++": modificaiton time?") $
853 modificationTime <$> getFdStatus fd
854getInputFileTime ctx (resolveInputFile ctx -> [fname]) = do
855 handleIO_ (error $ fname++": modificaiton time?") $
856 modificationTime <$> getFileStatus fname
857
858
848cachedContents :: InputFileContext -> InputFile -> IO (IO S.ByteString) 859cachedContents :: InputFileContext -> InputFile -> IO (IO S.ByteString)
849cachedContents ctx fd = do 860cachedContents ctx fd = do
850 ref <- newIORef Nothing 861 ref <- newIORef Nothing