summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-07-05 18:08:56 +0200
committerJulius Härtl <jus@bitgrid.net>2018-07-11 10:29:03 +0200
commitf1469e34aa8f29a8dbec8e1ae9260fb09777f82f (patch)
treea0047d15098a475efc84e51c8bb07ea4822b2c08
parentaf20f1dd4b3637f514837df6a2e1c683b7ef775b (diff)
downloadnextcloud-server-f1469e34aa8f29a8dbec8e1ae9260fb09777f82f.tar.gz
nextcloud-server-f1469e34aa8f29a8dbec8e1ae9260fb09777f82f.zip
Add fopen method to ISimpleFile
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--lib/private/Files/SimpleFS/SimpleFile.php11
-rw-r--r--lib/public/Files/SimpleFS/ISimpleFile.php9
-rw-r--r--tests/lib/Files/SimpleFS/SimpleFileTest.php8
3 files changed, 28 insertions, 0 deletions
diff --git a/lib/private/Files/SimpleFS/SimpleFile.php b/lib/private/Files/SimpleFS/SimpleFile.php
index e9bf0213d07..52b7819694c 100644
--- a/lib/private/Files/SimpleFS/SimpleFile.php
+++ b/lib/private/Files/SimpleFS/SimpleFile.php
@@ -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);
+ }
}
diff --git a/lib/public/Files/SimpleFS/ISimpleFile.php b/lib/public/Files/SimpleFS/ISimpleFile.php
index cd092056cda..c417db6354d 100644
--- a/lib/public/Files/SimpleFS/ISimpleFile.php
+++ b/lib/public/Files/SimpleFS/ISimpleFile.php
@@ -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);
}
diff --git a/tests/lib/Files/SimpleFS/SimpleFileTest.php b/tests/lib/Files/SimpleFS/SimpleFileTest.php
index ab4970804a4..aec5052cb4b 100644
--- a/tests/lib/Files/SimpleFS/SimpleFileTest.php
+++ b/tests/lib/Files/SimpleFS/SimpleFileTest.php
@@ -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+');
+ }
}