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

Method open

Core/MemoryFile_Win32.cpp:69–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69bool File::open() {
70 if (isFileValid()) {
71 return true;
72 }
73 auto pair = OpenFlag2NativeFlag(m_flag);
74 m_fd = CreateFile(m_path.c_str(), pair.first, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr,
75 pair.second, FILE_ATTRIBUTE_NORMAL, nullptr);
76 if (!isFileValid()) {
77 MMKVError("fail to open:[%s], flag %x, error %d", m_utf8Path.c_str(), m_flag, GetLastError());
78 return false;
79 }
80 MMKVInfo("open fd[%p], flag %x, %s", m_fd, m_flag, m_utf8Path.c_str());
81 return true;
82}
83
84void File::close() {
85 if (isFileValid()) {

Callers 1

openIfNeededMethod · 0.45

Calls 2

OpenFlag2NativeFlagFunction · 0.70
isFileValidFunction · 0.50

Tested by

no test coverage detected