| 87 | } |
| 88 | |
| 89 | bool 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 | |
| 107 | void File::close() { |
| 108 | if (isFileValid()) { |
no test coverage detected