summaryrefslogtreecommitdiffstats
path: root/src/common/fs/fs_util.cpp
diff options
context:
space:
mode:
authorboludoz <francomaro@gmail.com>2023-10-16 02:40:10 +0200
committerboludoz <francomaro@gmail.com>2023-10-16 02:40:10 +0200
commit74961d4dfb394c098da494f6beacdd994c089566 (patch)
tree40cfe9748d427047b758f4e4fe37036010c29026 /src/common/fs/fs_util.cpp
parentTyping and formatting errors fixed. (diff)
downloadyuzu-74961d4dfb394c098da494f6beacdd994c089566.tar
yuzu-74961d4dfb394c098da494f6beacdd994c089566.tar.gz
yuzu-74961d4dfb394c098da494f6beacdd994c089566.tar.bz2
yuzu-74961d4dfb394c098da494f6beacdd994c089566.tar.lz
yuzu-74961d4dfb394c098da494f6beacdd994c089566.tar.xz
yuzu-74961d4dfb394c098da494f6beacdd994c089566.tar.zst
yuzu-74961d4dfb394c098da494f6beacdd994c089566.zip
Diffstat (limited to '')
-rw-r--r--src/common/fs/fs_util.cpp59
1 files changed, 0 insertions, 59 deletions
diff --git a/src/common/fs/fs_util.cpp b/src/common/fs/fs_util.cpp
index e77958224..813a713c3 100644
--- a/src/common/fs/fs_util.cpp
+++ b/src/common/fs/fs_util.cpp
@@ -36,63 +36,4 @@ std::string PathToUTF8String(const std::filesystem::path& path) {
return ToUTF8String(path.u8string());
}
-std::u8string U8FilenameSanitizer(const std::u8string_view u8filename) {
- std::u8string u8path_sanitized{u8filename.begin(), u8filename.end()};
- size_t eSizeSanitized = u8path_sanitized.size();
-
- // The name is improved to make it look more beautiful and prohibited characters and shapes are
- // removed. Switch is used since it is better with many conditions.
- for (size_t i = 0; i < eSizeSanitized; i++) {
- switch (u8path_sanitized[i]) {
- case u8':':
- if (i == 0 || i == eSizeSanitized - 1) {
- u8path_sanitized.replace(i, 1, u8"_");
- } else if (u8path_sanitized[i - 1] == u8' ') {
- u8path_sanitized.replace(i, 1, u8"-");
- } else {
- u8path_sanitized.replace(i, 1, u8" -");
- eSizeSanitized++;
- }
- break;
- case u8'\\':
- case u8'/':
- case u8'*':
- case u8'?':
- case u8'\"':
- case u8'<':
- case u8'>':
- case u8'|':
- case u8'\0':
- u8path_sanitized.replace(i, 1, u8"_");
- break;
- default:
- break;
- }
- }
-
- // Delete duplicated spaces and dots
- for (size_t i = 0; i < eSizeSanitized - 1; i++) {
- if ((u8path_sanitized[i] == u8' ' && u8path_sanitized[i + 1] == u8' ') ||
- (u8path_sanitized[i] == u8'.' && u8path_sanitized[i + 1] == u8'.')) {
- u8path_sanitized.erase(i, 1);
- i--;
- }
- }
-
- // Delete all spaces and dots at the end of the name
- while (u8path_sanitized.back() == u8' ' || u8path_sanitized.back() == u8'.') {
- u8path_sanitized.pop_back();
- }
-
- if (u8path_sanitized.empty()) {
- return u8"";
- }
-
- return u8path_sanitized;
-}
-
-std::string UTF8FilenameSanitizer(const std::string_view filename) {
- return ToUTF8String(U8FilenameSanitizer(ToU8String(filename)));
-}
-
} // namespace Common::FS