diff options
| author | aarne <unknown> | 2004-02-26 14:49:16 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2004-02-26 14:49:16 +0000 |
| commit | 2e1b57878329eb6a1822ef43c190f8a2aaaa82b7 (patch) | |
| tree | d7a85d0755a7c651e355f3315acd35f7d1a2feb5 /src/GF/System/Arch.hs | |
| parent | 13be0d6356a2f198e2ad5929c5896939da8e168f (diff) | |
Improved make facility.
Diffstat (limited to 'src/GF/System/Arch.hs')
| -rw-r--r-- | src/GF/System/Arch.hs | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/GF/System/Arch.hs b/src/GF/System/Arch.hs index 5fb963fec..ce1b78775 100644 --- a/src/GF/System/Arch.hs +++ b/src/GF/System/Arch.hs @@ -1,6 +1,6 @@ module Arch ( myStdGen, prCPU, selectLater, modifiedFiles, ModTime, getModTime,getNowTime, - welcomeArch, fetchCommand) where + welcomeArch, fetchCommand, laterModTime) where import Time import Random @@ -52,20 +52,31 @@ selectLater x y = do ty <- getModificationTime y return $ if tx < ty then y else x --- a file is considered as modified also if it has not been read yet +-- a file is considered modified also if it has not been read yet +-- new 23/2/2004: the environment ofs has just module names modifiedFiles :: [(FilePath,ModTime)] -> [FilePath] -> IO [FilePath] -modifiedFiles ofs fs = print (map fst ofs) >> filterM isModified fs where - isModified file = case lookup file ofs of +modifiedFiles ofs fs = do + filterM isModified fs + where + isModified file = case lookup (justModName file) ofs of Just to -> do - t <- getModTime file + t <- getModificationTime file return $ to < t _ -> return True + justModName = + reverse . takeWhile (/='/') . tail . dropWhile (/='.') . reverse + type ModTime = ClockTime -getModTime :: FilePath -> IO ModTime -getModTime = getModificationTime +laterModTime :: ModTime -> ModTime -> Bool +laterModTime = (>) + +getModTime :: FilePath -> IO (Maybe ModTime) +getModTime f = do + b <- doesFileExist f + if b then (getModificationTime f >>= return . Just) else return Nothing getNowTime :: IO ModTime getNowTime = getClockTime |
