open static method

LMDB open(
  1. String path, {
  2. int maxDb = 1,
})

Implementation

static LMDB open(String path, {int maxDb = 1}) {
  LMDB? box = _boxes[path];

  if (box == null) {
    final functions = LMDBFunctions();

    final pointerToMdbEnv = ffi.calloc<Pointer<MDB_env>>();

    /// Try to create the LMDB, if the access was denied because the database.lock
    /// file cannot be accessed by the current user, try with [MDB_NOLOCK] flag
    if (_createLMDB(functions, pointerToMdbEnv, path, maxDb,
            MDB_CREATE | MDB_NOSUBDIR) ==
        DENIED) {
      functions.mdbEnvClose(pointerToMdbEnv.value);

      /// Trying open ignoring flags
      ErrorHandler(_createLMDB(
        functions,
        pointerToMdbEnv,
        path,
        maxDb,
        MDB_CREATE | MDB_NOLOCK | MDB_NOSUBDIR,
      ));
    }

    box = LMDB._(path, pointerToMdbEnv.value);
    _boxes[path] = box;
  }

  return box;
}