Commit bc98d9cc authored by Jeremy Mikola's avatar Jeremy Mikola

PHPLIB-248: GridFS should report file mode using stat(2) bits

parent a6fd0be1
...@@ -145,7 +145,9 @@ class StreamWrapper ...@@ -145,7 +145,9 @@ class StreamWrapper
{ {
$stat = $this->getStatTemplate(); $stat = $this->getStatTemplate();
$stat[2] = $stat['mode'] = $this->mode; $stat[2] = $stat['mode'] = $this->stream instanceof ReadableStream
? 0100444 // S_IFREG & S_IRUSR & S_IRGRP & S_IROTH
: 0100222; // S_IFREG & S_IWUSR & S_IWGRP & S_IWOTH
$stat[7] = $stat['size'] = $this->stream->getSize(); $stat[7] = $stat['size'] = $this->stream->getSize();
return $stat; return $stat;
......
...@@ -49,6 +49,15 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase ...@@ -49,6 +49,15 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
$this->assertSame('', fread($stream, 3)); $this->assertSame('', fread($stream, 3));
} }
public function testReadableStreamStat()
{
$stream = $this->bucket->openDownloadStream('length-10');
$stat = fstat($stream);
$this->assertSame(0100444, $stat[2]);
$this->assertSame(0100444, $stat['mode']);
}
public function testReadableStreamWrite() public function testReadableStreamWrite()
{ {
$stream = $this->bucket->openDownloadStream('length-10'); $stream = $this->bucket->openDownloadStream('length-10');
...@@ -84,6 +93,15 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase ...@@ -84,6 +93,15 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
$this->assertSame('', fread($stream, 8192)); $this->assertSame('', fread($stream, 8192));
} }
public function testWritableStreamStat()
{
$stream = $this->bucket->openUploadStream('filename');
$stat = fstat($stream);
$this->assertSame(0100222, $stat[2]);
$this->assertSame(0100222, $stat['mode']);
}
public function testWritableStreamWrite() public function testWritableStreamWrite()
{ {
$stream = $this->bucket->openUploadStream('filename'); $stream = $this->bucket->openUploadStream('filename');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment