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

Method open

Core/MemoryFile.cpp:89–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89bool File::open() {
90# ifdef MMKV_ANDROID
91 if (m_fileType == MMFILE_TYPE_ASHMEM) {
92 return isFileValid();
93 }
94# endif
95 if (isFileValid()) {
96 return true;
97 }
98 m_fd = ::open(m_path.c_str(), OpenFlag2NativeFlag(m_flag), S_IRWXU);
99 if (!isFileValid()) {
100 MMKVError("fail to open [%s], flag 0x%x, %d(%s)", m_path.c_str(), m_flag, errno, strerror(errno));
101 return false;
102 }
103 MMKVInfo("open fd[%d], flag 0x%x, %s", m_fd, m_flag, m_path.c_str());
104 return true;
105}
106
107void File::close() {
108 if (isFileValid()) {

Callers 1

openIfNeededMethod · 0.45

Calls 2

OpenFlag2NativeFlagFunction · 0.70
isFileValidFunction · 0.50

Tested by

no test coverage detected