{-# LINE 1 "libraries/unix/System/Posix/IO/ByteString.hsc" #-}
{-# LINE 2 "libraries/unix/System/Posix/IO/ByteString.hsc" #-}
{-# LANGUAGE Safe #-}
{-# LINE 6 "libraries/unix/System/Posix/IO/ByteString.hsc" #-}
module System.Posix.IO.ByteString (
    
    
    stdInput, stdOutput, stdError,
    
    OpenMode(..),
    OpenFileFlags(..), defaultFileFlags,
    openFd, createFile,
    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.ByteString.FilePath
openFd :: RawFilePath
       -> OpenMode
       -> Maybe FileMode 
       -> OpenFileFlags
       -> IO Fd
openFd :: RawFilePath -> OpenMode -> Maybe FileMode -> OpenFileFlags -> IO Fd
openFd RawFilePath
name OpenMode
how Maybe FileMode
maybe_mode OpenFileFlags
flags = do
   RawFilePath -> (CString -> IO Fd) -> IO Fd
forall a. RawFilePath -> (CString -> IO a) -> IO a
withFilePath RawFilePath
name ((CString -> IO Fd) -> IO Fd) -> (CString -> IO Fd) -> IO Fd
forall a b. (a -> b) -> a -> b
$ \CString
str -> do
     String -> RawFilePath -> IO Fd -> IO Fd
forall a. (Eq a, Num a) => String -> RawFilePath -> IO a -> IO a
throwErrnoPathIfMinus1Retry String
"openFd" RawFilePath
name (IO Fd -> IO Fd) -> IO Fd -> IO Fd
forall a b. (a -> b) -> a -> b
$
       CString -> OpenMode -> Maybe FileMode -> OpenFileFlags -> IO Fd
open_ CString
str OpenMode
how Maybe FileMode
maybe_mode OpenFileFlags
flags
createFile :: RawFilePath -> FileMode -> IO Fd
createFile :: RawFilePath -> FileMode -> IO Fd
createFile RawFilePath
name FileMode
mode
  = RawFilePath -> OpenMode -> Maybe FileMode -> OpenFileFlags -> IO Fd
openFd RawFilePath
name OpenMode
WriteOnly (FileMode -> Maybe FileMode
forall a. a -> Maybe a
Just FileMode
mode) OpenFileFlags
defaultFileFlags{ trunc :: Bool
trunc=Bool
True }