From: krasimir Date: Mon, 10 Jan 2005 00:03:04 +0000 (+0000) Subject: [project @ 2005-01-10 00:03:04 by krasimir] X-Git-Tag: nhc98-1-18-release~133 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=67fdfbc8044e247598d39e29cc0701f0068de955;p=ghc-base.git [project @ 2005-01-10 00:03:04 by krasimir] Add dropAbsolutePrefix function. (used in Cabal) --- diff --git a/System/FilePath.hs b/System/FilePath.hs index 3fead9b..e82ad25 100644 --- a/System/FilePath.hs +++ b/System/FilePath.hs @@ -26,6 +26,7 @@ module System.FilePath , changeFileExt , isRootedPath , isAbsolutePath + , dropAbsolutePrefix , pathParents , commonParent @@ -228,6 +229,17 @@ isAbsolutePath (c:_) | isPathSeparator c = True #endif isAbsolutePath _ = False +-- | If the function is applied to an absolute path then it returns a local path droping +-- the absolute prefix in the path. Under Windows the prefix is \"\\\", \"c:\" or \"c:\\\". Under +-- Unix the prefix is always \"/\". +dropAbsolutePrefix :: FilePath -> FilePath +dropAbsolutePrefix (c:cs) | isPathSeparator c = cs +#ifdef mingw32_TARGET_OS +dropAbsolutePrefix (_:':':c:cs) | isPathSeparator c = cs -- path with drive letter +dropAbsolutePrefix (_:':':cs) = cs +#endif +dropAbsolutePrefix cs = cs + -- | Gets this path and all its parents. -- The function is useful in case if you want to create -- some file but you aren\'t sure whether all directories