コード例 #1
0
ファイル: Packager.php プロジェクト: jpbender/mage_virtual
 /**
  * Remove empty directories recursively up
  * @param string $dir
  * @param Mage_Connect_Ftp $ftp
  */
 protected function removeEmptyDirectory($dir, $ftp = null)
 {
     if ($ftp) {
         if (count($ftp->nlist($dir)) == 0) {
             if ($ftp->rmdir($dir)) {
                 $this->removeEmptyDirectory(dirname($dir), $ftp);
             }
         }
     } else {
         if (@rmdir($dir)) {
             $this->removeEmptyDirectory(dirname($dir), $ftp);
         }
     }
 }
コード例 #2
0
ファイル: Packager.php プロジェクト: okite11/frames21
 /**
  * Remove empty directories recursively up
  *
  * @param string $dir
  * @param Mage_Connect_Ftp $ftp
  */
 protected function removeEmptyDirectory($dir, $ftp = null)
 {
     if ($ftp) {
         if (count($ftp->nlist($dir)) == 0) {
             if ($ftp->rmdir($dir)) {
                 $this->removeEmptyDirectory(dirname($dir), $ftp);
             }
         }
     } else {
         $content = scandir($dir);
         if ($content === false) {
             return;
         }
         if (count(array_diff($content, array('.', '..'))) == 0) {
             if (@rmdir($dir)) {
                 $this->removeEmptyDirectory(dirname($dir), $ftp);
             } else {
                 throw new RuntimeException('Failed to delete dir ' . $dir . "\r\n Check permissions");
             }
         }
     }
 }