public function write($path, $contents, $blocking = false)
{
$flockFlags = $blocking ? LOCK_EX : LOCK_EX | LOCK_NB;
$file = fopen($path, 'c');
if (!flock($file, $flockFlags)) {
fclose($file);
throw new IOException("Could not aquire file lock for file: {$path}");
}
ftruncate($file, 0);
fwrite($file, $contents);
fflush($file);
flock($file, LOCK_UN | LOCK_NB);
fclose($file);
}