Add makeRelativeToCurrentDirectory
authorIan Lynagh <igloo@earth.li>
Sat, 30 Jun 2007 10:58:34 +0000 (10:58 +0000)
committerIan Lynagh <igloo@earth.li>
Sat, 30 Jun 2007 10:58:34 +0000 (10:58 +0000)
Moved from the filepath package, which we now depend on.

System/Directory.hs
directory.cabal

index 364f083..beed879 100644 (file)
@@ -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
index eb3cfcb..929075c 100644 (file)
@@ -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