Fs.FileRead
eff FileReadSourceAn effect used to read file contents (string, lines, bytes).
Operations
Returns a string of all the contents of the given file f.
Returns a vector of all the bytes in the given file f.
Definitions
Handles the FileRead effect of the given function f.
In other words, re-interprets the FileRead effect using the IO effect.
Handles the FileRead effect of the given function f using the FileSystem effect.
@DefaultHandler Runs the FileRead effect of the given function f.
In other words, re-interprets the FileRead effect using the IO effect.
Middleware that intercepts the FileRead effect, validating that all file paths
match at least one of the given glob patterns. Rejects paths that do not match
with a PermissionDenied error.
def withAllowList(allowedDirs: Nel[String], f: Unit -> a \ ef): a \ (ef - FileRead) + FileRead§ SourceMiddleware that intercepts the FileRead effect, validating that all file paths
resolve within one of the given allowedDirs. Rejects paths outside the
allow list with a PermissionDenied error.
Middleware that intercepts the FileRead effect, resolving all file paths
relative to the given baseDir using Java's Path.resolve semantics.
Absolute paths are passed through unchanged.
def withChecksum(hash: Vector[Int8] -> Vector[Int8], sidecar: String, f: Unit -> a \ ef): a \ (ef - FileRead) + FileRead§ SourceMiddleware that intercepts the FileRead effect, verifying file checksums
on read. If a sidecar checksum file exists (e.g., "data.txt.sha256" when
sidecar is ".sha256"), the file's contents are hashed and compared
against the stored checksum.
hash is a pure function from file bytes to digest bytes.
sidecar is the file suffix (e.g., ".sha256").
If no sidecar file exists, the read proceeds normally.
If the checksum does not match, returns Err(IoError(ChecksumMismatch, ...)).
Middleware that intercepts the FileRead effect, validating that all file paths
resolve within the given chrootDir. Rejects paths that escape the chroot with
a PermissionDenied error.
Middleware that intercepts the FileRead effect, validating that all file paths
do not match any of the given glob patterns. Rejects paths that match a denied
pattern with a PermissionDenied error.
def withDenyList(deniedDirs: Nel[String], f: Unit -> a \ ef): a \ (ef - FileRead) + FileRead§ SourceMiddleware that intercepts the FileRead effect, validating that all file paths
do not resolve within any of the given deniedDirs. Rejects paths inside a
denied directory with a PermissionDenied error.
Middleware that intercepts the FileRead effect, resolving all file paths
to their real filesystem targets by following symlinks.
Action ops (read, readLines, readBytes): resolve path with fallback to original.
Middleware that intercepts the FileRead effect, logging each operation
and its result via the Logger effect.
Successful operations are logged at Debug level; errors at Warn.
def withTransferLimit(maxSize: Size, f: Unit -> a \ ef): a \ (ef - FileRead) + FileRead + FileStat§ SourceMiddleware that intercepts the FileRead effect, rejecting reads of files
larger than maxBytes. The file size is checked via FileStat.size before
reading. For string-based reads, the limit applies to the on-disk file size
(not the in-memory string length).