private function removeEmptyDirs($theDirName)
  {
    $entries = scandir($theDirName, SCANDIR_SORT_ASCENDING);
    if ($entries===false) $this->logError("Unable to scan directory %s", $theDirName);

    foreach ($entries as $i => $entry)
    {
      $path = $theDirName.'/'.$entry;

      if ($entry=='.' || $entry=='..')
      {
        unset($entries[$i]);
      }
      elseif (is_dir($path))
      {
        $empty = $this->removeEmptyDirs($path);
        if ($empty)
        {
          unset($entries[$i]);

          $this->removeDir($path);
        }
      }
    }

    return empty($entries);
  }
private function removeEmptyDirs($theDirName)
  {
    $entries = scandir($theDirName, SCANDIR_SORT_ASCENDING);
    if ($entries===false) $this->logError("Unable to scan directory %s", $theDirName);

    foreach ($entries as $i => $entry)
    {
      $path = $theDirName.'/'.$entry;

      if ($entry=='.' || $entry=='..')
      {
        unset($entries[$i]);
      }
      elseif (is_dir($path))
      {
        $empty = $this->removeEmptyDirs($path);
        if ($empty)
        {
          unset($entries[$i]);

          $this->removeDir($path);
        }
      }
    }

    return empty($entries);
  }
private function removeEmptyDirs ( $ theDirName ) { $ entries = scandir ( $ theDirName , SCANDIR_SORT_ASCENDING ) ; if ( $ entries === false ) $ this -> logError ( "Unable to scan directory %s" , $ theDirName ) ; foreach ( $ entries as $ i => $ entry ) { $ path = $ theDirName . '/' . $ entry ; if ( $ entry == '.' || $ entry == '..' ) { unset ( $ entries [ $ i ] ) ; } elseif ( is_dir ( $ path ) ) { $ empty = $ this -> removeEmptyDirs ( $ path ) ; if ( $ empty ) { unset ( $ entries [ $ i ] ) ; $ this -> removeDir ( $ path ) ; } } } return empty ( $ entries ) ; }
Removes recursively empty directories under a parent directory.

@param string $theDirName The parent directory.

@return bool True if the parent directory is empty. Otherwise false.
@throws BuildException
Removes recursively empty directories under a parent directory .