AtomicWriter
in package
FinalYes
Atomic write with quarantine sibling.
write() always lands the XML at either $targetPath (when $valid is true) or the sibling quarantine path *_invalid.xml (when $valid is false), via a temp file in the same directory plus a POSIX-atomic rename. The opposite sibling is removed on every successful write so the name space is monotonic per (filename, time): a reader picking up name.xml is guaranteed to see XML that passed validation at the moment it landed there.
Table of Contents
Methods
- quarantinePath() : string
- Computes the quarantine sibling path for a given target. e.g.
- write() : string
- Writes $xml to either $targetPath or its quarantine sibling, atomically.
Methods
quarantinePath()
Computes the quarantine sibling path for a given target. e.g.
public
static quarantinePath(string $targetPath) : string
/out/RE-1.xml -> /out/RE-1_invalid.xml
Parameters
- $targetPath : string
Return values
stringwrite()
Writes $xml to either $targetPath or its quarantine sibling, atomically.
public
write(string $xml, string $targetPath, bool $valid) : string
Parameters
- $xml : string
- $targetPath : string
- $valid : bool
Tags
Return values
string —The final path (either $targetPath or the quarantine sibling).