X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FFilePath.hs;h=4ae4a88c61adda2697a538909c4eb13ae7072913;hb=51f27f26931c97ab4965806ef08842be4465e83c;hp=3fead9be87f0da048bc1b4a3ac453c8c266febe3;hpb=bb101834420322740e520292b34ef5a8b31ddc8b;p=ghc-base.git diff --git a/System/FilePath.hs b/System/FilePath.hs index 3fead9b..4ae4a88 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,18 @@ isAbsolutePath (c:_) | isPathSeparator c = True #endif isAbsolutePath _ = False +-- | If the function is applied to an absolute path then it returns a +-- local path obtained by dropping the absolute prefix from 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