MCPcopy Create free account
hub / github.com/Tencent/MMKV / encodeFilePath

Function encodeFilePath

Core/MMKV.cpp:1627–1645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1625}
1626
1627static 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
1647static MMKVPath_t encodeFilePath(const string &mmapID, const MMKVPath_t &rootDir) {
1648 const char *specialCharacters = "\\/:*?\"<>|";

Callers 1

mappedKVPathWithIDFunction · 0.85

Calls 3

md5Function · 0.85
string2MMKVPath_tFunction · 0.85
mkPathFunction · 0.70

Tested by

no test coverage detected