unix-2.6.0.1: POSIX functionality

Portability | non-portable (requires POSIX)
Stability | provisional
Maintainer | libraries@haskell.org
Safe Haskell | Trustworthy

System.Posix.Directory.ByteString

Contents

- Creating and removing directories
- Reading directories
- The working dirctory

Description

String-based POSIX directory support

Synopsis

- createDirectory :: RawFilePath -> FileMode -> IO ()
- removeDirectory :: RawFilePath -> IO ()
- data DirStream
- openDirStream :: RawFilePath -> IO DirStream
- readDirStream :: DirStream -> IO RawFilePath
- rewindDirStream :: DirStream -> IO ()
- closeDirStream :: DirStream -> IO ()
- data DirStreamOffset
- tellDirStream :: DirStream -> IO DirStreamOffset
- seekDirStream :: DirStream -> DirStreamOffset -> IO ()
- getWorkingDirectory :: IO RawFilePath
- changeWorkingDirectory :: RawFilePath -> IO ()
- changeWorkingDirectoryFd :: Fd -> IO ()

# Creating and removing directories

createDirectory :: RawFilePath -> FileMode -> IO ()

`createDirectory dir mode` calls `mkdir` to create a new directory, `dir`, with permissions based on `mode`.

removeDirectory :: RawFilePath -> IO ()

# Reading directories

data DirStream

openDirStream :: RawFilePath -> IO DirStream

`openDirStream dir` calls `opendir` to obtain a directory stream for `dir`.

readDirStream :: DirStream -> IO RawFilePath

`readDirStream dp` calls `readdir` to obtain the next directory entry (`struct dirent`) for the open directory stream `dp`, and returns the `d_name` member of that structure.

rewindDirStream :: DirStream -> IO ()

`rewindDirStream dp` calls `rewinddir` to reposition the directory stream `dp` at the beginning of the directory.

closeDirStream :: DirStream -> IO ()

`closeDirStream dp` calls `closedir` to close the directory stream `dp`.

data DirStreamOffset

tellDirStream :: DirStream -> IO DirStreamOffset

seekDirStream :: DirStream -> DirStreamOffset -> IO ()

# The working dirctory

getWorkingDirectory :: IO RawFilePath

`getWorkingDirectory` calls `getcwd` to obtain the name of the current working directory.

changeWorkingDirectory :: RawFilePath -> IO ()

`changeWorkingDirectory dir` calls `chdir` to change the current working directory to `dir`.

changeWorkingDirectoryFd :: Fd -> IO ()