| 492 | #ifndef MMKV_APPLE |
| 493 | |
| 494 | static pair<MMKVPath_t, int> createUniqueTempFile(const char *prefix) { |
| 495 | char path[PATH_MAX]; |
| 496 | #ifdef MMKV_ANDROID |
| 497 | snprintf(path, PATH_MAX, "%s/%s.XXXXXX", g_android_tmpDir.c_str(), prefix); |
| 498 | #else |
| 499 | snprintf(path, PATH_MAX, "%s/%s.XXXXXX", P_tmpdir, prefix); |
| 500 | #endif |
| 501 | |
| 502 | auto fd = mkstemp(path); |
| 503 | if (fd < 0) { |
| 504 | MMKVError("fail to create unique temp file [%s], %d(%s)", path, errno, strerror(errno)); |
| 505 | return {"", fd}; |
| 506 | } |
| 507 | MMKVDebug("create unique temp file [%s] with fd[%d]", path, fd); |
| 508 | return {MMKVPath_t(path), fd}; |
| 509 | } |
| 510 | |
| 511 | #if !defined(MMKV_ANDROID) && !defined(MMKV_LINUX) |
| 512 | |