diff options
author | joe <joe@jerkface.net> | 2014-04-29 19:51:56 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-04-29 19:51:56 -0400 |
commit | 243302a3ead05d463f4de092cb334ea06ae34ad3 (patch) | |
tree | 8739724416ac601700da468fc59ffe328925923f | |
parent | 26b4148a6c14d868df624c1a1144e556e68e76cd (diff) |
implemented getInputFileTime
-rw-r--r-- | KeyRing.hs | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -93,10 +93,11 @@ import qualified Crypto.Hash.SHA1 as SHA1 | |||
93 | import qualified Data.Text as T ( Text, unpack, pack, | 93 | import qualified Data.Text as T ( Text, unpack, pack, |
94 | strip, reverse, drop, break, dropAround ) | 94 | strip, reverse, drop, break, dropAround ) |
95 | import qualified System.Posix.Types as Posix | 95 | import qualified System.Posix.Types as Posix |
96 | import System.Posix.Files ( modificationTime, getFileStatus | 96 | import System.Posix.Files ( modificationTime, getFileStatus, getFdStatus |
97 | , setFileCreationMask, setFileTimes ) | 97 | , setFileCreationMask, setFileTimes ) |
98 | import System.FilePath ( takeDirectory ) | 98 | import System.FilePath ( takeDirectory ) |
99 | import System.IO (hPutStrLn,withFile,IOMode(..)) | 99 | import System.IO (hPutStrLn,withFile,IOMode(..)) |
100 | import Foreign.C.Types ( CTime ) | ||
100 | import Data.IORef | 101 | import Data.IORef |
101 | import System.Posix.IO ( fdToHandle ) | 102 | import System.Posix.IO ( fdToHandle ) |
102 | import qualified Data.Traversable as Traversable ( mapM ) | 103 | import 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 | |||
850 | getInputFileTime :: InputFileContext -> InputFile -> IO CTime | ||
851 | getInputFileTime ctx (FileDesc fd) = do | ||
852 | handleIO_ (error $ "&"++show fd++": modificaiton time?") $ | ||
853 | modificationTime <$> getFdStatus fd | ||
854 | getInputFileTime ctx (resolveInputFile ctx -> [fname]) = do | ||
855 | handleIO_ (error $ fname++": modificaiton time?") $ | ||
856 | modificationTime <$> getFileStatus fname | ||
857 | |||
858 | |||
848 | cachedContents :: InputFileContext -> InputFile -> IO (IO S.ByteString) | 859 | cachedContents :: InputFileContext -> InputFile -> IO (IO S.ByteString) |
849 | cachedContents ctx fd = do | 860 | cachedContents ctx fd = do |
850 | ref <- newIORef Nothing | 861 | ref <- newIORef Nothing |