classes/Files/LockingFilesystem.php
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;
	}
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;
	}
Read from a file.

@param  string $path Path to the file.
@param  bool   $blocking Wait for other locks to expire rather than
throwing an error when a lock cannot be aquired.

@return string

@throws IOException