public function opendir($path) { $path = $this->stripPath($path); $content = $this->archive->getFolder($path); foreach ($content as &$file) { if (substr($file, -1) == '/') { $file = substr($file, 0, -1); } } $id = md5($this->path . $path); OC_FakeDirStream::$dirs[$id] = $content; return opendir('fakedir://' . $id); }
public function opendir($path) { if (substr($path, -1) !== '/') { $path .= '/'; } $path = $this->stripPath($path); $files = $this->archive->getFolder($path); $content = array(); foreach ($files as $file) { if (substr($file, -1) == '/') { $file = substr($file, 0, -1); } if ($file and strpos($file, '/') === false) { $content[] = $file; } } $id = md5($this->path . $path); \OC\Files\Stream\Dir::register($id, $content); return opendir('fakedir://' . $id); }
public function testGetFiles() { $this->instance = $this->getExisting(); $allFiles = $this->instance->getFiles(); $expected = array('lorem.txt', 'logo-wide.png', 'dir/', 'dir/lorem.txt'); $this->assertEquals(4, count($allFiles), 'only found ' . count($allFiles) . ' out of 4 expected files'); foreach ($expected as $file) { $this->assertContains($file, $allFiles, 'cant find ' . $file . ' in archive'); $this->assertTrue($this->instance->fileExists($file), 'file ' . $file . ' does not exist in archive'); } $this->assertFalse($this->instance->fileExists('non/existing/file')); $rootContent = $this->instance->getFolder(''); $expected = array('lorem.txt', 'logo-wide.png', 'dir/'); $this->assertEquals(3, count($rootContent)); foreach ($expected as $file) { $this->assertContains($file, $rootContent, 'cant find ' . $file . ' in archive'); } $dirContent = $this->instance->getFolder('dir/'); $expected = array('lorem.txt'); $this->assertEquals(1, count($dirContent)); foreach ($expected as $file) { $this->assertContains($file, $dirContent, 'cant find ' . $file . ' in archive'); } }