| 322 | } |
| 323 | |
| 324 | bool mkPath(const MMKVPath_t &str) { |
| 325 | wchar_t *path = _wcsdup(str.c_str()); |
| 326 | |
| 327 | bool done = false; |
| 328 | wchar_t *slash = path; |
| 329 | |
| 330 | while (!done) { |
| 331 | slash += wcsspn(slash, L"\\"); |
| 332 | slash += wcscspn(slash, L"\\"); |
| 333 | |
| 334 | done = (*slash == L'\0'); |
| 335 | *slash = L'\0'; |
| 336 | |
| 337 | auto attribute = GetFileAttributes(path); |
| 338 | if (attribute == INVALID_FILE_ATTRIBUTES) { |
| 339 | if (!CreateDirectory(path, nullptr)) { |
| 340 | const auto &utf8Path = MMKVPath_t2String(str); |
| 341 | MMKVError("fail to create dir:%s, %d", utf8Path.c_str(), GetLastError()); |
| 342 | free(path); |
| 343 | return false; |
| 344 | } |
| 345 | } else if (!(attribute & FILE_ATTRIBUTE_DIRECTORY)) { |
| 346 | const auto &utf8Path = MMKVPath_t2String(str); |
| 347 | MMKVError("%s attribute:%d not a directory", utf8Path.c_str(), attribute); |
| 348 | free(path); |
| 349 | return false; |
| 350 | } |
| 351 | |
| 352 | *slash = L'\\'; |
| 353 | } |
| 354 | free(path); |
| 355 | return true; |
| 356 | } |
| 357 | |
| 358 | MMBuffer *readWholeFile(const MMKVPath_t &nsFilePath) { |
| 359 | MMBuffer *buffer = nullptr; |
nothing calls this directly
no test coverage detected