From 7c45d60e60659f6ef45bf29ec02208f74183f3d6 Mon Sep 17 00:00:00 2001 From: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com> Date: Mon, 26 May 2025 17:42:32 +0100 Subject: [PATCH] add nxmp and switch wave file assoc, remove old sphaira file assoc, replace ext/db assoc parse code with views::split --- assets/romfs/assoc/SwitchWave.ini | 2 ++ assets/romfs/assoc/nxmp.ini | 2 ++ assets/romfs/assoc/sphaira.ini | 2 -- sphaira/source/ui/menus/filebrowser.cpp | 32 ++++++++++--------------- 4 files changed, 17 insertions(+), 21 deletions(-) create mode 100644 assets/romfs/assoc/SwitchWave.ini create mode 100644 assets/romfs/assoc/nxmp.ini delete mode 100644 assets/romfs/assoc/sphaira.ini diff --git a/assets/romfs/assoc/SwitchWave.ini b/assets/romfs/assoc/SwitchWave.ini new file mode 100644 index 0000000..e932352 --- /dev/null +++ b/assets/romfs/assoc/SwitchWave.ini @@ -0,0 +1,2 @@ +[config] +supported_extensions=mp3|ogg|flac|wav|aac|ac3|aif|asf|mp4|mkv|m3u|m3u8|hls|vob|avi|dv|flv|m2ts|m2v|m4a|mov|mpeg|mpg|mts|swf|ts|vob|wma|wmv|png|jpg|jpeg|bmp|gif diff --git a/assets/romfs/assoc/nxmp.ini b/assets/romfs/assoc/nxmp.ini new file mode 100644 index 0000000..e932352 --- /dev/null +++ b/assets/romfs/assoc/nxmp.ini @@ -0,0 +1,2 @@ +[config] +supported_extensions=mp3|ogg|flac|wav|aac|ac3|aif|asf|mp4|mkv|m3u|m3u8|hls|vob|avi|dv|flv|m2ts|m2v|m4a|mov|mpeg|mpg|mts|swf|ts|vob|wma|wmv|png|jpg|jpeg|bmp|gif diff --git a/assets/romfs/assoc/sphaira.ini b/assets/romfs/assoc/sphaira.ini deleted file mode 100644 index bc79fa0..0000000 --- a/assets/romfs/assoc/sphaira.ini +++ /dev/null @@ -1,2 +0,0 @@ -[config] -ext=nro diff --git a/sphaira/source/ui/menus/filebrowser.cpp b/sphaira/source/ui/menus/filebrowser.cpp index efdef2c..449b668 100644 --- a/sphaira/source/ui/menus/filebrowser.cpp +++ b/sphaira/source/ui/menus/filebrowser.cpp @@ -2011,30 +2011,24 @@ void Menu::LoadAssocEntriesPath(const fs::FsPath& path) { ini_browse([](const mTCHAR *Section, const mTCHAR *Key, const mTCHAR *Value, void *UserData) { auto assoc = static_cast(UserData); - if (!strcmp(Key, "path")) { + if (!std::strcmp(Key, "path")) { assoc->path = Value; - } else if (!strcmp(Key, "supported_extensions")) { - for (int i = 0; Value[i]; i++) { - for (int j = i; ; j++) { - if (Value[j] == '|' || Value[j] == '\0') { - assoc->ext.emplace_back(Value + i, j - i); - i += j - i; - break; - } + } else if (!std::strcmp(Key, "supported_extensions")) { + for (const auto& p : std::views::split(std::string_view{Value}, '|')) { + if (p.empty()) { + continue; } + assoc->ext.emplace_back(p.data(), p.size()); } - } else if (!strcmp(Key, "database")) { - for (int i = 0; Value[i]; i++) { - for (int j = i; ; j++) { - if (Value[j] == '|' || Value[j] == '\0') { - assoc->database.emplace_back(Value + i, j - i); - i += j - i; - break; - } + } else if (!std::strcmp(Key, "database")) { + for (const auto& p : std::views::split(std::string_view{Value}, '|')) { + if (p.empty()) { + continue; } + assoc->database.emplace_back(p.data(), p.size()); } - } else if (!strcmp(Key, "use_base_name")) { - if (!strcmp(Value, "true") || !strcmp(Value, "1")) { + } else if (!std::strcmp(Key, "use_base_name")) { + if (!std::strcmp(Value, "true") || !std::strcmp(Value, "1")) { assoc->use_base_name = true; } }