module

Pylon::Filesystem

stdlibs filesystem APIs (File, Dir, FileUtils) report failures (a vanished path, permissions, a full disk) by throwing exceptions and rarely offer non-throwing variants. We want to avoid exceptions as they can leave the application in undesirable states but also make potential failures invisible to the type system. Here we effectively wrap those APIs to explicitly handle the exceptions as they happen and convert them into values. This allows us to encode the potential failures into the return type and force callers to handle them as needed. A missing path is Missing where absence is actionable, everything else is a Problem carrying the reason.

Instance methods

chmod(path : String, mode : Int32) : Problem | Nil
Source
delete(path : String) : Problem | Nil
Source
delete_tree(path : String) : Problem | Nil
Source
each_child(path : String, & : String -> ) : Missing | Problem | Nil
Source
ensure_directory(path : String) : Problem | Nil
Source
info(path : String) : File::Info | Missing | Problem
Source
open(path : String, mode : String = "r", & : File -> T) : T | Missing | Problem forall T
Source
realpath(path : String) : String | Problem
Source
rename(from : String, to : String) : Problem | Nil
Source
snapshot(from : String, to : String) : Problem | Nil
Source
write(path : String, content : Bytes) : Problem | Nil
Source

Nested types