úÎ!Œbˆè-      !"#$%&'()*+,© 2016 Julian OspaldBSD3"Julian Ospald <hasufell@posteo.de> experimentalportableSafeP‡D.hpath-filepathPath separator characterhpath-filepath*Check if a character is the path separator+\n -> (_chr n == '/') == isPathSeparator nhpath-filepathSearch path separatorhpath-filepath1Check if a character is the search path separator0\n -> (_chr n == ':') == isSearchPathSeparator nhpath-filepathFile extension separatorhpath-filepath4Check if a character is the file extension separator)\n -> (_chr n == '.') == isExtSeparator nhpath-filepath#Take a ByteString, split it on the  . Blank items are converted to .. Follows the recommendations in Fhttp://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html#splitSearchPath "File1:File2:File3"["File1","File2","File3"]$splitSearchPath "File1::File2:File3"["File1",".","File2","File3"]splitSearchPath ""["."]hpath-filepathGet a list of -s in the $PATH variable.hpath-filepathSplit a -# into a path+filename and extensionsplitExtension "file.exe"("file",".exe")splitExtension "file" ("file","")"splitExtension "/path/file.tar.gz"("/path/file.tar",".gz"):\path -> uncurry (BS.append) (splitExtension path) == path hpath-filepathGet the final extension from a -takeExtension "file.exe"".exe"takeExtension "file"""!takeExtension "/path/file.tar.gz"".gz" hpath-filepathChange a file's extensionJ\path -> let ext = takeExtension path in replaceExtension path ext == path hpath-filepath Drop the final extension from a -dropExtension "file.exe""file"dropExtension "file""file"!dropExtension "/path/file.tar.gz""/path/file.tar" hpath-filepathAdd an extension to a -addExtension "file" ".exe" "file.exe"addExtension "file.tar" ".gz" "file.tar.gz"addExtension "/path/" ".ext" "/path/.ext" hpath-filepath Check if a - has an extensionhasExtension "file"FalsehasExtension "file.tar"TruehasExtension "/path.part1/"Falsehpath-filepathOperator version of  hpath-filepathSplit a - on the first extension.#splitExtensions "/path/file.tar.gz"("/path/file",".tar.gz")<\path -> uncurry addExtension (splitExtensions path) == pathhpath-filepathRemove all extensions from a -"dropExtensions "/path/file.tar.gz" "/path/file"hpath-filepathTake all extensions from a -"takeExtensions "/path/file.tar.gz" ".tar.gz"hpath-filepath2Drop the given extension from a FilePath, and the "." preceding it. Returns .8 if the FilePath does not have the given extension, or /. and the part before the extension if it does.+This function can be more predictable than 3, especially if the filename might itself contain . characters."stripExtension "hs.o" "foo.x.hs.o" Just "foo.x""stripExtension "hi.o" "foo.x.hs.o"NothingstripExtension ".c.d" "a.b.c.d" Just "a.b" stripExtension ".c.d" "a.b..c.d" Just "a.b."stripExtension "baz" "foo.bar"NothingstripExtension "bar" "foobar"Nothing,\path -> stripExtension "" path == Just pathS\path -> dropExtension path == fromJust (stripExtension (takeExtension path) path)T\path -> dropExtensions path == fromJust (stripExtension (takeExtensions path) path)hpath-filepathSplit a - into (path,file).  is the inversesplitFileName "path/file.txt"("path/","file.txt")splitFileName "path/" ("path/","")splitFileName "file.txt"("./","file.txt")Y\path -> uncurry combine (splitFileName path) == path || fst (splitFileName path) == "./"hpath-filepathGet the file nametakeFileName "path/file.txt" "file.txt"takeFileName "path/"""hpath-filepathChange the file name9\path -> replaceFileName path (takeFileName path) == pathhpath-filepathDrop the file namedropFileName "path/file.txt""path/"dropFileName "file.txt""./"hpath-filepath/Get the file name, without a trailing extensiontakeBaseName "path/file.tar.gz" "file.tar"takeBaseName """"hpath-filepathChange the base name(replaceBaseName "path/file.tar.gz" "bob" "path/bob.gz"9\path -> replaceBaseName path (takeBaseName path) == pathhpath-filepathBGet the directory, moving up one level if it's already a directorytakeDirectory "path/file.txt""path"takeDirectory "file""."takeDirectory "/path/to/" "/path/to"takeDirectory "/path/to""/path"hpath-filepath$Change the directory component of a -e\path -> replaceDirectory path (takeDirectory path) `equalFilePath` path || takeDirectory path == "."hpath-filepathJoin two paths togethercombine "/" "file""/file"combine "/path/to" "file""/path/to/file"combine "file" "/absolute/path""/absolute/path"hpath-filepathOperator version of combinehpath-filepath'Split a path into a list of components:splitPath "/path/to/file.txt"["/","path/","to/","file.txt"]+\path -> BS.concat (splitPath path) == pathhpath-filepathJoin a split path back together*\path -> joinPath (splitPath path) == path!joinPath ["path","to","file.txt"]"path/to/file.txt"hpath-filepathLike , but without trailing slashes$splitDirectories "/path/to/file.txt"["/","path","to","file.txt"]splitDirectories ""[] hpath-filepath!Check if the last character of a - is 0.!hasTrailingPathSeparator "/path/"TruehasTrailingPathSeparator "/"True hasTrailingPathSeparator "/path"False!hpath-filepathAdd a trailing path separator. addTrailingPathSeparator "/path""/path/"!addTrailingPathSeparator "/path/""/path/"addTrailingPathSeparator "/""/""hpath-filepath Remove a trailing path separator"dropTrailingPathSeparator "/path/""/path"%dropTrailingPathSeparator "/path////""/path"dropTrailingPathSeparator "/""/"dropTrailingPathSeparator "//""/"#hpath-filepathNormalise a file. normalise "/file/\\test////""/file/\\test/"normalise "/file/./test" "/file/test"#normalise "/test/file/../bob/fred/""/test/file/../bob/fred/"normalise "../bob/fred/""../bob/fred/"normalise "./bob/fred/" "bob/fred/",normalise "./bob////.fred/./...///./..///#.""bob/.fred/.../../#." normalise ".""."normalise "./""./"normalise "./.""./"normalise "/./""/" normalise "/""/"normalise "bob/fred/." "bob/fred/"normalise "//home""/home"$hpath-filepathbContract a filename, based on a relative path. Note that the resulting path will never introduce ..+ paths, as the presence of symlinks means ../b may not reach a/b if it starts from a/c. For a worked example see  Vhttp://neilmitchell.blogspot.co.uk/2015/10/filepaths-are-subtle-symlinks-are-hard.htmlthis blog post./makeRelative "/directory" "/directory/file.ext" "file.ext" makeRelative "/Home" "/home/bob" "/home/bob")makeRelative "/home/" "/home/bob/foo/bar" "bob/foo/bar"makeRelative "/fred" "bob""bob"+makeRelative "/file/test" "/file/test/fred""fred",makeRelative "/file/test" "/file/test/fred/""fred/"*makeRelative "some/path" "some/path/a/b/c""a/b/c"\p -> makeRelative p p == "."E\p -> makeRelative (takeDirectory p) p `equalFilePath` takeFileName p]prop x y -> equalFilePath x y || (isRelative x && makeRelative y x == x) || equalFilePath (y  / makeRelative y x) x%hpath-filepathbEquality of two filepaths. The filepaths are normalised and trailing path separators are dropped.equalFilePath "foo" "foo"TrueequalFilePath "foo" "foo/"TrueequalFilePath "foo" "./foo"TrueequalFilePath "" ""TrueequalFilePath "foo" "/foo"FalseequalFilePath "foo" "FOO"FalseequalFilePath "foo" "../foo"False\p -> equalFilePath p p&hpath-filepathCheck if a path is relative+\path -> isRelative path /= isAbsolute path'hpath-filepathCheck if a path is absoluteisAbsolute "/path"TrueisAbsolute "path"False isAbsolute ""False(hpath-filepath:Is a FilePath valid, i.e. could you create a file like it? isValid ""False isValid "\0"FalseisValid "/random_ path:*"True)hpath-filepathKTake a FilePath and make it valid; does not change already valid FilePaths. makeValid """_"makeValid "file\0name" "file_name">\p -> if isValid p then makeValid p == p else makeValid p /= p\p -> isValid (makeValid p)*hpath-filepath@Is the given path a valid filename? This includes "." and "..".isFileName "lal"TrueisFileName "."TrueisFileName ".."True isFileName ""FalseisFileName "\0"FalseisFileName "/random_ path:*"False+hpath-filepath7Check if the filepath has any parent directories in it.hasParentDir "/.."TruehasParentDir "foo/bar/.."TruehasParentDir "foo/../bar/."TruehasParentDir "foo/bar"FalsehasParentDir "foo"FalsehasParentDir ""FalsehasParentDir ".."False,hpath-filepath"Whether the file is a hidden file.hiddenFile ".foo"TruehiddenFile "..foo.bar"TruehiddenFile "some/path/.bar"TruehiddenFile "..."TruehiddenFile "dod.bar"FalsehiddenFile "."FalsehiddenFile ".."False hiddenFile ""False1hpath-filepath0Combine two paths, assuming rhs is NOT absolute.;23456789:;<=>-  !"#$%&'()*+,-  !"#$%&'()*+,?      !"#$%&'()*+,-./012342352678/09/0:/0;/0</0=/0>/0?/0@/0A/0B/0C/0D/0EF,hpath-filepath-0.10.0-9xl6XFjwkvtEHFopgxdylwSystem.Posix.FilePath pathSeparatorisPathSeparatorsearchPathSeparatorisSearchPathSeparator extSeparatorisExtSeparatorsplitSearchPath getSearchPathsplitExtension takeExtensionreplaceExtension dropExtension addExtension hasExtension<.>splitExtensionsdropExtensionstakeExtensionsstripExtension splitFileName takeFileNamereplaceFileName dropFileName takeBaseNamereplaceBaseName takeDirectoryreplaceDirectorycombine splitPathjoinPathsplitDirectorieshasTrailingPathSeparatoraddTrailingPathSeparatordropTrailingPathSeparator normalise makeRelative equalFilePath isRelative isAbsoluteisValid makeValid isFileName hasParentDir hiddenFile unix-2.7.2.2 System.Posix.ByteString.FilePath RawFilePathbase GHC.MaybeNothingJustGHC.Real/ combineRawthrowErrnoPathIfMinus1_throwErrnoPathIfMinus1throwErrnoPathIfNullthrowErrnoPathIf_throwErrnoPathIfthrowErrnoPaththrowErrnoPathIfRetrythrowErrnoPathIfNullRetrythrowErrnoPathIfMinus1Retry_throwErrnoPathIfMinus1RetrypeekFilePathLen peekFilePath withFilePath