posix-api-0.7.2.0: posix bindings
Safe HaskellSafe-Inferred
LanguageHaskell2010

Posix.File

Synopsis

Functions

uninterruptibleGetDescriptorFlags :: Fd -> IO (Either Errno DescriptorFlags) Source #

Get file descriptor flags. This uses the unsafe FFI to perform fcntl(fd,F_GETFD).

uninterruptibleGetStatusFlags :: Fd -> IO (Either Errno StatusFlags) Source #

Get file status flags. This uses the unsafe FFI to perform fcntl(fd,F_GETFL).

uninterruptibleWriteByteArray Source #

Arguments

:: Fd

Socket

-> ByteArray

Source byte array

-> Int

Offset into source array

-> CSize

Length in bytes

-> IO (Either Errno CSize)

Number of bytes pushed to send buffer

Wrapper for write(2) that takes a byte array and an offset. The byte array does not need to be pinned.

uninterruptibleWriteBytes Source #

Arguments

:: Fd

File descriptor

-> Bytes

Source bytes

-> IO (Either Errno CSize)

Number of bytes written

Wrapper for write(2) that takes a slice of bytes and an offset. The byte array backing the slice does not need to be pinned.

uninterruptibleWriteBytesCompletely Source #

Arguments

:: Fd

File descriptor

-> Bytes

Source bytes

-> IO (Either Errno ()) 

Wrapper for write(2) that takes a slice of bytes and an offset. The byte array backing the slice does not need to be pinned.

uninterruptibleWriteBytesCompletelyErrno Source #

Arguments

:: Fd

File descriptor

-> Bytes

Source bytes

-> IO Errno 

Variant of uninterruptibleWriteBytesCompletely that uses errno 0 to communicate success.

uninterruptibleReadMutableByteArray Source #

Arguments

:: Fd

File descriptor

-> MutableByteArray RealWorld

Destination

-> Int

Destination offset

-> CSize

Length in bytes

-> IO (Either Errno CSize)

Number of bytes received

writeBytesCompletelyErrno Source #

Arguments

:: Fd

File descriptor

-> Bytes

Source bytes

-> IO Errno 

Wrapper for write(2) that takes a slice of bytes and an offset. The byte array backing the slice must be pinned.

uninterruptibleOpen Source #

Arguments

:: ManagedCString

NULL-terminated file name

-> AccessMode

Access mode

-> CreationFlags

Creation flags

-> StatusFlags

Status flags

-> IO (Either Errno Fd) 

uninterruptibleOpenMode Source #

Arguments

:: ManagedCString

NULL-terminated file name

-> AccessMode

Access mode, should include O_CREAT

-> CreationFlags

Creation flags

-> StatusFlags

Status flags

-> CMode

Permissions assigned to newly created file

-> IO (Either Errno Fd) 

uninterruptibleOpenUntypedFlags Source #

Arguments

:: ManagedCString

NULL-terminated file name

-> CInt

Flags

-> IO (Either Errno Fd) 

Variant of uninterruptibleOpen that does not help the caller with the types of the flags.

uninterruptibleOpenModeUntypedFlags Source #

Arguments

:: ManagedCString

NULL-terminated file name

-> CInt

Flags

-> CMode

Mode

-> IO (Either Errno Fd) 

Variant of uninterruptibleOpenMode that does not help the caller with the types of the flags.

writeByteArray Source #

Arguments

:: Fd

File descriptor

-> ByteArray

Source byte array

-> Int

Offset into source array

-> CSize

Length in bytes

-> IO (Either Errno CSize)

Number of bytes pushed to send buffer

Wrapper for write(2) that takes a byte array and an offset. Uses safe FFI. The byte array must be pinned.

writeMutableByteArray Source #

Arguments

:: Fd

File descriptor

-> MutableByteArray RealWorld

Source byte array

-> Int

Offset into source array

-> CSize

Length in bytes

-> IO (Either Errno CSize)

Number of bytes pushed to send buffer

Variant of writeByteArray that operates on mutable byte array. Uses safe FFI. The byte array must be pinned.

close Source #

Arguments

:: Fd

Socket

-> IO (Either Errno ()) 

Close a file descriptor. The POSIX specification includes more details. This uses the safe FFI.

uninterruptibleClose Source #

Arguments

:: Fd

Socket

-> IO (Either Errno ()) 

Close a file descriptor. This uses the unsafe FFI. According to the POSIX specification, "If fildes refers to a socket, close() shall cause the socket to be destroyed. If the socket is in connection-mode, and the SO_LINGER option is set for the socket with non-zero linger time, and the socket has untransmitted data, then close() shall block for up to the current linger interval until all data is transmitted."

uninterruptibleErrorlessClose Source #

Arguments

:: Fd

Socket

-> IO () 

Close a file descriptor with the unsafe FFI. Do not check for errors. It is only appropriate to use this when a file descriptor is being closed to handle an exceptional case. Since the user will want to propogate the original exception, the exception provided by uninterruptibleClose would just be discarded. This function allows us to potentially avoid an additional FFI call to getErrno.

uninterruptibleLink Source #

Arguments

:: ManagedCString

Path to existing file

-> ManagedCString

Path to new file

-> IO (Either Errno ()) 

Types

newtype AccessMode Source #

Constructors

AccessMode CInt 

Instances

Instances details
Eq AccessMode Source # 
Instance details

Defined in Posix.File.Types

newtype CreationFlags Source #

File Creation Flags

Constructors

CreationFlags CInt 

Instances

Instances details
Monoid CreationFlags Source # 
Instance details

Defined in Posix.File.Types

Semigroup CreationFlags Source # 
Instance details

Defined in Posix.File.Types

Bits CreationFlags Source # 
Instance details

Defined in Posix.File.Types

Eq CreationFlags Source # 
Instance details

Defined in Posix.File.Types

newtype DescriptorFlags Source #

File Descriptor Flags

Constructors

DescriptorFlags CInt 

Instances

Instances details
Monoid DescriptorFlags Source # 
Instance details

Defined in Posix.File.Types

Semigroup DescriptorFlags Source # 
Instance details

Defined in Posix.File.Types

Bits DescriptorFlags Source # 
Instance details

Defined in Posix.File.Types

Eq DescriptorFlags Source # 
Instance details

Defined in Posix.File.Types

newtype StatusFlags Source #

File Status Flags

Constructors

StatusFlags CInt 

Instances

Instances details
Monoid StatusFlags Source # 
Instance details

Defined in Posix.File.Types

Semigroup StatusFlags Source # 
Instance details

Defined in Posix.File.Types

Bits StatusFlags Source # 
Instance details

Defined in Posix.File.Types

Eq StatusFlags Source # 
Instance details

Defined in Posix.File.Types

File Descriptor Flags

nonblocking :: StatusFlags Source #

The O_NONBLOCK flag

append :: StatusFlags Source #

The O_APPEND flag

Open Access Mode

readOnly :: AccessMode Source #

The O_RDONLY access mode.

writeOnly :: AccessMode Source #

The O_WRONLY access mode.

readWrite :: AccessMode Source #

The O_RDWR access mode.

File Creation Flags

create :: CreationFlags Source #

The O_CREAT flag

truncate :: CreationFlags Source #

The O_TRUNC flag

exclusive :: CreationFlags Source #

The O_EXCL flag