Merge pull request #10122 from nextcloud/feature/noid/appdata-fopen-stream
Add fopen method to ISimpleFile
This commit is contained in:
commit
229289d206
3 changed files with 57 additions and 0 deletions
|
@ -146,4 +146,27 @@ class SimpleFile implements ISimpleFile {
|
||||||
public function getMimeType() {
|
public function getMimeType() {
|
||||||
return $this->file->getMimeType();
|
return $this->file->getMimeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the file as stream for reading, 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 read() {
|
||||||
|
return $this->file->fopen('r');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the file as stream for writing, 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 write() {
|
||||||
|
return $this->file->fopen('w');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,4 +99,22 @@ interface ISimpleFile {
|
||||||
* @since 11.0.0
|
* @since 11.0.0
|
||||||
*/
|
*/
|
||||||
public function getMimeType();
|
public function getMimeType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the file as stream for reading, 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 read();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the file as stream for writing, 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 write();
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,4 +123,20 @@ class SimpleFileTest extends \Test\TestCase {
|
||||||
|
|
||||||
$this->simpleFile->getContent();
|
$this->simpleFile->getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRead() {
|
||||||
|
$this->file->expects($this->once())
|
||||||
|
->method('fopen')
|
||||||
|
->with('r');
|
||||||
|
|
||||||
|
$this->simpleFile->read();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWrite() {
|
||||||
|
$this->file->expects($this->once())
|
||||||
|
->method('fopen')
|
||||||
|
->with('w');
|
||||||
|
|
||||||
|
$this->simpleFile->write();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue