-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | POSIX filepath/directory functionality
--   
--   This package gives access to certain POSIX-based Filepath/Directory
--   services.
--   
--   The package is not supported under Windows (except under Cygwin).
@package posix-paths
@version 0.2.1.5

module System.Posix.Directory.Foreign
newtype DirType
DirType :: Int -> DirType
data Flags
Flags :: Int -> Flags
UnsupportedFlag :: String -> Flags
unFlags :: Flags -> Int

-- | Returns <tt>True</tt> if posix-paths was compiled with support for the
--   provided flag. (As of this writing, the only flag for which this check
--   may be necessary is <a>oCloexec</a>; all other flags will always yield
--   <tt>True</tt>.)
isSupported :: Flags -> Bool

-- | <tt>O_CLOEXEC</tt> is not supported on every POSIX platform. Use
--   <tt><a>isSupported</a> oCloexec</tt> to determine if support for
--   <tt>O_CLOEXEC</tt> was compiled into your version of posix-paths. (If
--   not, using <tt>oCloexec</tt> will throw an exception.)
oCloexec :: Flags
dtBlk :: DirType
oAppend :: Flags
dtChr :: DirType
pathMax :: Int
oAsync :: Flags
dtDir :: DirType
oCreat :: Flags
dtFifo :: DirType
unionFlags :: [Flags] -> CInt
dtLnk :: DirType
oDirectory :: Flags
oExcl :: Flags
dtReg :: DirType
oNoctty :: Flags
dtSock :: DirType
oNofollow :: Flags
dtUnknown :: DirType
oNonblock :: Flags
oRdonly :: Flags
oSync :: Flags
oTrunc :: Flags
instance GHC.Show.Show System.Posix.Directory.Foreign.Flags
instance GHC.Classes.Eq System.Posix.Directory.Foreign.Flags
instance GHC.Show.Show System.Posix.Directory.Foreign.DirType
instance GHC.Classes.Eq System.Posix.Directory.Foreign.DirType


-- | The equivalent of <a>System.FilePath</a> on raw (byte string) file
--   paths.
--   
--   Not all functions of <a>System.FilePath</a> are implemented yet. Feel
--   free to contribute!
module System.Posix.FilePath

-- | Path separator character
pathSeparator :: Word8

-- | Check if a character is the path separator
--   
--   <pre>
--   \n -&gt;  (_chr n == '/') == isPathSeparator n
--   </pre>
isPathSeparator :: Word8 -> Bool

-- | Search path separator
searchPathSeparator :: Word8

-- | Check if a character is the search path separator
--   
--   <pre>
--   \n -&gt; (_chr n == ':') == isSearchPathSeparator n
--   </pre>
isSearchPathSeparator :: Word8 -> Bool

-- | File extension separator
extSeparator :: Word8

-- | Check if a character is the file extension separator
--   
--   <pre>
--   \n -&gt; (_chr n == '.') == isExtSeparator n
--   </pre>
isExtSeparator :: Word8 -> Bool

-- | Split a <a>RawFilePath</a> into a path+filename and extension
--   
--   <pre>
--   &gt;&gt;&gt; splitExtension "file.exe"
--   ("file",".exe")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; splitExtension "file"
--   ("file","")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; splitExtension "/path/file.tar.gz"
--   ("/path/file.tar",".gz")
--   </pre>
--   
--   <pre>
--   \path -&gt; uncurry (BS.append) (splitExtension path) == path
--   </pre>
splitExtension :: RawFilePath -> (RawFilePath, ByteString)

-- | Get the final extension from a <a>RawFilePath</a>
--   
--   <pre>
--   &gt;&gt;&gt; takeExtension "file.exe"
--   ".exe"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; takeExtension "file"
--   ""
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; takeExtension "/path/file.tar.gz"
--   ".gz"
--   </pre>
takeExtension :: RawFilePath -> ByteString

-- | Change a file's extension
--   
--   <pre>
--   \path -&gt; let ext = takeExtension path in replaceExtension path ext == path
--   </pre>
replaceExtension :: RawFilePath -> ByteString -> RawFilePath

-- | Drop the final extension from a <a>RawFilePath</a>
--   
--   <pre>
--   &gt;&gt;&gt; dropExtension "file.exe"
--   "file"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; dropExtension "file"
--   "file"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; dropExtension "/path/file.tar.gz"
--   "/path/file.tar"
--   </pre>
dropExtension :: RawFilePath -> RawFilePath

