From 2e1b57878329eb6a1822ef43c190f8a2aaaa82b7 Mon Sep 17 00:00:00 2001 From: aarne Date: Thu, 26 Feb 2004 14:49:16 +0000 Subject: Improved make facility. --- src/GF/System/Arch.hs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/GF/System') 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 -- cgit v1.2.3