| 1625 | } |
| 1626 | |
| 1627 | static MMKVPath_t encodeFilePath(const string &mmapID) { |
| 1628 | const char *specialCharacters = "\\/:*?\"<>|"; |
| 1629 | string encodedID; |
| 1630 | bool hasSpecialCharacter = false; |
| 1631 | for (auto ch : mmapID) { |
| 1632 | if (strchr(specialCharacters, ch) != nullptr) { |
| 1633 | encodedID = md5(mmapID); |
| 1634 | hasSpecialCharacter = true; |
| 1635 | break; |
| 1636 | } |
| 1637 | } |
| 1638 | if (hasSpecialCharacter) { |
| 1639 | static ThreadOnceToken_t once = ThreadOnceUninitialized; |
| 1640 | ThreadLock::ThreadOnce(&once, mkSpecialCharacterFileDirectory); |
| 1641 | return MMKVPath_t(SPECIAL_CHARACTER_DIRECTORY_NAME) + MMKV_PATH_SLASH + string2MMKVPath_t(encodedID); |
| 1642 | } else { |
| 1643 | return string2MMKVPath_t(mmapID); |
| 1644 | } |
| 1645 | } |
| 1646 | |
| 1647 | static MMKVPath_t encodeFilePath(const string &mmapID, const MMKVPath_t &rootDir) { |
| 1648 | const char *specialCharacters = "\\/:*?\"<>|"; |
no test coverage detected