X-Git-Url: http://git.megacz.com/?p=haskell-directory.git;a=blobdiff_plain;f=System%2FDirectory.hs;h=beed8798cca5fa154974083563baaaf4055361f4;hp=364f083549f07910316097b6d11807ecb9329008;hb=30c6a57ac9dfc3808a28bb2654912aa7460568c8;hpb=8a2b8790502da776df1486e7b366c68f33b1722f diff --git a/System/Directory.hs b/System/Directory.hs index 364f083..beed879 100644 --- a/System/Directory.hs +++ b/System/Directory.hs @@ -39,6 +39,7 @@ module System.Directory , copyFile -- :: FilePath -> FilePath -> IO () , canonicalizePath + , makeRelativeToCurrentDirectory , findExecutable -- * Existence tests @@ -67,6 +68,7 @@ module System.Directory import System.Directory.Internals import System.Environment ( getEnv ) +import System.FilePath import System.IO.Error import Control.Monad ( when, unless ) @@ -596,6 +598,12 @@ foreign import ccall unsafe "realpath" -> IO CString #endif +-- | 'makeRelative' the current directory. +makeRelativeToCurrentDirectory :: FilePath -> IO FilePath +makeRelativeToCurrentDirectory x = do + cur <- getCurrentDirectory + return $ makeRelative cur x + -- | Given an executable file name, searches for such file -- in the directories listed in system PATH. The returned value -- is the path to the found executable or Nothing if there isn't