| 97 | } |
| 98 | |
| 99 | MMKV_EXPORT void *getMMKVWithID(const char *mmapID, int32_t mode, const char *cryptKey, const char *rootPath, |
| 100 | uint64_t expectedCapacity, bool fromNameSpace, bool aes256, int32_t enableKeyExpire, |
| 101 | int32_t expiredInSeconds, bool enableCompareBeforeSet, int32_t recover, |
| 102 | uint32_t itemSizeLimit) { |
| 103 | MMKV *kv = nullptr; |
| 104 | if (!mmapID) { |
| 105 | return kv; |
| 106 | } |
| 107 | auto str = string(mmapID); |
| 108 | |
| 109 | auto config = MMKVConfig(); |
| 110 | config.mode = (MMKVMode) mode; |
| 111 | config.aes256 = aes256; |
| 112 | config.expectedCapacity = expectedCapacity; |
| 113 | if (enableKeyExpire >= 0) { |
| 114 | config.enableKeyExpire = (enableKeyExpire != 0); |
| 115 | } |
| 116 | config.expiredInSeconds = expiredInSeconds; |
| 117 | config.enableCompareBeforeSet = enableCompareBeforeSet; |
| 118 | if (recover >= 0) { |
| 119 | config.recover = static_cast<MMKVRecoverStrategic>(recover); |
| 120 | } |
| 121 | config.itemSizeLimit = itemSizeLimit; |
| 122 | |
| 123 | bool done = false; |
| 124 | if (cryptKey) { |
| 125 | string crypt = cryptKey; |
| 126 | if (crypt.length() > 0) { |
| 127 | config.cryptKey = &crypt; |
| 128 | if (rootPath) { |
| 129 | auto path = string(rootPath); |
| 130 | if (fromNameSpace) { |
| 131 | auto ns = MMKV::nameSpace(path); |
| 132 | config.rootPath = &ns.getRootDir(); |
| 133 | kv = ns.mmkvWithID(str, config); |
| 134 | } else { |
| 135 | config.rootPath = &path; |
| 136 | kv = MMKV::mmkvWithID(str, config); |
| 137 | } |
| 138 | } else { |
| 139 | kv = MMKV::mmkvWithID(str, config); |
| 140 | } |
| 141 | done = true; |
| 142 | } |
| 143 | } |
| 144 | if (!done) { |
| 145 | if (rootPath) { |
| 146 | auto path = string(rootPath); |
| 147 | if (fromNameSpace) { |
| 148 | auto ns = MMKV::nameSpace(path); |
| 149 | config.rootPath = &ns.getRootDir(); |
| 150 | kv = ns.mmkvWithID(str, config); |
| 151 | } else { |
| 152 | config.rootPath = &path; |
| 153 | kv = MMKV::mmkvWithID(str, config); |
| 154 | } |
| 155 | } else { |
| 156 | kv = MMKV::mmkvWithID(str, config); |
nothing calls this directly
no test coverage detected