Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
System.FS.BlockIO.API
Description
Abstract interface, types, and utilities.
Synopsis
- data HasBlockIO m h = HasBlockIO {
- close :: HasCallStack => m ()
- submitIO :: HasCallStack => Vector (IOOp (PrimState m) h) -> m (Vector IOResult)
- hSetNoCache :: Handle h -> Bool -> m ()
- hAdvise :: Handle h -> FileOffset -> FileOffset -> Advice -> m ()
- hAllocate :: Handle h -> FileOffset -> FileOffset -> m ()
- tryLockFile :: FsPath -> LockMode -> m (Maybe (LockFileHandle m))
- hSynchronise :: Handle h -> m ()
- synchroniseDirectory :: FsPath -> m ()
- createHardLink :: FsPath -> FsPath -> m ()
- data IOOp s h
- = IOOpRead !(Handle h) !FileOffset !(MutableByteArray s) !BufferOffset !ByteCount
- | IOOpWrite !(Handle h) !FileOffset !(MutableByteArray s) !BufferOffset !ByteCount
- ioopHandle :: IOOp s h -> Handle h
- ioopFileOffset :: IOOp s h -> FileOffset
- ioopBuffer :: IOOp s h -> MutableByteArray s
- ioopBufferOffset :: IOOp s h -> BufferOffset
- ioopByteCount :: IOOp s h -> ByteCount
- newtype IOResult = IOResult ByteCount
- data Advice
- hAdviseAll :: HasBlockIO m h -> Handle h -> Advice -> m ()
- hDropCacheAll :: HasBlockIO m h -> Handle h -> m ()
- data LockMode
- data FileLockingNotSupported = FileLockingNotSupported
- newtype LockFileHandle m = LockFileHandle {
- hUnlock :: m ()
- synchroniseFile :: MonadThrow m => HasFS m h -> HasBlockIO m h -> FsPath -> m ()
- synchroniseDirectoryRecursive :: MonadThrow m => HasFS m h -> HasBlockIO m h -> FsPath -> m ()
- type ByteCount = CSize
- type FileOffset = COff
HasBlockIO
data HasBlockIO m h Source #
Abstract interface for submitting large batches of I/O operations. This
interface is an extension of the HasFS
interface that is provided by the
fs-api
package.
The interface tries to specify uniform behaviour, but each implementation can have subtly different effects for a variety of reasons. However, for the most part the underlying implementation of an instance of the interface should not affect the correctness of programs that use the interface.
For uniform behaviour across implementations, functions that create a new
instance of the interface should initialise an IO context. This IO context
may be of any shape, as long as the context has two modes: open and closed.
This context is only important for the close
and submitIO
functions. As
long as the IO context is open, submitIO
should perform batches of I/O
operations as expected, but submitIO
should throw an error as soon as the
IO context is closed. Once the IO context is closed, it can not be re-opened
again. Instead, the user should create a new instance of the interface.
Note: there are a bunch of functions in the interface that have nothing to do
with submitting large batches of I/O operations. In fact, only close
and
submitIO
are related to that. All other functions were put in this record
for simplicity because the authors of the library needed them and it was more
straightforward to add them here then to add them to fs-api
. Still these
unrelated functions could and should all be moved into fs-api
at some point
in the future.
Constructors
HasBlockIO | |
Fields
|
Instances
NFData (HasBlockIO m h) Source # | |
Defined in System.FS.BlockIO.API Methods rnf :: HasBlockIO m h -> () # |
Constructors
IOOpRead !(Handle h) !FileOffset !(MutableByteArray s) !BufferOffset !ByteCount | |
IOOpWrite !(Handle h) !FileOffset !(MutableByteArray s) !BufferOffset !ByteCount |
ioopHandle :: IOOp s h -> Handle h Source #
ioopFileOffset :: IOOp s h -> FileOffset Source #
ioopBuffer :: IOOp s h -> MutableByteArray s Source #
ioopBufferOffset :: IOOp s h -> BufferOffset Source #
ioopByteCount :: IOOp s h -> ByteCount Source #
Number of read/written bytes.
Instances
Advice
Copy of System.Posix.Fcntl.Advice from the unix
package
hAdviseAll :: HasBlockIO m h -> Handle h -> Advice -> m () Source #
hDropCacheAll :: HasBlockIO m h -> Handle h -> m () Source #
Drop the full file referenced by a Handle
from the OS page cache, if
present.
File locks
Indicates a mode in which a file should be locked.
Constructors
SharedLock | |
ExclusiveLock |
data FileLockingNotSupported #
Exception thrown by hLock
on non-Windows platforms that don't support
flock
.
Since: base-4.10.0.0
Constructors
FileLockingNotSupported |
Instances
Exception FileLockingNotSupported | |
Defined in GHC.IO.Handle.Lock.Common | |
Show FileLockingNotSupported | Since: base-4.10.0.0 |
Defined in GHC.IO.Handle.Lock.Common Methods showsPrec :: Int -> FileLockingNotSupported -> ShowS # show :: FileLockingNotSupported -> String # showList :: [FileLockingNotSupported] -> ShowS # |
newtype LockFileHandle m Source #
A handle to a file locked using tryLockFile
.
Constructors
LockFileHandle | |
Fields
|
Storage synchronisation
synchroniseFile :: MonadThrow m => HasFS m h -> HasBlockIO m h -> FsPath -> m () Source #
Synchronise a file's contents and metadata with the storage device.
synchroniseDirectoryRecursive :: MonadThrow m => HasFS m h -> HasBlockIO m h -> FsPath -> m () Source #
Synchronise a directory's contents and metadata with the storage device, and recursively for all entries in the directory.
Re-exports
type FileOffset = COff #