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