Changeset 10466

Show
Ignore:
Timestamp:
06/03/06 08:12:31 (2 years ago)
Author:
audreyt
Message:

* Change file tests to use native POSIX stats in preparation

of true chained tests.

Location:
src/Pugs
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/AST/Internals.hs

    r10323 r10466  
    12531253mkCompUnit _ pad ast = MkCompUnit compUnitVersion pad ast 
    12541254 
     1255compUnitVersion :: Int 
    12551256compUnitVersion = 1 
    12561257 
  • src/Pugs/Compat.hs

    r8934 r10466  
    1 {-# OPTIONS_GHC -fglasgow-exts -fvia-C -optc-w -fno-warn-orphans -cpp #-} 
     1{-# OPTIONS_GHC -fglasgow-exts -fvia-C -optc-w -fno-warn-orphans -cpp -fno-warn-deprecations #-} 
    22 
    33{-| 
     
    4343    closeDirStream, 
    4444    executeFile',        -- the prime signifies we changed signature. 
     45    getCurrentDirectory, 
     46    setCurrentDirectory, 
     47    doesFileExist, 
     48    doesDirectoryExist, 
     49    doesExist, 
    4550) where 
    4651 
     
    4954 
    5055#ifdef PUGS_HAVE_POSIX 
     56import System.Posix.Files 
    5157import System.Posix.Process 
    5258import System.Posix.Env hiding (getEnvironment) 
    53 import System.Posix.Files 
    5459import System.Posix.Directory 
    5560import System.Posix.User 
     
    6166import qualified System.Posix.Signals 
    6267 
     68doesExist :: FilePath -> IO Bool 
     69doesExist = fileExist 
     70 
     71doesFileExist :: FilePath -> IO Bool 
     72doesFileExist f = do 
     73    rv <- (fmap isRegularFile . getFileStatus) f 
     74    return rv 
     75 
     76doesDirectoryExist :: FilePath -> IO Bool 
     77doesDirectoryExist = fmap isDirectory . getFileStatus 
     78 
     79getCurrentDirectory :: IO FilePath 
     80getCurrentDirectory = getWorkingDirectory 
     81 
     82setCurrentDirectory :: FilePath -> IO () 
     83setCurrentDirectory = changeWorkingDirectory 
     84 
    6385executeFile' :: FilePath -> Bool -> [String] -> Maybe [(String, String)] -> IO ExitCode 
    6486executeFile' prog search args env = do 
     
    87109import Debug.Trace 
    88110import qualified System.Environment 
     111import System.Directory (getCurrentDirectory, setCurrentDirectory, doesFileExist, doesDirectoryExist) 
    89112import IO 
    90113import System.IO 
     
    245268executeFile' _ _ _ _ = failWithIncomplete "executeFile" 
    246269 
     270doesExist :: FilePath -> IO Bool 
     271doesExist f = do 
     272    rv <- doesFileExist f 
     273    if rv then return rv else doesDirectoryExist f 
     274 
    247275#endif 
    248276 
  • src/Pugs/Internals.hs

    r10113 r10466  
    1 {-# OPTIONS_GHC -fglasgow-exts -fno-warn-orphans -fno-full-laziness -fno-cse #-} 
     1{-# OPTIONS_GHC -fglasgow-exts -fno-warn-orphans -fno-full-laziness -fno-cse -fno-warn-deprecations #-} 
    22 
    33{-| 
     
    1515 
    1616module Pugs.Internals ( 
    17     module UTF8, 
     17    module Control.Concurrent, 
     18    module Control.Concurrent.STM, 
     19    module Control.Exception, 
     20    module Control.Monad.Error, 
     21    module Control.Monad.RWS, 
     22    module Data.Array, 
     23    module Data.Bits, 
     24    module Data.Char, 
     25    module Data.Complex, 
     26    module Data.Dynamic, 
     27    module Data.Either, 
     28    module Data.FunctorM, 
     29    module Data.IntMap, 
     30    module Data.List, 
     31    module Data.Map, 
     32    module Data.Maybe, 
     33    module Data.Ratio, 
     34    module Data.Set, 
     35    module Data.Tree, 
     36    module Data.Unique, 
     37    module Data.Word, 
     38    module Debug.Trace, 
     39    module Network, 
    1840    module Pugs.Compat, 
    1941    module RRegex, 
    2042    module RRegex.Syntax, 
    21     module Data.Char, 
    22     module Data.Dynamic, 
    23     module Data.Unique, 
    24     module Data.FunctorM, 
    25     module Control.Exception, 
     43    module System.Cmd, 
     44    module System.Directory, 
    2645    module System.Environment, 
    27     module System.Random, 
     46    module System.Exit, 
    2847    module System.IO, 
     48    module System.IO.Error, 
    2949    module System.IO.Unsafe, 
    30     module System.IO.Error, 
    31     module System.Exit, 
    32     module System.Time, 
    33     module System.Directory, 
    34     module System.Cmd, 
    35     module System.Process, 
    3650    module System.Mem, 
    3751    module System.Mem.Weak, 
    38     module Control.Monad.RWS, 
    39     module Control.Monad.Error, 
    40     module Control.Concurrent, 
    41     module Control.Concurrent.STM, 
    42     module Data.Array, 
    43     module Data.Bits, 
    44     module Data.List, 
    45     module Data.Either, 
    46     module Data.Word, 
    47     module Data.Ratio, 
    48     module Data.Tree, 
    49     module Data.Maybe, 
    50     module Data.Complex, 
    51     module Data.Set, 
    52     module Data.Map, 
    53     module Data.IntMap, 
    54     module Debug.Trace, 
    55     module Network, 
     52    module System.Process, 
     53    module System.Random, 
     54    module System.Time, 
     55    module UTF8, 
    5656    internalError, 
    5757    split, 
     
    9898import System.IO.Unsafe 
    9999import System.IO.Error (ioeGetErrorString, isUserError) 
    100 import System.Directory 
    101100import System.Mem 
    102101import System.Mem.Weak 
     102import System.Directory (Permissions(..), getPermissions, getTemporaryDirectory, createDirectory, removeDirectory, removeFile, getDirectoryContents) 
    103103import Control.Exception (catchJust, errorCalls) 
    104104import Control.Monad.RWS 
  • src/Pugs/Prim/Eval.hs

    r10301 r10466  
    1717import Pugs.Config 
    1818import Pugs.Prim.Keyed 
    19 import qualified Data.ByteString as Str 
    2019import DrIFT.YAML 
    2120import Data.Yaml.Syck 
    22  
    23 -- type Str = Str.ByteString 
    24  
    2521 
    2622data EvalError = EvalErrorFatal 
  • src/Pugs/Prim/FileTest.hs

    r3372 r10466  
    5959 
    6060fileTestExists :: FilePath -> IO Val 
    61 fileTestExists f = do 
    62     b1 <- doesFileExist f 
    63     b2 <- doesDirectoryExist f 
    64     return $ valFromBool f (b1 || b2) 
     61fileTestExists f = doesExist f >>= return . (valFromBool f) 
    6562 
    6663fileTestIsFile :: FilePath -> IO Val