FileHandle

trait FileHandle[F[_]] extends FileHandlePlatform[F]

Provides the ability to read/write/lock/inspect a file in the effect F.

Companion
object
trait FileHandlePlatform[F]
class Object
trait Matchable
class Any

Type members

Inherited types

type Lock

Opaque type representing an exclusive lock on a file.

Opaque type representing an exclusive lock on a file.

Inherited from
FileHandlePlatform

Value members

Abstract methods

def force(metaData: Boolean): F[Unit]

Force any updates for the underlying file to storage.

Force any updates for the underlying file to storage.

Value Params
metaData

If true, also attempts to force file metadata updates to storage.

def read(numBytes: Int, offset: Long): F[Option[Chunk[Byte]]]

Read the specified number of bytes at a particular offset.

Read the specified number of bytes at a particular offset.

Value Params
numBytes

the number of bytes to read.

offset

the offset from the start of the file.

Returns

a number of bytes from the file (at most, numBytes in size).

def size: F[Long]

Report the current size of the file.

Report the current size of the file.

Returns

the size of the file.

def truncate(size: Long): F[Unit]

Truncate the underlying file to the specified size.

Truncate the underlying file to the specified size.

Value Params
size

the size of the file after truncation.

def write(bytes: Chunk[Byte], offset: Long): F[Int]

Write the specified bytes at a particular offset.

Write the specified bytes at a particular offset.

Value Params
bytes

the bytes to write to the FileHandle.

offset

the offset at which to write the bytes.

Returns

the number of bytes written.

Inherited methods

def lock(position: Long, size: Long, shared: Boolean): F[Lock]

Acquire a lock on the specified region of the underlying file.

Acquire a lock on the specified region of the underlying file.

Value Params
position

the start of the region to lock.

shared

to request a shared lock across process boundaries (may be converted to an exclusive lock on some operating systems).

size

the size of the region to lock.

Returns

a lock object which can be used to unlock the region.

Inherited from
FileHandlePlatform
def lock: F[Lock]

Acquire an exclusive lock on the underlying file.

Acquire an exclusive lock on the underlying file.

Returns

a lock object which can be used to unlock the file.

Inherited from
FileHandlePlatform
def tryLock(position: Long, size: Long, shared: Boolean): F[Option[Lock]]

Attempt to acquire a lock on the specified region of the underlying file.

Attempt to acquire a lock on the specified region of the underlying file.

Value Params
position

the start of the region to lock.

shared

to request a shared lock across process boundaries (may be converted to an exclusive lock on some operating systems).

size

the size of the region to lock.

Returns

if the lock could be acquired, a lock object which can be used to unlock the region.

Inherited from
FileHandlePlatform
def tryLock: F[Option[Lock]]

Attempt to acquire an exclusive lock on the underlying file.

Attempt to acquire an exclusive lock on the underlying file.

Returns

if the lock could be acquired, a lock object which can be used to unlock the file.

Inherited from
FileHandlePlatform
def unlock(lock: Lock): F[Unit]

Unlock the (exclusive or regional) lock represented by the supplied Lock.

Unlock the (exclusive or regional) lock represented by the supplied Lock.

Value Params
lock

the lock object which represents the locked file or region.

Inherited from
FileHandlePlatform