/** @inheritdoc */ public function clean($validPackages) { foreach (Linq::from($this->filesystem->listContents($this->vendorDir))->where(function ($v) { return $v['type'] == 'dir'; }) as $vendor) { if (!Linq::from($validPackages)->any(function ($v, $k) use($vendor) { return preg_match('/^' . $vendor['basename'] . '/i', $k); })) { $this->notify("DELETING: " . $vendor['path'] . "\n"); $this->filesystem->deleteDir($vendor['path']); continue; } foreach (Linq::from($this->filesystem->listContents($vendor['path']))->where(function ($v) { return $v['type'] == 'dir'; }) as $package) { if (!Linq::from($validPackages)->any(function ($v, $k) use($vendor, $package) { return $k == $vendor['basename'] . '/' . $package['basename']; })) { $this->notify("DELETING: " . $package['path'] . "\n"); $this->filesystem->deleteDir($package['path']); continue; } foreach (Linq::from($this->filesystem->listContents($package['path']))->where(function ($v) { return $v['type'] == 'dir'; }) as $version) { if (!Linq::from($validPackages[$vendor['basename'] . '/' . $package['basename']])->any(function ($v) use($version) { return $v == $version['basename']; })) { $this->notify("DELETING: " . $version['path'] . "\n"); $this->filesystem->deleteDir($version['path']); } } } } }
public function uploadImagePreview(int $themeId, string $path) : string { $theme = $this->getThemeById($themeId); $dir = $theme->getId(); $name = sprintf('%s.png', GenerateRandomString::gen(self::GENERATE_FILENAME_LENGTH)); $newPath = sprintf('%s/%s', $dir, $name); if ($this->fileSystem->has($dir)) { $this->fileSystem->deleteDir($dir); } $this->fileSystem->write($newPath, file_get_contents($path)); $theme->setPreview($newPath); $this->themeRepository->saveTheme($theme); return $theme->getPreview(); }
/** * Delete cached manipulations for an image. * @param string $path Image path. * @return bool Whether the delete succeeded. */ public function deleteCache($path) { if (!$this->groupCacheInFolders) { throw new InvalidArgumentException('Deleting cached image manipulations is not possible when grouping cache into folders is disabled.'); } return $this->cache->deleteDir(dirname($this->getCachePath($path))); }
/** * Removes a folder in filesystem. * * @param string $folderIdentifier * @param bool $deleteRecursively * @return bool * @throws FileOperationErrorException */ public function deleteFolder($folderIdentifier, $deleteRecursively = false) { $folderIdentifier = ltrim($folderIdentifier, '/'); $result = $this->filesystem->deleteDir($folderIdentifier); if (false === $result) { throw new FileOperationErrorException('Deleting folder "' . $folderIdentifier . '" failed.', 1330119451); } return $result; }
/** @inheritdoc */ public function extract($zipBallPath, $to) { $absolutePathToZipBall = $this->filesystem->getAdapter()->applyPathPrefix($zipBallPath); if ($this->zip->open($absolutePathToZipBall) === true) { $absolutePathToExtract = $this->filesystem->getAdapter()->applyPathPrefix($to); $this->zip->extractTo($absolutePathToExtract); $this->zip->close(); $zipCreatedFolder = Linq::from($this->filesystem->listContents($to))->single(function ($object) { return $object['type'] == 'dir'; })['path']; foreach ($this->filesystem->listContents($zipCreatedFolder, true) as $object) { if ($object['type'] == "file") { $segments = explode('/', $object['path']); unset($segments[4]); $this->filesystem->rename($object['path'], implode('/', $segments)); } } $this->filesystem->deleteDir($zipCreatedFolder); return; } throw new ZipExtractionFailed($zipBall, $to); }
/** * {@inheritdoc} */ protected function removeEmptyDirectories($backupName) { /** * @var \SplFileInfo $dir */ foreach ($this->flysystem->listContents($backupName) as $dir) { if ($dir['type'] != 'dir') { continue; } if (count($this->flysystem->listContents($dir['path'])) > 0) { $this->removeEmptyDirectories($dir['path']); } else { $this->flysystem->deleteDir($dir['path']); } } }
/** * Erase a directory. * * @param string $dirname * @throws IoWriteException */ public function eraseDir($dirname = '') { try { $listing = $this->fs->listContents($dirname, false); foreach ($listing as $item) { if ($item['type'] === 'dir') { $this->fs->deleteDir($item['path']); } else { $this->fs->delete($item['path']); } } } catch (Error $ex) { throw new IoWriteException("Directory {$dirname} could not be erased.", $ex); } catch (Exception $ex) { throw new IoWriteException("Directory {$dirname} could not be erased.", $ex); } }
/** * Erase a directory. * * @param string $dirname * @throws WriteException */ private function ensuredEraseDir($dirname) { try { $listing = $this->fs->listContents($dirname, false); foreach ($listing as $item) { if ($item['type'] === 'dir') { $this->fs->deleteDir($item['path']); } else { $this->fs->delete($item['path']); } } return; } catch (Error $ex) { } catch (Exception $ex) { } throw new WriteException("Directory {$dirname} could not be erased.", $ex); }
/** * Recursively delete a directory. * * @param string $directory * @return bool */ public function deleteDirectory($directory) { return $this->driver->deleteDir($directory); }
/** * Remove dir * * @param string $path dir path * @return bool **/ protected function _rmdir($path) { return $this->fs->deleteDir($path); }
public function deleteDirectory($spiPath) { $this->filesystem->deleteDir($spiPath); }
/** * Delete cached manipulations for an image. * @param string $path Image path. * @return bool Whether the delete succeeded. */ public function deleteCache($path) { return $this->cache->deleteDir(dirname($this->getCachePath($path))); }
/** * @param \livetyping\hermitage\foundation\entities\Image $image * * @throws \livetyping\hermitage\foundation\exceptions\ImageNotFoundException */ public function delete(Image $image) { $this->assertPresent($image->getPath()); $this->filesystem->deleteDir($image->getDirname()); }
/** * 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) { return $this->fileSystem->deleteDir($dirname); }