Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,22 @@ private function toIterator($files)

return $files;
}

/**
* Read file and return contents.
*
* @param $filename
*
* @return string $filename The file to read.
*
* @throws Exception\IOException
*/
public function readFile($filename)
{
if (false === $source = @file_get_contents($filename)) {
throw new IOException(sprintf('Failed to read "%s" because source file could not be opened for reading.', $filename), 0, null, $filename);
}

return $source;
}
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ $filesystem->makePathRelative($endPath, $startPath);
$filesystem->mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array());

$filesystem->isAbsolutePath($file);

$filesystem->readFile($file);

```

Resources
Expand Down