From 30c6a57ac9dfc3808a28bb2654912aa7460568c8 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sat, 30 Jun 2007 10:58:34 +0000 Subject: [PATCH] Add makeRelativeToCurrentDirectory Moved from the filepath package, which we now depend on. --- System/Directory.hs | 8 ++++++++ directory.cabal | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) 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 diff --git a/directory.cabal b/directory.cabal index eb3cfcb..929075c 100644 --- a/directory.cabal +++ b/directory.cabal @@ -15,5 +15,5 @@ include-dirs: include includes: HsDirectory.h install-includes: HsDirectory.h HsDirectoryConfig.h extensions: CPP, ForeignFunctionInterface -build-depends: base, old-time +build-depends: base, old-time, filepath -- 1.7.10.4