LIB/GTK: remove the rest of the directory package

This commit is contained in:
2015-12-27 19:26:58 +01:00
parent aba62f03f2
commit 54af33f3a7
6 changed files with 55 additions and 47 deletions

View File

@@ -45,11 +45,6 @@ import Foreign.C.Error
, Errno
)
import IO.Utils
import System.Directory
(
doesDirectoryExist
, doesFileExist
)
import System.FilePath
(
equalFilePath
@@ -151,3 +146,26 @@ catchErrno en a1 a2 =
if errno == en
then a2
else ioError e
handleIOError :: (IOError -> IO a) -> IO a -> IO a
handleIOError a1 a2 = catchIOError a2 a1
-- |Checks if the given file exists and is not a directory. This follows
-- symlinks, but will return True if the symlink is broken.
doesFileExist :: FilePath -> IO Bool
doesFileExist fp =
handleIOError (\_ -> return False) $ do
fs <- catchIOError (PF.getFileStatus fp) $ \_ ->
PF.getSymbolicLinkStatus fp
return $ not . PF.isDirectory $ fs
-- |Checks if the given file exists and is a directory. This follows
-- symlinks, but will return False if the symlink is broken.
doesDirectoryExist :: FilePath -> IO Bool
doesDirectoryExist fp =
handleIOError (\_ -> return False) $ do
fs <- PF.getFileStatus fp
return $ PF.isDirectory fs