public static function rmdir($path, $removeNonEmpty = FALSE) {
		$OK = FALSE;
		$path = preg_replace('|/$|', '', $path); // Remove trailing slash

		if (file_exists($path)) {
			$OK = TRUE;

			if (is_dir($path)) {
				if ($removeNonEmpty == TRUE && $handle = opendir($path)) {
					while ($OK && FALSE !== ($file = readdir($handle))) {
						if ($file == '.' || $file == '..') {
							continue;
						}
						$OK = self::rmdir($path . '/' . $file, $removeNonEmpty);
					}
					closedir($handle);
				}
				if ($OK) {
					$OK = rmdir($path);
				}

			} else { // If $dirname is a file, simply remove it
				$OK = unlink($path);
			}

			clearstatcache();
		}

		return $OK;
	}