-- | Add an extension to a <a>RawFilePath</a>
--   
--   <pre>
--   &gt;&gt;&gt; addExtension "file" ".exe"
--   "file.exe"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; addExtension "file.tar" ".gz"
--   "file.tar.gz"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; addExtension "/path/" ".ext"
--   "/path/.ext"
--   </pre>
addExtension :: RawFilePath -> ByteString -> RawFilePath

-- | Check if a <a>RawFilePath</a> has an extension
--   
--   <pre>
--   &gt;&gt;&gt; hasExtension "file"
--   False
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; hasExtension "file.tar"
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; hasExtension "/path.part1/"
--   False
--   </pre>
hasExtension :: RawFilePath -> Bool

-- | Operator version of <a>addExtension</a>
(<.>) :: RawFilePath -> ByteString -> RawFilePath

-- | Split a <a>RawFilePath</a> on the first extension
--   
--   <pre>
--   &gt;&gt;&gt; splitExtensions "/path/file.tar.gz"
--   ("/path/file",".tar.gz")
--   </pre>
--   
--   <pre>
--   \path -&gt; uncurry addExtension (splitExtensions path) == path
--   </pre>
splitExtensions :: RawFilePath -> (RawFilePath, ByteString)

-- | Remove all extensions from a <a>RawFilePath</a>
--   
--   <pre>
--   &gt;&gt;&gt; dropExtensions "/path/file.tar.gz"
--   "/path/file"
--   </pre>
dropExtensions :: RawFilePath -> RawFilePath

-- | Take all extensions from a <a>RawFilePath</a>
--   
--   <pre>
--   &gt;&gt;&gt; takeExtensions "/path/file.tar.gz"
--   ".tar.gz"
--   </pre>
takeExtensions :: RawFilePath -> ByteString

-- | Split a <a>RawFilePath</a> into (path,file). <a>combine</a> is the
--   inverse
--   
--   <pre>
--   &gt;&gt;&gt; splitFileName "path/file.txt"
--   ("path/","file.txt")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; splitFileName "path/"
--   ("path/","")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; splitFileName "file.txt"
--   ("./","file.txt")
--   </pre>
--   
--   <pre>
--   \path -&gt; uncurry combine (splitFileName path) == path || fst (splitFileName path) == "./"
--   </pre>
splitFileName :: RawFilePath -> (RawFilePath, RawFilePath)

-- | Get the file name
--   
--   <pre>
--   &gt;&gt;&gt; takeFileName "path/file.txt"
--   "file.txt"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; takeFileName "path/"
--   ""
--   </pre>
takeFileName :: RawFilePath -> RawFilePath

-- | Change the file name
--   
--   <pre>
--   \path -&gt; replaceFileName path (takeFileName path) == path
--   </pre>
replaceFileName :: RawFilePath -> ByteString -> RawFilePath

-- | Drop the file name
--   
--   <pre>
--   &gt;&gt;&gt; dropFileName "path/file.txt"
--   "path/"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; dropFileName "file.txt"
--   "./"
--   </pre>
dropFileName :: RawFilePath -> RawFilePath

-- | Get the file name, without a trailing extension
--   
--   <pre>
--   &gt;&gt;&gt; takeBaseName "path/file.tar.gz"
--   "file.tar"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; takeBaseName ""
--   ""
--   </pre>
takeBaseName :: RawFilePath -> ByteString

-- | Change the base name
--   
--   <pre>
--   &gt;&gt;&gt; replaceBaseName "path/file.tar.gz" "bob"
--   "path/bob.gz"
--   </pre>
--   
--   <pre>
--   \path -&gt; replaceBaseName path (takeBaseName path) == path
--   </pre>
replaceBaseName :: RawFilePath -> ByteString -> RawFilePath

-- | Get the directory, moving up one level if it's already a directory
--   
--   <pre>
--   &gt;&gt;&gt; takeDirectory "path/file.txt"
--   "path"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; takeDirectory "file"
--   "."
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; takeDirectory "/path/to/"
--   "/path/to"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; takeDirectory "/path/to"
--   "/path"
--   </pre>
takeDirectory :: RawFilePath -> RawFilePath

