get_backgrounds() as $file) self::blacken_image($file); } public static function remove_videos(osu_library $library) { foreach ($library->get_videos() as $file) { if (file_exists($file)) unlink($file); } } public static function remove_storyboards(osu_library $library) : void { foreach ($library->get_storyboards() as $file) { if (file_exists($file)) unlink($file); } foreach ($library->get_osb_files() as $file) { if (file_exists($file)) unlink($file); } $empty = self::build_empty_dir_list($library); foreach ($empty as $folder) { rmdir($folder); } } private static function build_removand_sublist(string $folder) : array { $queue = array(); foreach (glob(utils::globsafe($folder) . "/*") as $file) { if (is_dir($file)) { $queue = array_merge($queue, self::build_removand_sublist($file)); // recursion } else { $queue[] = $file; } } return $queue; } public static function build_removand_list(osu_library $library) : array { $queue = array(); foreach ($library->get_folders() as $folder) { $queue = array_merge($queue, self::build_removand_sublist($folder)); } return $queue; } public static function build_excluded_list(osu_library $library) : array { $background_files = $library->get_backgrounds(); $video_files = $library->get_videos(); $audio_files = $library->get_audiofiles(); $storyboard_files = $library->get_storyboards(); $hitsound_files = $library->get_hitsounds(); // $osu_files = $library->get_osu_files(); // $osb_files = $library->get_osb_files(); $physical_excluded = $library->get_parsed_files(); $essential_excluded = array_merge($background_files, $video_files, $audio_files); // $physical_excluded = array_merge($osb_files, $osu_files); $other_excluded = array_merge($storyboard_files, $hitsound_files); $excluded = array_merge($essential_excluded, $physical_excluded, $other_excluded); return $excluded; } public static function cut_extension(string $path) : string { $directory = pathinfo($path, PATHINFO_DIRNAME) ?? ""; if (!empty($directory)) $directory .= "/"; // append slash if set return $directory . (pathinfo($path, PATHINFO_FILENAME) ?? ""); } // because peppy thinks file extensions are wildcards: // you can have image.mp3 in storyboards in jfif // and you can have ogg vorbis hitsounds in mysound.wav.png.whatever public static function array_diff_ver_peppy(array $files, array $exclusions) : array { // osu! is case insensitive $files_lowercase = array(); foreach ($files as $key => $value) { $files_lowercase[$key] = self::cut_extension(mb_strtolower($value)); } $exclusions_lowercase = array(); foreach ($exclusions as $key => $value) { $exclusions_lowercase[$key] = self::cut_extension(mb_strtolower($value)); } // return values from the original, but only the ones that did not get removed return array_intersect_key($files, array_diff($files_lowercase, $exclusions_lowercase)); } public static function remove_other(osu_library $library) : void { $removand = self::build_removand_list($library); $exclusions = self::build_excluded_list($library); $junk_files = self::array_diff_ver_peppy($removand, $exclusions); foreach ($junk_files as $file) { if (self::is_skinnable($file)) continue; // ignore default hitsounds // if (file_exists($file)) unlink($file); echo $file . "
"; } exit(0); $empty = self::build_empty_dir_list($library); foreach ($empty as $folder) { rmdir($folder); } } }