projects
/
haskell-directory.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add makeRelativeToCurrentDirectory
[haskell-directory.git]
/
System
/
Directory.hs
diff --git
a/System/Directory.hs
b/System/Directory.hs
index
364f083
..
beed879
100644
(file)
--- a/
System/Directory.hs
+++ b/
System/Directory.hs
@@
-39,6
+39,7
@@
module System.Directory
, copyFile -- :: FilePath -> FilePath -> IO ()
, canonicalizePath
, copyFile -- :: FilePath -> FilePath -> IO ()
, canonicalizePath
+ , makeRelativeToCurrentDirectory
, findExecutable
-- * Existence tests
, findExecutable
-- * Existence tests
@@
-67,6
+68,7
@@
module System.Directory
import System.Directory.Internals
import System.Environment ( getEnv )
import System.Directory.Internals
import System.Environment ( getEnv )
+import System.FilePath
import System.IO.Error
import Control.Monad ( when, unless )
import System.IO.Error
import Control.Monad ( when, unless )
@@
-596,6
+598,12
@@
foreign import ccall unsafe "realpath"
-> IO CString
#endif
-> 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
-- | 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