static function _RecursiveUnlinkDir($dir,&$error,&$error_str){
		settype($dir,"string");
		
		$out = 0;

		if($error){
			return $out;
		}

		if($dir==""){ return; }

		if($dir[strlen($dir)-1]=="/"){
			$dir = preg_replace('/\/$/','',$dir);
		}

		if($dir==""){ return; }

		if(!file_exists($dir)){
			return 0;
		}

		$dir .= "/";
		$dir_handle = opendir($dir);
		if(!$dir_handle){
			return 0;
		}
		while(($item = readdir($dir_handle))!==false){
			if($item=="." || $item==".." || $item==""){
				continue;
			}
			if(is_dir($dir.$item)){
				$out += Files::_RecursiveUnlinkDir($dir.$item,$error,$error_str);
				//2005-10-21: nasledujici continue tady chybel, skript se proto chybne pokousel volat fci unlink na adresar
				continue;
			}
			if($error){ break; }
			//going to unlink file: $dir$item
			$stat = unlink("$dir$item");
			if(!$stat){
				$error = true;
				$error_str = "cannot unlink $dir$item";
			}else{
				$out++;
			}
		}
		
		closedir($dir_handle);
		if($error){ return; }
		//going to unlink dir: $dir$item
		$stat = rmdir($dir);
		if(!$stat){
			$error = true;
			$error_str = "cannot unlink $dir";
		}else{
			$out++;
		}
		return $out;
	}
static function _RecursiveUnlinkDir($dir,&$error,&$error_str){
		settype($dir,"string");
		
		$out = 0;

		if($error){
			return $out;
		}

		if($dir==""){ return; }

		if($dir[strlen($dir)-1]=="/"){
			$dir = preg_replace('/\/$/','',$dir);
		}

		if($dir==""){ return; }

		if(!file_exists($dir)){
			return 0;
		}

		$dir .= "/";
		$dir_handle = opendir($dir);
		if(!$dir_handle){
			return 0;
		}
		while(($item = readdir($dir_handle))!==false){
			if($item=="." || $item==".." || $item==""){
				continue;
			}
			if(is_dir($dir.$item)){
				$out += Files::_RecursiveUnlinkDir($dir.$item,$error,$error_str);
				//2005-10-21: nasledujici continue tady chybel, skript se proto chybne pokousel volat fci unlink na adresar
				continue;
			}
			if($error){ break; }
			//going to unlink file: $dir$item
			$stat = unlink("$dir$item");
			if(!$stat){
				$error = true;
				$error_str = "cannot unlink $dir$item";
			}else{
				$out++;
			}
		}
		
		closedir($dir_handle);
		if($error){ return; }
		//going to unlink dir: $dir$item
		$stat = rmdir($dir);
		if(!$stat){
			$error = true;
			$error_str = "cannot unlink $dir";
		}else{
			$out++;
		}
		return $out;
	}
static function _RecursiveUnlinkDir ( $ dir , & $ error , & $ error_str ) { settype ( $ dir , "string" ) ; $ out = 0 ; if ( $ error ) { return $ out ; } if ( $ dir == "" ) { return ; } if ( $ dir [ strlen ( $ dir ) - 1 ] == "/" ) { $ dir = preg_replace ( '/\/$/' , '' , $ dir ) ; } if ( $ dir == "" ) { return ; } if ( ! file_exists ( $ dir ) ) { return 0 ; } $ dir .= "/" ; $ dir_handle = opendir ( $ dir ) ; if ( ! $ dir_handle ) { return 0 ; } while ( ( $ item = readdir ( $ dir_handle ) ) !== false ) { if ( $ item == "." || $ item == ".." || $ item == "" ) { continue ; } if ( is_dir ( $ dir . $ item ) ) { $ out += Files :: _RecursiveUnlinkDir ( $ dir . $ item , $ error , $ error_str ) ; //2005-10-21: nasledujici continue tady chybel, skript se proto chybne pokousel volat fci unlink na adresar continue ; } if ( $ error ) { break ; } //going to unlink file: $dir$item $ stat = unlink ( "$dir$item" ) ; if ( ! $ stat ) { $ error = true ; $ error_str = "cannot unlink $dir$item" ; } else { $ out ++ ; } } closedir ( $ dir_handle ) ; if ( $ error ) { return ; } //going to unlink dir: $dir$item $ stat = rmdir ( $ dir ) ; if ( ! $ stat ) { $ error = true ; $ error_str = "cannot unlink $dir" ; } else { $ out ++ ; } return $ out ; }
Internal method making main part of RecursiveUnlinkDir call

@param string $dir Directory name
@param boolean &$error Error flag
@param string &$error_str Error description
@return int pocet smazanych souboru a adresaru
@ignore
@internal We should consider making this method private
Internal method making main part of RecursiveUnlinkDir call