mirror of
https://github.com/Tencent/MMKV.git
synced 2026-10-18 13:10:43 +08:00
add checkExist() for Python
This commit is contained in:
@@ -125,6 +125,7 @@ PYBIND11_MODULE(mmkv, m) {
|
||||
|
||||
clsNameSpace.def("removeStorage", &NameSpace::removeStorage);
|
||||
clsNameSpace.def("isFileValid", &NameSpace::isFileValid);
|
||||
clsNameSpace.def("checkExist", &NameSpace::checkExist);
|
||||
|
||||
py::class_<MMKV, unique_ptr<MMKV, py::nodelete>> clsMMKV(m, "MMKV");
|
||||
|
||||
@@ -435,4 +436,12 @@ PYBIND11_MODULE(mmkv, m) {
|
||||
},
|
||||
"detect if the MMKV file is valid or not", py::arg("mmapID"),
|
||||
py::arg("rootDir") = MMKVPath_t());
|
||||
|
||||
clsMMKV.def_static("checkExist",
|
||||
[](const string &mmapID, const MMKVPath_t &rootDir) {
|
||||
MMKVPath_t *rootDirPtr = (!rootDir.empty()) ? (MMKVPath_t *) &rootDir : nullptr;
|
||||
return MMKV::checkExist(mmapID, rootDirPtr);
|
||||
},
|
||||
"check if the MMKV file is exist or not", py::arg("mmapID"),
|
||||
py::arg("rootDir") = MMKVPath_t());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user