Exemple #1
1
 /**
  * Remove file or a directory
  *
  * @param $path
  * @return void
  */
 public function remove($path)
 {
     if (!$this->filesystem->has($path)) {
         return;
     }
     $meta = $this->filesystem->getMetadata($path);
     if ($meta['type'] === 'file') {
         $this->filesystem->delete($path);
     } else {
         $this->filesystem->deleteDir($path);
     }
 }
 /**
  * @return bool
  */
 public function execute()
 {
     if ($this->filesystem->getMimetype($this->filePath) == 'application/x-gzip') {
         if ($this->filesystem->getMimetype(str_replace('.tar.gz', '', $this->filePath)) == 'directory') {
             $this->filesystem->deleteDir(str_replace('.tar.gz', '', $this->filePath));
         }
     }
     if ($this->filesystem->getMimetype($this->filePath) == 'directory') {
         return $this->filesystem->deleteDir($this->filePath);
     } else {
         return $this->filesystem->delete($this->filePath);
     }
 }
Exemple #3
0
	/**
	 * {@inheritdoc}
	 */
	public function rmdir($path) {
		try {
			return @$this->flysystem->deleteDir($this->buildPath($path));
		} catch (FileNotFoundException $e) {
			return false;
		}
	}
 /**
  * Delete a directory.
  *
  * @param string $dirname
  *
  * @throws RootViolationException Thrown if $dirname is empty.
  *
  * @return bool True on success, false on failure.
  */
 public function deleteDir($dirname)
 {
     try {
         return $this->filesystem->deleteDir($dirname);
     } catch (FlysystemRootViolationException $e) {
         RootViolationException::rootViolation();
     }
 }
Exemple #5
0
 /**
  * Clean the cache dir.
  *
  * @throws \DomainException
  * @return void
  */
 public static function cleanCache()
 {
     $filesystem = new Filesystem(new Local(self::$cacheDir));
     foreach ($filesystem->listContents() as $path) {
         if ('dir' == $path['type']) {
             if (false == $filesystem->deleteDir($path['path'])) {
                 throw new \DomainException('Can not clean the cache.');
             }
         }
     }
 }
 /**
  * @inheritdoc
  */
 public function deleteDir($dirname)
 {
     $innerDirname = $this->getInnerPath($dirname);
     try {
         $return = $this->fileSystem->deleteDir($innerDirname);
     } catch (RootViolationException $e) {
         throw $this->exceptionWrapper($e, $dirname);
     }
     if ($return !== false) {
         $this->invokePlugin("removePathFromIndex", [$dirname, $innerDirname], $this);
     }
     return $return;
 }
 /**
  * Clean up remote files.
  *
  * @return void
  */
 public function cleanupRemote()
 {
     if (isset($this->config->keepfor)) {
         $remotePath = './' . $this->dump_folder;
         $directories = $this->remoteAdapter->listContents($remotePath);
         $timestamp = date('YmdHi', time() - (time() - strtotime($this->config->keepfor . ' ago')));
         foreach ($directories as $dir) {
             if ($dir['filename'] < $timestamp) {
                 $this->remoteAdapter->deleteDir($dir['path']);
             }
         }
     }
 }
 private function handleOptions()
 {
     if ($this->delete) {
         $this->getItemsToDelete()->each(function ($item) {
             if ($item['type'] === 'dir') {
                 dump($item);
                 $this->filesystem->deleteDir($item['path']);
                 return true;
             }
             $this->filesystem->delete($item['path']);
             return true;
         });
     }
 }
Exemple #9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     if ($this->abortDeletion($path, $output)) {
         $output->writeln("<comment>Aborted.</comment>");
         return;
     }
     $package = Package::fromFolder($path);
     $this->config->removePackage($package);
     $output->writeln("<comment>Removing package...</comment>");
     $filesystem = new Filesystem(new Local(getcwd()));
     $filesystem->deleteDir($path);
     $output->writeln("<info>Package successfully removed.</info>");
     $output->writeln("<comment>Dumping autoloads...</comment>");
     Shell::run('composer dump-autoload');
     $output->writeln("<info>Autoloads successfully generated.</info>");
 }
