public function read($path, $blocking = false)
{
$size = filesize($path);
if ($size === 0) {
return '';
}
$flockFlags = $blocking ? LOCK_SH : LOCK_SH | LOCK_NB;
$file = fopen($path, 'r');
if (!flock($file, $flockFlags)) {
fclose($file);
throw new IOException("Could not aquire file lock for file: {$path}");
}
$contents = fread($file, $size);
flock($file, LOCK_UN | LOCK_NB);
fclose($file);
return $contents;
}