Esempio n. 1
0
 public function testCreateDir()
 {
     $local = new Local($this->tempDir);
     $config = new Config();
     $create = $local->createDir('horse-with-no-name', $config);
     $this->assertSame('horse-with-no-name', $create['path']);
     $this->assertSame('dir', $create['type']);
     $this->filesystem->get('fixtures/base.css')->copy('temp/horse-with-no-name/koala.css');
     $create = $local->createDir('horse-with-no-name/koala.css', $config);
     $this->assertFalse($create);
 }
 /**
  * @param Storageable $storageable
  * @param \SplFileInfo $fileInfo
  *
  * @return bool
  */
 public function store(Storageable $storageable, \SplFileInfo $fileInfo) : bool
 {
     $fileName = $this->namingStrategy->generate($storageable);
     $filePath = $this->filePathStrategy->generate($fileName);
     $fileExtension = $this->getFileExtension($fileInfo);
     if ($fileExtension) {
         $fileName .= '.' . $fileExtension;
     }
     $storageable->setFileName($fileName);
     $filePathWithName = $filePath . DIRECTORY_SEPARATOR . $fileName;
     if (!$this->filesystem->write($filePathWithName, file_get_contents($fileInfo->getPathname()))) {
         throw FileStoreException::notStored();
     }
     return true;
 }
Esempio n. 3
0
 /**
  * Lists the subdirectories inside a directory
  *
  * @param   null|string  $dir  The directory to scan. Skip to use the current directory.
  *
  * @return  array|bool  A list of folders, or false if we could not get a listing
  *
  * @throws  \RuntimeException  When the server is incompatible with our folder scanner
  */
 public function listFolders($dir = null)
 {
     try {
         // First try using a direct access
         $list = $this->fileAdapter->listFolders($dir);
     } catch (\RuntimeException $e) {
         if (!is_object($this->abstractionAdapter)) {
             // If we failed and there is no abstraction adapter rethrow the exception
             throw $e;
         } else {
             // Also try using the abstraction adapter
             $list = $this->abstractionAdapter->listFolders($dir);
         }
     }
     return $list;
 }
Esempio n. 4
0
 /**
  * Retrieve the entree type (file|dir).
  *
  * @return string file or dir
  */
 public function getType()
 {
     $metadata = $this->filesystem->getMetadata($this->path);
     return $metadata['type'];
 }