Exemplo n.º 1
0
 /**
  * Create the directory specified by the $file if it does not exist
  *
  * @param FileNode    $file
  * @param string|null $visibility public or private visibility
  *
  * @return LocalFile The original file inputted
  * @throws MakeDirectoryFailedException
  */
 public function makeDirectory(FileNode $file, $visibility = null)
 {
     $madeDirectory = $file->getFilesystem()->createDir($file->getDirectory(), ['visibility' => $visibility ?: static::VISIBILITY_PUBLIC]);
     if (!$madeDirectory) {
         throw new MakeDirectoryFailedException($file, error_get_last()['message']);
     }
     return $file;
 }
Exemplo n.º 2
0
 /**
  * @param FileNode $from
  * @param FileNode $to
  *
  * @return FileNode
  * @throws TransferFailedException
  */
 public function moveTo(FileNode $from, FileNode $to)
 {
     $mountManager = new MountManager(['from' => $from->getFilesystem(), 'to' => $to->getFilesystem()]);
     $this->log(LogLevel::INFO, "Moving file from: '{from}', to: '{to}'", ['from' => $from, 'to' => $to]);
     if (!$mountManager->move('from://' . $from->getPath(), 'to://' . $to->getPath())) {
         throw new TransferFailedException($from, $to);
     }
     return $to;
 }
Exemplo n.º 3
0
 public function testSetFileSystemUpdatesTheFileSystem()
 {
     $first = $this->getFilesystem();
     $second = $this->getFilesystem();
     $file = new FileNode($first, 'file/check');
     $first->shouldReceive('has')->with('file/check')->once()->andReturn(true);
     static::assertTrue($file->getFilesystem()->has('file/check'));
     $second->shouldReceive('has')->with('file/check')->once()->andReturn(false);
     static::assertSame($file, $file->setFilesystem($second));
     static::assertFalse($file->getFilesystem()->has('file/check'));
 }