flix

0.78.0

FileStat

Effect for reading file metadata, such as file type, permissions, timestamps, and size, and its functions.

eff FileStatSource

Effect for reading file metadata, such as file type, permissions, timestamps, and size.

Default Handler

runWithIO

Operations

def accessTime(f: String): Result[IoError, Int64] \ FileStat§ Source

Returns the last access time of the given file f in milliseconds since the epoch.

def creationTime(f: String): Result[IoError, Int64] \ FileStat§ Source

Returns the creation time of the given file f in milliseconds since the epoch.

def exists(f: String): Result[IoError, Bool] \ FileStat§ Source

Returns true if the given file f exists.

def isDirectory(f: String): Result[IoError, Bool] \ FileStat§ Source

Returns true if the given file f is a directory.

def isExecutable(f: String): Result[IoError, Bool] \ FileStat§ Source

Returns true if the given file f is executable.

def isReadable(f: String): Result[IoError, Bool] \ FileStat§ Source

Returns true if the given file f is readable.

def isRegularFile(f: String): Result[IoError, Bool] \ FileStat§ Source

Returns true if the given file f is a regular file.

def isWritable(f: String): Result[IoError, Bool] \ FileStat§ Source

Returns true if the given file f is writable.

def modificationTime(f: String): Result[IoError, Int64] \ FileStat§ Source

Returns the last-modified timestamp of the given file f in milliseconds since the epoch.

def size(f: String): Result[IoError, Size] \ FileStat§ Source

Returns the size of the given file f.

Definitions

def handle(f: a -> b \ ef): a -> b \ (ef - FileStat) + IO§ Source

Handles the FileStat effect of the given function f.

In other words, re-interprets the FileStat effect using the IO effect.

def runWithFileSystem(f: Unit -> a \ ef): a \ (ef - FileStat) + FileSystem§ Source

Handles the FileStat effect of the given function f using the FileSystem effect.

@DefaultHandler
def runWithIO(f: Unit -> a \ ef): a \ (ef - FileStat) + IO§ Source

Runs the FileStat effect of the given function f.

In other words, re-interprets the FileStat effect using the IO effect.

def withAllowGlob(patterns: Nel[String], f: Unit -> a \ ef): a \ (ef - FileStat) + FileStat§ Source

Middleware that intercepts the FileStat 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 - FileStat) + FileStat§ Source

Middleware that intercepts the FileStat effect, validating that all file paths resolve within one of the given allowedDirs. Rejects paths outside the allow list with a PermissionDenied error.

def withBaseDir(baseDir: String, f: Unit -> a \ ef): a \ (ef - FileStat) + FileStat§ Source

Middleware that intercepts the FileStat effect, resolving all file paths relative to the given baseDir using Java's Path.resolve semantics.

Absolute paths are passed through unchanged.

def withChroot(chrootDir: String, f: Unit -> a \ ef): a \ (ef - FileStat) + FileStat§ Source

Middleware that intercepts the FileStat effect, validating that all file paths resolve within the given chrootDir. Rejects paths that escape the chroot with a PermissionDenied error.

def withDenyGlob(patterns: Nel[String], f: Unit -> a \ ef): a \ (ef - FileStat) + FileStat§ Source

Middleware that intercepts the FileStat 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 - FileStat) + FileStat§ Source

Middleware that intercepts the FileStat 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.

def withLogging(f: Unit -> a \ ef): a \ (ef - FileStat) + FileStat + Logger§ Source

Middleware that intercepts the FileStat effect, logging each operation and its result via the Logger effect.

Successful operations are logged at Debug level; errors at Warn.