summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Compile
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2013-12-16 14:04:57 +0000
committerhallgren <hallgren@chalmers.se>2013-12-16 14:04:57 +0000
commit2b16962835af120a332c5e54c3465a0d02e9b668 (patch)
treedce62262dd77ceaa1ee5b3f71130eeca5eab7449 /src/compiler/GF/Compile
parent1010d357c53e45902e8ee7a53b39464bb9b8ab06 (diff)
GF.Compile.ReadFiles: reduced code duplication
Diffstat (limited to 'src/compiler/GF/Compile')
-rw-r--r--src/compiler/GF/Compile/ReadFiles.hs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/compiler/GF/Compile/ReadFiles.hs b/src/compiler/GF/Compile/ReadFiles.hs
index 70b0d6ee6..02bc4452d 100644
--- a/src/compiler/GF/Compile/ReadFiles.hs
+++ b/src/compiler/GF/Compile/ReadFiles.hs
@@ -43,9 +43,8 @@ import Control.Monad
import Data.Maybe(isJust)
import qualified Data.ByteString.Char8 as BS
import qualified Data.Map as Map
-import Data.Time
-import Data.Time.Compat (toUTCTime)
-import System.Directory
+import Data.Time(UTCTime)
+import GF.System.Directory
import System.FilePath
import Text.PrettyPrint
@@ -58,8 +57,8 @@ type ModEnv = Map.Map ModName (UTCTime,[ModName])
--getAllFiles :: (MonadIO m,ErrorMonad m) => Options -> [InitPath] -> ModEnv -> FileName -> m [FullPath]
getAllFiles opts ps env file = do
-- read module headers from all files recursively
- ds <- liftM reverse $ get [] [] (justModuleName file)
- liftIO $ putIfVerb opts $ "all modules:" +++ show [name | (name,_,_,_,_,_) <- ds]
+ ds <- reverse `fmap` get [] [] (justModuleName file)
+ putIfVerb opts $ "all modules:" +++ show [name | (name,_,_,_,_,_) <- ds]
return $ paths ds
where
-- construct list of paths to read
@@ -99,13 +98,12 @@ getAllFiles opts ps env file = do
(file,gfTime,gfoTime) <- do
mb_gfFile <- getFilePath ps (gfFile name)
case mb_gfFile of
- Just gfFile -> do gfTime <- liftIO $ toUTCTime `fmap` getModificationTime gfFile
- mb_gfoTime <- liftIO $ catch (liftM Just $ toUTCTime `fmap` getModificationTime (gf2gfo opts gfFile))
- (\_->return Nothing)
+ Just gfFile -> do gfTime <- modtime gfFile
+ mb_gfoTime <- maybeIO $ modtime (gf2gfo opts gfFile)
return (gfFile, Just gfTime, mb_gfoTime)
Nothing -> do mb_gfoFile <- getFilePath (maybe id (:) (flag optGFODir opts) ps) (gfoFile name)
case mb_gfoFile of
- Just gfoFile -> do gfoTime <- liftIO $ toUTCTime `fmap` getModificationTime gfoFile
+ Just gfoFile -> do gfoTime <- modtime gfoFile
return (gfoFile, Nothing, Just gfoTime)
Nothing -> raise (render (text "File" <+> text (gfFile name) <+> text "does not exist." $$
text "searched in:" <+> vcat (map text ps)))
@@ -130,6 +128,8 @@ getAllFiles opts ps env file = do
("module name" +++ mname +++ "differs from file name" +++ name)
return (name,st,t,isJust gfTime,imps,dropFileName file)
+modtime path = liftIO $ getModificationTime path
+
isGFO :: FilePath -> Bool
isGFO = (== ".gfo") . takeExtensions