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

Method File

Core/MemoryFile_Android.cpp:44–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42extern string ASharedMemory_getName(int fd);
43
44File::File(MMKVPath_t path, OpenFlag flag, size_t size, FileType fileType)
45 : m_path(std::move(path)), m_fd(-1), m_flag(flag), m_size(0), m_fileType(fileType) {
46 if (m_fileType == MMFILE_TYPE_FILE) {
47 open();
48 } else {
49 // round up to (n * pagesize)
50 if (size < DEFAULT_MMAP_SIZE || (size % DEFAULT_MMAP_SIZE != 0)) {
51 size = ((size / DEFAULT_MMAP_SIZE) + 1) * DEFAULT_MMAP_SIZE;
52 }
53 auto filename = m_path.c_str();
54 auto ptr = strstr(filename, ASHMEM_NAME_DEF);
55 if (ptr && ptr[sizeof(ASHMEM_NAME_DEF) - 1] == '/') {
56 filename = ptr + sizeof(ASHMEM_NAME_DEF);
57 }
58 m_fd = ASharedMemory_create(filename, size);
59 if (isFileValid()) {
60 m_size = size;
61 }
62 }
63}
64
65File::File(MMKVFileHandle_t ashmemFD)
66 : m_path(), m_fd(ashmemFD), m_flag(OpenFlag::ReadWrite), m_size(0), m_fileType(MMFILE_TYPE_ASHMEM) {

Callers

nothing calls this directly

Calls 4

ASharedMemory_createFunction · 0.85
ASharedMemory_getNameFunction · 0.85
ASharedMemory_getSizeFunction · 0.85
isFileValidFunction · 0.50

Tested by

no test coverage detected