Ejemplo n.º 1
1
 public function process(FileInfo $path)
 {
     if (mb_strlen($path->getPathname()) < 5) {
         throw new DirectoryCleanerException('For security reasons, path must be at least 5 chars long', DirectoryCleanerException::SecurityLimitation);
     }
     if (!$path->exists()) {
         return;
     }
     $worker = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path->getPathname(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($worker as $entry) {
         if ($entry->isDir() && !$entry->isLink()) {
             rmdir($entry->getPathname());
         } else {
             unlink($entry->getPathname());
         }
     }
     rmdir($path);
 }
Ejemplo n.º 2
1
 public function process(FileInfo $path)
 {
     if (mb_strlen($path->getPathname()) < 5) {
         throw new DirectoryCleanerException('For security reasons, path must be at least 5 chars long', DirectoryCleanerException::SecurityLimitation);
     }
     if (!file_exists($path)) {
         return;
     }
     $worker = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path->getPathname()));
     foreach ($worker as $x) {
         if ($x->getFilename() == "." || $x->getFilename() == "..") {
             continue;
         }
         if ($x->isDir()) {
             $this->clearDirectory(new FileInfo($x->getPathname()));
         }
         unlink($x->getPathname());
     }
 }
Ejemplo n.º 3
0
 /**
  * The pathname of the current entry
  *
  * @return string
  */
 public function key()
 {
     return $this->currentEntry ? $this->currentEntry->getPathname() : null;
 }