openDirStream :: FilePath -> IO DirStream
openDirStream dir calls opendir
to obtain a
directory stream for dir.
readDirStream :: DirStream -> IO String
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.
The operation may fail with:
End of file has been reached.
Various other causes.
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.
getWorkingDirectory :: IO FilePath
getWorkingDirectory
calls getcwd
to obtain the name
of the current working directory.
changeWorkingDirectory :: FilePath -> IO ()
changeWorkingDirectory dir calls chdir
to change
the current working directory to dir.
nullFileMode :: FileMode -- --------- ownerReadMode :: FileMode -- r-------- ownerWriteMode :: FileMode -- -w------- ownerExecuteMode :: FileMode -- --x------ groupReadMode :: FileMode -- ---r----- groupWriteMode :: FileMode -- ----w---- groupExecuteMode :: FileMode -- -----x--- otherReadMode :: FileMode -- ------r-- otherWriteMode :: FileMode -- -------w- otherExecuteMode :: FileMode -- --------x setUserIDMode :: FileMode -- --S------ setGroupIDMode :: FileMode -- -----S--- stdFileMode :: FileMode -- rw-rw-rw- ownerModes :: FileMode -- rwx------ groupModes :: FileMode -- ---rwx--- otherModes :: FileMode -- ------rwx accessModes :: FileMode -- rwxrwxrwx unionFileModes :: FileMode -> FileMode -> FileMode intersectFileModes :: FileMode -> FileMode -> FileMode stdInput :: Fd stdInput = intToFd 0 stdOutput :: Fd stdOutput = intToFd 1 stdError :: Fd stdError = intToFd 2 data OpenFileFlags = OpenFileFlags { append :: Bool, exclusive :: Bool, noctty :: Bool, nonBlock :: Bool, trunc :: Bool } openFd :: FilePath -> OpenMode -> Maybe FileMode -- Just x => O_CREAT, Nothing => must exist -> OpenFileFlags -> IO Fd
openFd path acc mode (OpenFileFlags app excl noctty nonblock trunc) calls
open
to obtain a Fd for the file path with access
mode acc. If mode is Just m, the O_CREAT
flag is
set and the file's permissions will be based on m if it does not
already exist; otherwise, the O_CREAT
flag is not set. The
arguments app, excl, noctty, nonblock, and
trunc control whether or not the flags O_APPEND
,
O_EXCL
, O_NOCTTY
, O_NONBLOCK
, and O_TRUNC
are set,
respectively.
createFile :: FilePath -> FileMode -> IO Fd
createFile path mode calls creat
to obtain a Fd
for file path, which will be created with permissions based on
mode if it does not already exist.
setFileCreationMask :: FileMode -> IO FileMode
setFileCreationMask mode calls umask
to set
the process's file creation mask to mode. The previous file
creation mask is returned.
createLink :: FilePath -> FilePath -> IO ()
createLink old new calls link
to create a
new path, new, linked to an existing file, old.
createDirectory :: FilePath -> FileMode -> IO ()
createDirectory dir mode calls mkdir
to
create a new directory, dir, with permissions based on
mode.
createNamedPipe :: FilePath -> FileMode -> IO ()
createNamedPipe fifo mode calls mkfifo
to
create a new named pipe, fifo, with permissions based on
mode.
removeLink :: FilePath -> IO ()
removeLink path calls unlink
to remove the link
named path.
removeDirectory :: FilePath -> IO ()
removeDirectory dir calls rmdir
to remove the
directory named dir.
rename :: FilePath -> FilePath -> IO ()
rename old new calls rename
to rename a
file or directory from old to new.
fileMode :: FileStatus -> FileMode fileID :: FileStatus -> FileID deviceID :: FileStatus -> DeviceID linkCount :: FileStatus -> LinkCount fileOwner :: FileStatus -> UserID fileGroup :: FileStatus -> GroupID fileSize :: FileStatus -> FileOffset accessTime :: FileStatus -> EpochTime modificationTime :: FileStatus -> EpochTime statusChangeTime :: FileStatus -> EpochTime isDirectory :: FileStatus -> Bool isCharacterDevice :: FileStatus -> Bool isBlockDevice :: FileStatus -> Bool isRegularFile :: FileStatus -> Bool isNamedPipe :: FileStatus -> Bool getFileStatus :: FilePath -> IO FileStatus
getFileStatus path calls stat
to get the
FileStatus information for the file path.
getFdStatus :: Fd -> IO FileStatus
getFdStatus fd calls fstat
to get the
FileStatus information for the file associated with
Fd fd.
queryAccess :: FilePath -> Bool -> Bool -> Bool -> IO Bool
queryAccess path r w x calls access
to test the access
permissions for file path. The three arguments, r, w,
and x control whether or not access
is called with
R_OK
, W_OK
, and X_OK
respectively.
queryFile :: FilePath -> IO Bool
queryFile path calls access
with F_OK
to test for the
existence for file path.
setFileMode :: FilePath -> FileMode -> IO ()
setFileMode path mode calls chmod
to set the
permission bits associated with file path to mode.
setOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO ()
setOwnerAndGroup path uid gid calls chown
to
set the UserID and GroupID associated with file
path to uid and gid, respectively.
setFileTimes :: FilePath -> EpochTime -> EpochTime -> IO ()
setFileTimes path atime mtime calls utime
to
set the access and modification times associated with file
path to atime and mtime, respectively.
touchFile :: FilePath -> IO ()
touchFile path calls utime
to
set the access and modification times associated with file
path to the current time.
getPathVar :: PathVar -> FilePath -> IO Limit
getPathVar var path calls pathconf
to obtain the
dynamic value of the requested configurable file limit or option associated
with file or directory path. For
defined file limits, getPathVar
returns the associated
value. For defined file options, the result of getPathVar
is undefined, but not failure.
The operation may fail with:
The requested file limit or option is undefined.
Various other causes.
getFdVar :: PathVar -> Fd -> IO Limit
getFdVar var fd calls fpathconf
to obtain the
dynamic value of the requested configurable file limit or option associated
with the file or directory attached to the open channel fd.
For defined file limits, getFdVar
returns the associated
value. For defined file options, the result of getFdVar
is undefined, but not failure.
The operation may fail with:
The requested file limit or option is undefined.
Various other causes.