{-# LINE 1 "System/Posix/IO/PosixString.hsc" #-}
module System.Posix.IO.PosixString (
stdInput, stdOutput, stdError,
OpenMode(..),
OpenFileFlags(..), defaultFileFlags,
openFd, openFdAt, createFile, createFileAt,
closeFd,
fdRead, fdWrite,
fdReadBuf, fdWriteBuf,
fdSeek,
FdOption(..),
queryFdOption,
setFdOption,
FileLock,
LockRequest(..),
getLock, setLock,
waitToSetLock,
createPipe,
dup, dupTo,
handleToFd,
fdToHandle,
) where
import System.Posix.Types
import System.Posix.IO.Common
import System.Posix.IO.ByteString ( fdRead, fdWrite )
import System.OsPath.Types
import System.Posix.PosixPath.FilePath
openFd :: PosixPath
-> OpenMode
-> OpenFileFlags
-> IO Fd
openFd :: PosixPath -> OpenMode -> OpenFileFlags -> IO Fd
openFd = Maybe Fd -> PosixPath -> OpenMode -> OpenFileFlags -> IO Fd
openFdAt Maybe Fd
forall a. Maybe a
Nothing
openFdAt :: Maybe Fd
-> PosixPath
-> OpenMode
-> OpenFileFlags
-> IO Fd
openFdAt :: 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
createFile :: PosixPath -> FileMode -> IO Fd
createFile :: PosixPath -> FileMode -> IO Fd
createFile = Maybe Fd -> PosixPath -> FileMode -> IO Fd
createFileAt Maybe Fd
forall a. Maybe a
Nothing
createFileAt :: Maybe Fd
-> PosixPath
-> FileMode
-> IO Fd
createFileAt :: 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 :: Bool
trunc=Bool
True, creat :: Maybe FileMode
creat=(FileMode -> Maybe FileMode
forall a. a -> Maybe a
Just FileMode
mode) }