Ejemplo n.º 1
0
 protected function setupRootDirectory()
 {
     if (isset($this->settings['id'])) {
         $dir = static::computeRootDirectory($this->settings['id']);
     } else {
         $dir = Filesystem::createDirectory(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'k2' . DIRECTORY_SEPARATOR . UUID::createRandom());
     }
     if (empty($this->settings['persistent'])) {
         register_shutdown_function(function () use($dir) {
             if (is_dir($dir)) {
                 @Filesystem::removeDirectory($dir);
             }
         });
     }
     return $dir;
 }
Ejemplo n.º 2
0
 public function deleteResource(ResourceInterface $resource)
 {
     if ($resource instanceof FilesystemFile) {
         Filesystem::removeFile($resource->getFileInfo()->getPathname());
     } elseif ($resource instanceof FilesystemDirectory) {
         Filesystem::removeDirectory($resource->getFileInfo()->getPathname());
     } else {
         throw new \InvalidArgumentException(sprintf('Resource "%s" is no filesystem resource', $resource->getPath()));
     }
 }
Ejemplo n.º 3
0
 protected function setupRootDirectory()
 {
     $dir = Filesystem::createDirectory(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'k2' . DIRECTORY_SEPARATOR . UUID::createRandom());
     // TODO: Directory is not being removed when console is terminated using CRTL+C kill signal...
     register_shutdown_function(function () use($dir) {
         if (is_dir($dir)) {
             @Filesystem::removeDirectory($dir);
         }
     });
     return $dir;
 }