Add fopen method to ISimpleFile

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2018-07-05 18:08:56 +02:00
parent af20f1dd4b
commit f1469e34aa
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
3 changed files with 28 additions and 0 deletions

View File

@ -146,4 +146,15 @@ class SimpleFile implements ISimpleFile {
public function getMimeType() {
return $this->file->getMimeType();
}
/**
* Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen
*
* @return resource
* @throws \OCP\Files\NotPermittedException
* @since 14.0.0
*/
public function fopen(string $mode) {
return $this->file->fopen($mode);
}
}

View File

@ -99,4 +99,13 @@ interface ISimpleFile {
* @since 11.0.0
*/
public function getMimeType();
/**
* Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen
*
* @return resource
* @throws \OCP\Files\NotPermittedException
* @since 14.0.0
*/
public function fopen(string $mode);
}

View File

@ -123,4 +123,12 @@ class SimpleFileTest extends \Test\TestCase {
$this->simpleFile->getContent();
}
public function testFopen() {
$this->file->expects($this->once())
->method('fopen')
->with('r+');
$this->simpleFile->fopen('r+');
}
}