/* This is free and unencumbered software released into the public domain. */ #include /* for std::*printf() */ #include /* for EXIT_FAILURE, EXIT_SUCCESS */ #include /* for std::errno */ #include /* for std::error */ #include /* for unlink and rmdir */ #include int main() { try { /* Create the LMDB environment: */ auto env = lmdb::env::create(); char tmpdir[] = "/tmp/check.XXXXXX"; if (!mkdtemp(tmpdir)) { std::fprintf(stderr, "Unable to create temporary directory: %s\n", std::strerror(errno)); return EXIT_FAILURE; } /* Open the LMDB environment: */ env.open(tmpdir); /* Begin the LMDB transaction: */ auto txn = lmdb::txn::begin(env); // TODO /* clean up */ char filename[30]; // enough room for tmpdir + filename std::sprintf(filename, "%s/data.mdb", tmpdir); unlink(filename); std::sprintf(filename, "%s/lock.mdb", tmpdir); unlink(filename); rmdir(tmpdir); return EXIT_SUCCESS; } catch (const lmdb::error& error) { std::fprintf(stderr, "Failed with error: %s\n", error.what()); return EXIT_FAILURE; } }