diff options
-rw-r--r-- | lib/private/files/stream/close.php | 2 | ||||
-rw-r--r-- | lib/private/files/stream/oc.php | 2 | ||||
-rw-r--r-- | lib/private/files/stream/quota.php | 2 | ||||
-rw-r--r-- | tests/lib/streamwrappers.php | 10 |
4 files changed, 13 insertions, 3 deletions
diff --git a/lib/private/files/stream/close.php b/lib/private/files/stream/close.php index 0e1f088fcf9..97e45e37ad7 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() { diff --git a/lib/private/files/stream/oc.php b/lib/private/files/stream/oc.php index c206b41f55e..8c3531638ec 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() { diff --git a/lib/private/files/stream/quota.php b/lib/private/files/stream/quota.php index bb4623b1a7b..cef9d84f560 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() { diff --git a/tests/lib/streamwrappers.php b/tests/lib/streamwrappers.php index d15b712139d..1b61446f4dc 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:///')); } |