Copyright | (c) The University of Glasgow 2002 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | libraries@haskell.org |
Stability | provisional |
Portability | non-portable (requires POSIX) |
Safe Haskell | None |
Language | Haskell2010 |
PosixPath based POSIX directory support
Synopsis
- createDirectory :: PosixPath -> FileMode -> IO ()
- removeDirectory :: PosixPath -> IO ()
- data DirStream
- openDirStream :: PosixPath -> IO DirStream
- readDirStream :: DirStream -> IO PosixPath
- readDirStreamMaybe :: DirStream -> IO (Maybe PosixPath)
- rewindDirStream :: DirStream -> IO ()
- closeDirStream :: DirStream -> IO ()
- data DirStreamOffset
- tellDirStream :: DirStream -> IO DirStreamOffset
- seekDirStream :: DirStream -> DirStreamOffset -> IO ()
- getWorkingDirectory :: IO PosixPath
- changeWorkingDirectory :: PosixPath -> IO ()
- changeWorkingDirectoryFd :: Fd -> IO ()
Creating and removing directories
createDirectory :: PosixPath -> FileMode -> IO () Source #
createDirectory dir mode
calls mkdir
to
create a new directory, dir
, with permissions based on
mode
.
removeDirectory :: PosixPath -> IO () Source #
Reading directories
openDirStream :: PosixPath -> IO DirStream Source #
openDirStream dir
calls opendir
to obtain a
directory stream for dir
.
readDirStream :: DirStream -> IO PosixPath Source #
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.
Note that this function returns an empty filepath if the end of the
directory stream is reached. For a safer alternative use
readDirStreamMaybe
.
readDirStreamMaybe :: DirStream -> IO (Maybe PosixPath) Source #
readDirStreamMaybe dp
calls readdir
to obtain the
next directory entry (struct dirent
) for the open directory
stream dp
. It returns the d_name
member of that
structure wrapped in a Just d_name
if an entry was read and Nothing
if
the end of the directory stream was reached.
rewindDirStream :: DirStream -> IO () Source #
rewindDirStream dp
calls rewinddir
to reposition
the directory stream dp
at the beginning of the directory.
closeDirStream :: DirStream -> IO () Source #
closeDirStream dp
calls closedir
to close
the directory stream dp
.
data DirStreamOffset Source #
seekDirStream :: DirStream -> DirStreamOffset -> IO () Source #
The working directory
getWorkingDirectory :: IO PosixPath Source #
getWorkingDirectory
calls getcwd
to obtain the name
of the current working directory.
changeWorkingDirectory :: PosixPath -> IO () Source #
changeWorkingDirectory dir
calls chdir
to change
the current working directory to dir
.
changeWorkingDirectoryFd :: Fd -> IO () Source #