Changeset 15324
- Timestamp:
- 02/22/07 09:47:16 (21 months ago)
- Location:
- src/Pugs/Prim
- Files:
-
- 2 modified
-
FileTest.hs (modified) (2 diffs)
-
Match.hs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Prim/FileTest.hs
r14635 r15324 5 5 fileSize, sizeIsZero, 6 6 fileMTime, fileCTime, fileATime, 7 fileTestViaPerl5 7 8 ) where 8 9 import Pugs.Internals 10 import Pugs.Embed 11 import Pugs.Types 9 12 import Pugs.AST hiding (isWritable) 10 13 … … 42 45 fileATime :: Val -> Eval Val 43 46 fileATime = fileTime statFileATime 47 48 fileTestViaPerl5 :: String -> Val -> Eval Val 49 fileTestViaPerl5 testOp v = do 50 env <- ask 51 envSV <- liftIO $ mkEnv env 52 argSV <- fromVal v 53 subSV <- liftIO $ evalPerl5 ("sub { warn $_[0]; -" ++ testOp ++ " $_[0] }") envSV (enumCxt cxtItemAny) 54 rv <- runInvokePerl5 subSV nullSV [argSV] 55 return $ case rv of 56 VStr "" -> VBool False 57 VNum 1 -> VBool True 58 VInt 1 -> VBool True 59 _ -> rv 44 60 45 61 fileTime :: (FilePath -> IO Integer) -> Val -> Eval Val -
src/Pugs/Prim/Match.hs
r15297 r15324 141 141 "f" -> FileTest.isFile 142 142 "d" -> FileTest.isDirectory 143 [op] | op `elem` "oRWXOlpSbctugkTB" -> FileTest.fileTestViaPerl5 testOp 143 144 _ -> const $ die "Unknown file test operator" testOp 144 145 if isTrue
