/**
  * @param $name
  * @dataProvider nameProvider
  */
 public function testDirPaths($name)
 {
     $txtFile = $this->getTextFile();
     $this->share->mkdir($this->root . '/' . $name);
     $this->share->put($txtFile, $this->root . '/' . $name . '/' . $name);
     unlink($txtFile);
     $content = $this->share->dir($this->root . '/' . $name);
     $this->assertCount(1, $content);
     $this->assertEquals($name, $content[0]->getName());
 }
Esempio n. 2
0
 /**
  * List the contents of a directory.
  *
  * @param string $path
  * @param bool $recursive
  * @return array|false
  */
 public function listContents($path = '', $recursive = false)
 {
     $fullPath = $this->applyPathPrefix($path);
     try {
         $files = $this->share->dir($this->stripTrailingSeparator($fullPath));
     } catch (InvalidTypeException $e) {
         return array();
     } catch (NotFoundException $e) {
         return false;
     }
     $contents = array();
     foreach ($files as $file) {
         $contents[] = $this->normalizeFileInfo($file);
         if ($file->isDirectory() && $recursive) {
             $contents = array_merge($contents, $this->listContents($this->getFilePath($file), true));
         }
     }
     return $contents;
 }