Changeset 10466 for src/Pugs/Compat.hs

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

* Change file tests to use native POSIX stats in preparation

of true chained tests.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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