Show
Ignore:
Timestamp:
11/03/06 05:30:51 (2 years ago)
Author:
allbery_b
svk:copy_cache_prev:
41990
Message:

AUTHORS: hello, world\n :)
src/Pugs/Compat.hs: added file time tests
src/Pugs/Internals.hs, src/Pugs/Prim.hs: abstract out guts of "time" for

use in $*BASETIME and file tests

src/Pugs/Run.hs: add $*BASETIME
src/Pugs/AST.hs: document _reserved and filterUserDefinedPad; add $*BASETIME

to _reserved

src/Pugs/Prim.hs: add file time operators -M, -C, -A
src/Pugs/Prim/FileTest.hs: add implementation of file time operators
t/operators/filetest.t: correct existing file time operator tests, add a few

more, add all of them to the plan

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim/FileTest.hs

    r10466 r14599  
    33    exists, isFile, isDirectory, 
    44    fileSize, sizeIsZero, 
     5    fileMTime, fileCTime, fileATime, 
    56) where 
    67import Pugs.Internals 
     
    3435sizeIsZero   :: Val -> Eval Val 
    3536sizeIsZero   = fileTestIO fileTestSizeIsZero 
     37fileMTime    :: Val -> Eval Val 
     38fileMTime    = fileTime statFileMTime 
     39fileCTime    :: Val -> Eval Val 
     40fileCTime    = fileTime statFileCTime 
     41fileATime    :: Val -> Eval Val 
     42fileATime    = fileTime statFileATime 
     43 
     44fileTime :: (FilePath -> IO Integer) -> Val -> Eval Val 
     45fileTime test f = do 
     46    t <- fileTestIO (fileTestDo test) f 
     47    if (t == undef) then return VUndef else do 
     48    t' <- fromVal t 
     49    b <- (readVar $ cast "$*BASETIME") >>= fromVal 
     50    return $ VRat $ (b - (pugsTimeSpec $ TOD t' 0)) / 86400 
    3651 
    3752fileTestIO :: (Value n) => (n -> IO Val) -> Val -> Eval Val 
     
    7489    n <- statFileSize f 
    7590    return $ if n == 0 then VBool True else VBool False 
     91 
     92fileTestDo :: (FilePath -> IO Integer) -> FilePath -> IO Val 
     93fileTestDo test f = test f >>= return . VInt