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

Function createUniqueTempFile

Core/MemoryFile.cpp:494–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

492#ifndef MMKV_APPLE
493
494static 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

Callers 1

copyFileFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected