{-# LINE 1 "System/Posix/IO/PosixString.hsc" #-}------------------------------------------------------------------------------- |-- Module : System.Posix.IO.PosixString-- 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)---- POSIX IO support. These types and functions correspond to the unix-- functions open(2), close(2), etc. For more portable functions-- which are more like fopen(3) and friends from stdio.h, see-- "System.IO".-------------------------------------------------------------------------------moduleSystem.Posix.IO.PosixString(-- * Input \/ Output-- ** Standard file descriptorsstdInput ,stdOutput ,stdError ,-- ** Opening and closing filesOpenMode (..),OpenFileFlags (..),defaultFileFlags ,openFd ,openFdAt ,createFile ,createFileAt ,closeFd ,-- ** Reading\/writing data-- |Programmers using the 'fdRead' and 'fdWrite' API should be aware that-- EAGAIN exceptions may occur for non-blocking IO!fdRead ,fdWrite ,fdReadBuf ,fdWriteBuf ,-- ** SeekingfdSeek ,-- ** File optionsFdOption (..),queryFdOption ,setFdOption ,-- ** LockingFileLock ,LockRequest (..),getLock ,setLock ,waitToSetLock ,-- ** PipescreatePipe ,-- ** Duplicating file descriptorsdup ,dupTo ,-- ** Converting file descriptors to\/from HandleshandleToFd ,fdToHandle ,)whereimportSystem.Posix.TypesimportSystem.Posix.IO.Common importSystem.Posix.IO.ByteString (fdRead ,fdWrite )importSystem.OsPath.TypesimportSystem.Posix.PosixPath.FilePath -- |Open and optionally create this file. See 'System.Posix.Files'-- for information on how to use the 'FileMode' type.openFd ::PosixPath->OpenMode ->OpenFileFlags ->IOFdopenFd :: PosixPath -> OpenMode -> OpenFileFlags -> IO Fd
openFd =Maybe Fd -> PosixPath -> OpenMode -> OpenFileFlags -> IO Fd
openFdAt Maybe Fd
forall a. Maybe a
Nothing-- | Open a file relative to an optional directory file descriptor.---- Directory file descriptors can be used to avoid some race conditions when-- navigating changing directory trees, or to retain access to a portion of the-- directory tree that would otherwise become inaccessible after dropping-- privileges.openFdAt ::MaybeFd-- ^ Optional directory file descriptor->PosixPath-- ^ Pathname to open->OpenMode -- ^ Read-only, read-write or write-only->OpenFileFlags -- ^ Append, exclusive, truncate, etc.->IOFdopenFdAt :: Maybe Fd -> PosixPath -> OpenMode -> OpenFileFlags -> IO Fd
openFdAt Maybe Fd
fdMay PosixPath
name OpenMode
how OpenFileFlags
flags =PosixPath -> (CString -> IO Fd) -> IO Fd
forall a. PosixPath -> (CString -> IO a) -> IO a
withFilePath PosixPath
name ((CString -> IO Fd) -> IO Fd) -> (CString -> IO Fd) -> IO Fd
forall a b. (a -> b) -> a -> b
$\CString
str ->String -> PosixPath -> IO Fd -> IO Fd
forall a. (Eq a, Num a) => String -> PosixPath -> IO a -> IO a
throwErrnoPathIfMinus1Retry String
"openFdAt"PosixPath
name (IO Fd -> IO Fd) -> IO Fd -> IO Fd
forall a b. (a -> b) -> a -> b
$Maybe Fd -> CString -> OpenMode -> OpenFileFlags -> IO Fd
openat_ Maybe Fd
fdMay CString
str OpenMode
how OpenFileFlags
flags -- |Create and open this file in WriteOnly mode. A special case of-- 'openFd'. See 'System.Posix.Files' for information on how to use-- the 'FileMode' type.createFile ::PosixPath->FileMode->IOFdcreateFile :: PosixPath -> FileMode -> IO Fd
createFile =Maybe Fd -> PosixPath -> FileMode -> IO Fd
createFileAt Maybe Fd
forall a. Maybe a
Nothing-- | Create and open a file for write-only, with default flags,-- relative an optional directory file-descriptor.---- Directory file descriptors can be used to avoid some race conditions when-- navigating changing directory trees, or to retain access to a portion of the-- directory tree that would otherwise become inaccessible after dropping-- privileges.createFileAt ::MaybeFd-- ^ Optional directory file descriptor->PosixPath-- ^ Pathname to create->FileMode-- ^ File permission bits (before umask)->IOFdcreateFileAt :: Maybe Fd -> PosixPath -> FileMode -> IO Fd
createFileAt Maybe Fd
fdMay PosixPath
name FileMode
mode =Maybe Fd -> PosixPath -> OpenMode -> OpenFileFlags -> IO Fd
openFdAt Maybe Fd
fdMay PosixPath
name OpenMode
WriteOnly OpenFileFlags
defaultFileFlags {trunc =True,creat =(Justmode )}

AltStyle によって変換されたページ (->オリジナル) /