mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
[ticket/15305] Add streams
PHPBB3-15305
This commit is contained in:
@@ -195,4 +195,39 @@ class local implements adapter_interface
|
||||
$this->create_dir($path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read_stream($path)
|
||||
{
|
||||
$stream = @fopen($path, 'rb');
|
||||
|
||||
if (!$stream)
|
||||
{
|
||||
throw new exception('STORAGE_CANNOT_OPEN_FILE', $path);
|
||||
}
|
||||
|
||||
return $stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write_stream($path, $resource)
|
||||
{
|
||||
if ($this->exists($path))
|
||||
{
|
||||
throw new exception('STORAGE_FILE_EXISTS', $path);
|
||||
}
|
||||
|
||||
$stream = @fopen($path, 'w+b');
|
||||
|
||||
if (!$stream)
|
||||
{
|
||||
throw new exception('STORAGE_CANNOT_CREATE_FILE', $path);
|
||||
}
|
||||
|
||||
stream_copy_to_stream($resource, $stream);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user