From ef6db5e9d7a20fe85f2758881b67d6c63f378ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Sun, 21 Sep 2014 22:47:40 +0200 Subject: [PATCH 1/4] add seek and tell to streamwrapper test --- tests/lib/streamwrappers.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/lib/streamwrappers.php b/tests/lib/streamwrappers.php index d15b712139..1b61446f4d 100644 --- a/tests/lib/streamwrappers.php +++ b/tests/lib/streamwrappers.php @@ -79,6 +79,16 @@ class Test_StreamWrappers extends PHPUnit_Framework_TestCase { $this->assertEquals(array('.', '..', 'bar.txt', 'foo.txt'), scandir('oc:///')); $this->assertEquals('qwerty', file_get_contents('oc:///bar.txt')); + $fh = fopen('oc:///bar.txt', 'rb'); + $this->assertSame(0, ftell($fh)); + $content = fread($fh, 4); + $this->assertSame(4, ftell($fh)); + $this->assertSame('qwer', $content); + $content = fread($fh, 1); + $this->assertSame(5, ftell($fh)); + $this->assertSame(0, fseek($fh, 0)); + $this->assertSame(0, ftell($fh)); + unlink('oc:///foo.txt'); $this->assertEquals(array('.', '..', 'bar.txt'), scandir('oc:///')); } From b752cb98d819637cc36c9eba9f2c1844e3c5c550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Sun, 21 Sep 2014 22:48:35 +0200 Subject: [PATCH 2/4] return boolean in OC::stream_seek --- lib/private/files/stream/oc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/files/stream/oc.php b/lib/private/files/stream/oc.php index c206b41f55..8c3531638e 100644 --- a/lib/private/files/stream/oc.php +++ b/lib/private/files/stream/oc.php @@ -48,7 +48,7 @@ class OC { } public function stream_seek($offset, $whence = SEEK_SET) { - fseek($this->fileSource, $offset, $whence); + return fseek($this->fileSource, $offset, $whence) === 0; } public function stream_tell() { From 561a7e47cd68429baa9142f7c09c424c8c9ee81a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 22 Sep 2014 11:33:55 +0200 Subject: [PATCH 3/4] return boolean in Ciose::stream_seek --- lib/private/files/stream/close.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/files/stream/close.php b/lib/private/files/stream/close.php index 0e1f088fcf..97e45e37ad 100644 --- a/lib/private/files/stream/close.php +++ b/lib/private/files/stream/close.php @@ -29,7 +29,7 @@ class Close { } public function stream_seek($offset, $whence = SEEK_SET) { - fseek($this->source, $offset, $whence); + return fseek($this->source, $offset, $whence) === 0; } public function stream_tell() { From f83689e1be43aaa6bf2fbac2772868151597911b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 22 Sep 2014 11:35:42 +0200 Subject: [PATCH 4/4] in quota wrapper use === instead of ! for better readability and as in other wrappers --- lib/private/files/stream/quota.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/files/stream/quota.php b/lib/private/files/stream/quota.php index bb4623b1a7..cef9d84f56 100644 --- a/lib/private/files/stream/quota.php +++ b/lib/private/files/stream/quota.php @@ -83,7 +83,7 @@ class Quota { } // this wrapper needs to return "true" for success. // the fseek call itself returns 0 on succeess - return !fseek($this->source, $offset, $whence); + return fseek($this->source, $offset, $whence) === 0; } public function stream_tell() {