Thursday, 25 March 2010 12:35
You'll have to adapt this a bit - it's written as if these are class functions (notice the $this->recursiveDelete)...
function cleanPackageRoot( $subdir='' )
{
  if( strlen( $subdir ) ) $subdir .= DS;
  $dh = opendir( $this->packageroot.$subdir );
  while( ( $file = readdir( $dh ) ) !== false )
  {
    if( preg_match( '`^install`', $file ) )
    {
      $this->recursiveDelete( $this->packageroot.$subdir.$file );
    }
  }
  closedir($dh);
}
// http://www.php.net/manual/en/function.unlink.php#94766
function recursiveDelete( $str )
{
  if( is_file( $str ) )
  {
    return @unlink( $str );
  }
  elseif( is_dir( $str ) )
  {
    $scan = glob( rtrim( $str, '/' ).'/*' );
    if( $scan )
    {
      foreach( $scan as $index => $path )
      {
        $this->recursiveDelete( $path );
      }
    }
    return @rmdir($str);
  }
}
Last Updated on Thursday, 25 March 2010 12:46
 

The Joomla!® name is used under a limited license from Open Source Matters in the United States and other countries. Jeff Channell is not affiliated with or endorsed by Open Source Matters or the Joomla!® Project.

Santorum
Joomla Extensions