Exemple #10
0
 public function testConvertCommandWithNamespaceOption()
 {
     $codeLocation = __DIR__ . '/mock/src/VendorName/ProjectName/Category/ProductName/v123456/';
     $codeLocationArray = explode('/', $codeLocation);
     $codeLocationArray = array_splice($codeLocationArray, 6, 4);
     $directory = $codeLocationArray[0];
     $destinationLocation = implode('/', $codeLocationArray);
     $codeDestination = '/tmp/';
     $input = new ArrayInput(['convert', 'code-location' => $codeLocation, '--code-destination' => '/tmp', '--create-namespace' => true, '--offset' => 6, '--length' => 4]);
     $output = new BufferedOutput();
     $app = new Application();
     $app->get('convert')->run($input, $output);
     $this->assertFileExists(sprintf('/%s/%s/Date.php', $codeDestination, $destinationLocation));
     $this->assertFileExists(sprintf('/%s/%s/DateRange.php', $codeDestination, $destinationLocation));
     $this->assertFileExists(sprintf('/%s/%s/OrderBy.php', $codeDestination, $destinationLocation));
     // Delete all files/
     $filesystem = new Filesystem(new Local($codeDestination));
     $filesystem->deleteDir($directory);
 }
 /**
  * @param string[] $paths   The paths where the original files are expected to be.
  * @param string[] $filters The imagine filters in effect.
  */
 public function remove(array $paths, array $filters)
 {
     if (empty($paths) && empty($filters)) {
         return;
     }
     if (empty($paths)) {
         foreach ($filters as $filter) {
             $filterCacheDir = $this->cacheRoot . '/' . $filter;
             $this->flysystem->deleteDir($filterCacheDir);
         }
         return;
     }
     foreach ($paths as $path) {
         foreach ($filters as $filter) {
             if ($this->flysystem->has($this->getFilePath($path, $filter))) {
                 $this->flysystem->delete($this->getFilePath($path, $filter));
             }
         }
     }
 }
Exemple #12
0
 public function deleteDir($directory)
 {
     $this->flysystem->deleteDir($directory);
 }