-- | Change the directory component of a <a>RawFilePath</a>
--   
--   <pre>
--   \path -&gt; replaceDirectory path (takeDirectory path) `_equalFilePath` path || takeDirectory path == "."
--   </pre>
replaceDirectory :: RawFilePath -> ByteString -> RawFilePath

-- | Join two paths together
--   
--   <pre>
--   &gt;&gt;&gt; combine "/" "file"
--   "/file"
--   
--   &gt;&gt;&gt; combine "/path/to" "file"
--   "/path/to/file"
--   
--   &gt;&gt;&gt; combine "file" "/absolute/path"
--   "/absolute/path"
--   </pre>
combine :: RawFilePath -> RawFilePath -> RawFilePath

-- | Operator version of combine
(</>) :: RawFilePath -> RawFilePath -> RawFilePath

-- | Split a path into a list of components:
--   
--   <pre>
--   &gt;&gt;&gt; splitPath "/path/to/file.txt"
--   ["/","path/","to/","file.txt"]
--   </pre>
--   
--   <pre>
--   \path -&gt; BS.concat (splitPath path) == path
--   </pre>
splitPath :: RawFilePath -> [RawFilePath]

-- | Join a split path back together
--   
--   <pre>
--   \path -&gt; joinPath (splitPath path) == path
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; joinPath ["path","to","file.txt"]
--   "path/to/file.txt"
--   </pre>
joinPath :: [RawFilePath] -> RawFilePath

-- | Like <a>splitPath</a>, but without trailing slashes
--   
--   <pre>
--   &gt;&gt;&gt; splitDirectories "/path/to/file.txt"
--   ["/","path","to","file.txt"]
--   
--   &gt;&gt;&gt; splitDirectories ""
--   []
--   </pre>
splitDirectories :: RawFilePath -> [RawFilePath]

-- | Check if the last character of a <a>RawFilePath</a> is <a>/</a>,
--   unless it's the root.
--   
--   <pre>
--   &gt;&gt;&gt; hasTrailingPathSeparator "/path/"
--   True
--   
--   &gt;&gt;&gt; hasTrailingPathSeparator "/"
--   False
--   </pre>
hasTrailingPathSeparator :: RawFilePath -> Bool

-- | Add a trailing path separator.
--   
--   <pre>
--   &gt;&gt;&gt; addTrailingPathSeparator "/path"
--   "/path/"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; addTrailingPathSeparator "/path/"
--   "/path/"
--   </pre>
addTrailingPathSeparator :: RawFilePath -> RawFilePath

-- | Remove a trailing path separator
--   
--   <pre>
--   &gt;&gt;&gt; dropTrailingPathSeparator "/path/"
--   "/path"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; dropTrailingPathSeparator "/"
--   "/"
--   </pre>
dropTrailingPathSeparator :: RawFilePath -> RawFilePath

-- | Check if a path is relative
--   
--   <pre>
--   \path -&gt; isRelative path /= isAbsolute path
--   </pre>
isRelative :: RawFilePath -> Bool

-- | Check if a path is absolute
--   
--   <pre>
--   &gt;&gt;&gt; isAbsolute "/path"
--   True
--   
--   &gt;&gt;&gt; isAbsolute "path"
--   False
--   
--   &gt;&gt;&gt; isAbsolute ""
--   False
--   </pre>
isAbsolute :: RawFilePath -> Bool

module System.Posix.Directory.Traversals
getDirectoryContents :: RawFilePath -> IO [(DirType, RawFilePath)]

-- | Get all files from a directory and its subdirectories.
--   
--   Upon entering a directory, <a>allDirectoryContents</a> will get all
--   entries strictly. However the returned list is lazy in that
--   directories will only be accessed on demand.
allDirectoryContents :: RawFilePath -> IO [RawFilePath]

-- | Get all files from a directory and its subdirectories strictly.
allDirectoryContents' :: RawFilePath -> IO [RawFilePath]

-- | Recursively apply the <tt>action</tt> to the parent directory and all
--   files/subdirectories.
--   
--   This function allows for memory-efficient traversals.
traverseDirectory :: (s -> RawFilePath -> IO s) -> s -> RawFilePath -> IO s
readDirEnt :: DirStream -> IO (DirType, RawFilePath)
packDirStream :: Ptr CDir -> DirStream
unpackDirStream :: DirStream -> Ptr CDir

-- | return the canonicalized absolute pathname
--   
--   like canonicalizePath, but uses realpath(3)
realpath :: RawFilePath -> IO RawFilePath
