Exemplo n.º 1
0
 /**
  * Clear destination folder
  */
 public function clear()
 {
     if ($this->files->exists($this->destination)) {
         $this->files->remove($this->destination);
     }
     $this->files->mkdir($this->destination);
 }
Exemplo n.º 2
0
 public static function clearDrupal()
 {
     if (FALSE === is_dir(self::$drupalPath)) {
         return;
     }
     self::$filesystem->chmod(self::$drupalPath, 0777, 00, TRUE);
     self::$filesystem->remove(self::$drupalPath);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln("<error>Be carreful, you might removes files you don't want to. You should backup your files beforehand to be sure everything still works as intended.</error>");
     $force = $input->getOption('force');
     $container = $this->getContainer();
     $fs = new FileSystem();
     $helper = $this->getHelper('question');
     //Parse the file directory and fetch the other directories
     //We should find Workspaces and Users. Workspaces being formatted like "WORKSPACE_[ID]
     $fileDir = $container->getParameter('claroline.param.files_directory');
     $iterator = new \DirectoryIterator($fileDir);
     foreach ($iterator as $pathinfo) {
         if ($pathinfo->isDir()) {
             $name = $pathinfo->getBasename();
             //look for workspaces
             if (strpos('_' . $name, 'WORKSPACE')) {
                 $parts = explode('_', $name);
                 $id = $parts[1];
                 $workspace = $container->get('claroline.manager.workspace_manager')->getWorkspaceById($id);
                 if (!$workspace) {
                     $continue = false;
                     if (!$force) {
                         $question = new ConfirmationQuestion('Do you really want to remove the directory ' . $pathinfo->getPathname() . ' [y/n] y ', true);
                         $continue = $helper->ask($input, $output, $question);
                     }
                     if ($continue || $force) {
                         $fs->remove($pathinfo->getPathname());
                     }
                 }
             }
         }
     }
 }
 public function connect(Application $app)
 {
     // creates a new controller based on the default route
     $controllers = $app['controllers_factory'];
     $names = [];
     foreach ($this->faculty->professors as $professor) {
         $names[] = $professor->name;
     }
     $fs = new FileSystem();
     $fs->remove($this->faculty->baseCacheDestination);
     $names = '(' . implode('|', $names) . ')';
     $faculty = $this->faculty;
     $controllers->get('/{processor}/{path}', function (Application $app, $processor, $path) use($faculty) {
         $exten = [];
         preg_match($faculty->extenstions, $path, $exten);
         $exten = ltrim($exten[0], '.');
         if (empty($exten)) {
             return $app->abort(404);
         }
         $faculty->process($processor, $path);
         $imagePath = $faculty->getLastProcessed()[0];
         return $app->sendFile($imagePath, 200, array('Content-Type' => 'image/' . $exten));
     })->assert('path', $this->faculty->extenstions);
     return $controllers;
 }
Exemplo n.º 5
0
 public function cleanupClientSpec()
 {
     $client = $this->getClient();
     $command = 'p4 client -d $client';
     $this->executeCommand($command);
     $clientSpec = $this->getP4ClientSpec();
     $fileSystem = new FileSystem($this->process);
     $fileSystem->remove($clientSpec);
 }
 /**
  * @DI\Observe("kernel.terminate")
  */
 public function onKernelTerminate(PostResponseEvent $event)
 {
     if (count($this->elementsToRemove) > 0) {
         $fs = new FileSystem();
         foreach ($this->elementsToRemove as $element) {
             $fs->remove($element);
         }
     }
 }
Exemplo n.º 7
0
 public function removeModuleFromDisk($name)
 {
     $fs = new FileSystem();
     try {
         $fs->remove(_PS_MODULE_DIR_ . '/' . $name);
         return true;
     } catch (IOException $e) {
         return false;
     }
 }
Exemplo n.º 8
0
 public static function emptyDir($dirPath, $includeDir = false)
 {
     $fileSystem = new FileSystem();
     if (!$fileSystem->exists($dirPath)) {
         return;
     }
     foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dirPath, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $path) {
         $path->isFile() ? $fileSystem->remove($path->getPathname()) : rmdir($path->getPathname());
     }
     if ($includeDir) {
         rmdir($dirPath);
     }
 }
Exemplo n.º 9
0
 /**
  * Write the docker-compose.yml file.
  *
  * @return bool
  */
 public function writeConfig()
 {
     // Create the app/environment folder
     $fs = new FileSystem();
     try {
         $fs->mkdir($this->getDockerComposePath());
     } catch (IOExceptionInterface $e) {
         return false;
     }
     // Create the environments docker-compose file.
     $dumper = new Dumper();
     try {
         $fs->remove($this->getDockerComposePath() . '/docker-compose.yml');
         $fs->dumpFile($this->getDockerComposePath() . '/docker-compose.yml', $dumper->dump($this->getDockerComposeArray(), 10));
         return true;
     } catch (IOExceptionInterface $e) {
         return false;
     }
 }
Exemplo n.º 10
0
 public function tearDown()
 {
     $fs = new FileSystem();
     $fs->remove($this->tmpDir);
 }
Exemplo n.º 11
0
 public function removeTemplate(File $file)
 {
     $fileName = $file->getBasename();
     $extractPath = $this->templateDirectory . DIRECTORY_SEPARATOR . $fileName;
     $fs = new FileSystem();
     $fs->remove($extractPath);
 }
 /**
  * @param $file
  * @return StandardResponseInterface
  */
 public function deleteFile($file)
 {
     $fullPath = $this->getRealPath($file);
     $this->fs->remove($fullPath);
     return new StandardResponse();
 }
Exemplo n.º 13
0
 /**
  * Remove a file from the filesystem by hash
  * @param  [string] $relativePath
  */
 public function removeFile($relativePath)
 {
     $this->fileSystem->remove($this->getPath($relativePath));
 }
Exemplo n.º 14
0
 /**
  * Remove a file from the file system by hash
  * @param string $hash
  */
 public function removeFile($hash)
 {
     $this->fileSystem->remove($this->getPath($hash));
 }