fs-api-0.3.0.1: Abstract interface for the file system
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.FS.API

Description

An abstract view over the filesystem.

Synopsis

Record that abstracts over the filesystem

data HasFS m h #

Abstract interface for performing file I/O

User-supplied buffers
For functions that require user-supplied buffers (i.e., MutableByteArray), it is the user's responsiblity to provide buffers that are large enough. Behaviour is undefined if the I/O operations access the buffer outside it's allocated range.

Constructors

HasFS 

Fields

Instances

Instances details
NFData (HasFS m h) # 
Instance details

Defined in System.FS.API

Methods

rnf :: HasFS m h -> () #

Types

Opening and closing files

hClose' :: (HasCallStack, Monad m) => HasFS m h -> Handle h -> m Bool #

Returns True when the handle was still open.

withFile :: (HasCallStack, MonadThrow m) => HasFS m h -> FsPath -> OpenMode -> (Handle h -> m a) -> m a #

SomeHasFS

data SomeHasFS m where #

It is often inconvenient to have to parameterise over h. This data type hides an existential h parameter of a HasFS.

Constructors

SomeHasFS :: Eq h => HasFS m h -> SomeHasFS m 

File I/O with user-supplied buffers

newtype BufferOffset #

Absolute offset into a buffer (i.e., MutableByteArray).

Can be negative, because buffer offsets can be added together to change offset positions. This is similar to plusPtr for Ptr types. However, note that reading or writing from a buffer at a negative offset leads to undefined behaviour.

Constructors

BufferOffset 

Fields

Instances

Instances details
Bounded BufferOffset # 
Instance details

Defined in System.FS.API

Enum BufferOffset # 
Instance details

Defined in System.FS.API

Num BufferOffset # 
Instance details

Defined in System.FS.API

Show BufferOffset # 
Instance details

Defined in System.FS.API

Eq BufferOffset # 
Instance details

Defined in System.FS.API

Ord BufferOffset # 
Instance details

Defined in System.FS.API

hGetBufExactly #

Arguments

:: forall m h. (HasCallStack, MonadThrow m) 
=> HasFS m h 
-> Handle h 
-> MutableByteArray (PrimState m)

Buffer to read bytes into

-> BufferOffset

Offset into buffer

-> ByteCount

The number of bytes to read

-> m ByteCount 

Wrapper for hGetBufSome that ensures that we read exactly as many bytes as requested. If EOF is found before the requested number of bytes is read, an FsError exception is thrown.

hGetBufExactlyAt #

Arguments

:: forall m h. (HasCallStack, MonadThrow m) 
=> HasFS m h 
-> Handle h 
-> MutableByteArray (PrimState m)

Buffer to read bytes into

-> BufferOffset

Offset into buffer

-> ByteCount

The number of bytes to read

-> AbsOffset

The file offset at which to read

-> m ByteCount 

Wrapper for hGetBufSomeAt that ensures that we read exactly as many bytes as requested. If EOF is found before the requested number of bytes is read, an FsError exception is thrown.

hPutBufExactly #

Arguments

:: forall m h. (HasCallStack, MonadThrow m) 
=> HasFS m h 
-> Handle h 
-> MutableByteArray (PrimState m)

Buffer to write bytes from

-> BufferOffset

Offset into buffer

-> ByteCount

The number of bytes to write

-> m ByteCount 

Wrapper for hPutBufSome that ensures we write exactly as many bytes as requested.

hPutBufExactlyAt #

Arguments

:: forall m h. (HasCallStack, MonadThrow m) 
=> HasFS m h 
-> Handle h 
-> MutableByteArray (PrimState m)

Buffer to write bytes from

-> BufferOffset

Offset into buffer

-> ByteCount

The number of bytes to write

-> AbsOffset

The file offset at which to write

-> m ByteCount 

Wrapper for hPutBufSomeAt that ensures we write exactly as many bytes as requested.