Exemple #13
0
 private function deleteFiles($codeDestination, $directory)
 {
     // Delete all files/
     $filesystem = new Filesystem(new Local($codeDestination));
     $filesystem->deleteDir($directory);
 }
 public function destroyCMS($identifier)
 {
     $adapter = new Local($this->container_path);
     $filesystem = new Filesystem($adapter);
     if ($this->checkExistance($identifier)) {
         if ($this->saveAsZip($identifier)) {
             $filesystem->deleteDir($identifier);
             return true;
         }
     }
     return false;
 }
 /**
  * 3.txt
  * 2.txt.
  */
 public function testDeleteDir()
 {
     $this->assertTrue($this->filesystem->deleteDir('test'));
     $this->assertFalse($this->filesystem->has('test/'));
 }
 /** @inheritdoc */
 public function import($request)
 {
     $_from = null;
     $_instance = $request->getInstance();
     $_mount = $_instance->getStorageMount();
     $this->info('[provisioning:storage:import] instance "' . $_instance->instance_id_text . '" begin');
     //  Grab the target (zip archive) and pull out the target of the import
     $_zip = $request->getTarget();
     /** @var \ZipArchive $_archive */
     /** @noinspection PhpUndefinedMethodInspection */
     $_archive = $_zip->getAdapter()->getArchive();
     $_path = null;
     foreach ($_zip->listContents() as $_file) {
         if ('dir' != $_file['type'] && false !== strpos($_file['path'], '.storage.zip')) {
             $_from = Disk::segment([sys_get_temp_dir(), 'dfe', 'import', sha1($_file['path'])], true);
             if (!$_archive->extractTo($_from, $_file['path'])) {
                 throw new \RuntimeException('Unable to unzip archive file "' . $_file['path'] . '" from snapshot.');
             }
             $_path = Disk::path([$_from, $_file['path']], false);
             if (!$_path || !file_exists($_path)) {
                 throw new \InvalidArgumentException('$from file "' . $_file['path'] . '" missing or unreadable.');
             }
             $_from = new Filesystem(new ZipArchiveAdapter($_path));
             break;
         }
     }
     if (!$_mount instanceof Filesystem) {
         $_mount = new Filesystem(new ZipArchiveAdapter($_mount));
     }
     //  If "clean" == true, storage is wiped clean before restore
     if (true === $request->get('clean', false)) {
         $_mount->deleteDir('./');
     }
     //  Extract the files
     $_restored = [];
     /** @type Filesystem $_archive */
     foreach ($_from->listContents() as $_file) {
         $_filename = $_file['path'];
         if ('dir' == array_get($_file, 'type')) {
             $_mount->createDir($_filename);
         } else {
             $_mount->writeStream($_filename, $_archive->readStream($_filename));
         }
         $_restored[] = $_file;
     }
     unset($_from);
     $_path && is_dir(dirname($_path)) && Disk::deleteTree(dirname($_path));
     //  Fire off a "storage.imported" event...
     \Event::fire('dfe.storage.imported', [$this, $request]);
     $this->info('[provisioning:storage:import] instance "' . $_instance->instance_id_text . '" complete');
     return $_restored;
 }
 /**
  * Removes temporary directory
  *
  * @throws \League\Flysystem\FileExistsException
  */
 public function __destruct()
 {
     $fs = new Filesystem(new Local(dirname($this->getPathPrefix())));
     $fs->deleteDir(basename($this->getPathPrefix()));
     $fs->assertAbsent($this->getPathPrefix());
 }
 /**
  * @inheritdoc
  */
 protected function _rmdir($path)
 {
     return $this->fs->deleteDir($path);
 }
 public function testDeleteDir()
 {
     $this->prophecy->deleteDir('dirname')->willReturn(true);
     $response = $this->filesystem->deleteDir('dirname');
     $this->assertTrue($response);
 }
 /**
  * Delete a directory.
  *
  * @param string $dirname
  *
  * @throws RootViolationException Thrown if $dirname is empty.
  *
  * @return bool True on success, false on failure.
  */
 public function deleteDir($dirname)
 {
     $result = parent::deleteDir($dirname);
     if ($result && ($resource = $this->get($dirname))) {
         return $this->dispatch(new DeleteFolder($resource));
     }
     return $result;
 }
 /**
  * Removes a folder from oc
  * @param string $directoryName
  *
  * @return bool
  */
 public function removeDirectory($directoryName)
 {
     return $this->fs->deleteDir($directoryName);
 }
Exemple #22
0
 /**
  * Deletes a directory.
  *
  * @param string $dirname
  *
  * @return bool
  */
 public function deleteDir($dirname)
 {
     $baseAdapter = $this->getBaseAdapter();
     // For FTP first remove recursively all directory contents
     if ($baseAdapter instanceof Ftp) {
         $this->deleteContents($dirname);
     }
     return parent::deleteDir($dirname);
 }
 /**
  * Clear directory if it's empty
  *
  * @param string $dirname Name of directory
  * @param Filesystem $filesystem
  */
 protected function truncateDirectory($dirname, Filesystem $filesystem)
 {
     if ($dirname && ltrim(dirname($dirname), '.') && !Config::inst()->get(get_class($this), 'keep_empty_dirs') && !$filesystem->listContents($dirname)) {
         $filesystem->deleteDir($dirname);
     }
 }
Exemple #24
0
 private function cleanup()
 {
     if ($this->keepFiles) {
         // Don't cleanup
         return $this;
     }
     $filesystem = new Filesystem(new Local($this->outPath));
     $filesystem->deleteDir('zips');
     $filesystem->createDir('zips');
     $filesystem->deleteDir('sources');
     $filesystem->createDir('sources');
     return $this;
 }
 function tearDown()
 {
     $flysystem = new Filesystem(new Local(MY_DRINKS_VAR_DIR));
     $flysystem->deleteDir('tmp');
 }
Exemple #26
0
 /**
  * Clear current dir
  */
 public function deleteAll()
 {
     foreach (parent::listContents() as $value) {
         if (!isset($value['type']) || $value['type'] === self::TYPE_DIR) {
             parent::deleteDir($value['path']);
             continue;
         }
         parent::delete($value['path']);
     }
 }