Skip to content
docsv0.1.0

WriteGuard

Filesystem safety for generators: refuses to clobber an existing file unless `--force`, and creates parent directories on write. `assertWritable()` is called for every planned file up front so a blocked target aborts the whole `coa:make` run before anything is written.

WriteGuard::assertWritable()

public function assertWritable(string $path, bool $force): void

Throws unless `$path` is free to write: absent, or `$force` is true.

Parameters

Parameters of assertWritable()
NameTypeDescription
$pathstring
$forcebool

WriteGuard::write()

public function write(string $path, string $contents): void

Writes `$contents` to `$path`, creating parent directories as needed.

Parameters

Parameters of write()
NameTypeDescription
$pathstring
$contentsstring