예제 #1
0
 public function rmdir($path)
 {
     $fullPath = $this->getFullPath($path);
     if (!file_exists($fullPath)) {
         throw FileException::ENOENT();
     } elseif (!is_dir($fullPath)) {
         throw FileException::ENOTDIR();
     }
     $dh = opendir($fullPath);
     try {
         while ($item = readdir($dh)) {
             if ($item != '.' && $item != '..') {
                 throw FileException::ENOTEMPTY();
             }
         }
     } finally {
         closedir($dh);
     }
     return rmdir($fullPath);
 }
예제 #2
0
 public function rmdir($path)
 {
     $path = Util\Path::normalise("/{$path}");
     $parentPath = dirname($path);
     $base = basename($path);
     $parentMemNode = $this->getInternalNode($parentPath);
     if (!$parentMemNode || !isset($parentMemNode->data[$base])) {
         throw FileException::ENOENT();
     }
     $memNode = $parentMemNode->data[$base];
     if ($memNode->node->type != Node::DIR) {
         throw FileException::ENOTDIR();
     }
     if ($memNode->len > 0) {
         throw FileException::ENOTEMPTY();
     }
     unset($parentMemNode->data[$base]);
     return true;
 }