public function write(string $contents, int $opts = 0): bool
    {
        if ($this->prepareWrite() !== true) {
            $this->error = "failed to write '{$this->path}; {$this->error}";
            return false;
        }
        return $this->writeFile($contents, $opts);
    }