mdbx-test: cleanup for without MDBX_NOSUBDIR case.

Change-Id: I50d6640108ca229e4919ea96469152d2533f9cab
This commit is contained in:
Leonid Yuriev
2020-09-26 22:01:07 +03:00
parent 5627521f16
commit 12770cae88
5 changed files with 27 additions and 0 deletions

View File

@@ -212,8 +212,23 @@ std::string thunk_param(const actor_config &config) {
void cleanup() {
log_trace(">> cleanup");
const int is_dir =
#if defined(_WIN32) || defined(_WIN64)
ERROR_ACCESS_DENIED /* Windows API is mad */;
#else
EISDIR;
#endif
for (const auto &db_path : global::databases) {
int err = osal_removefile(db_path);
if (err == is_dir) {
err = osal_removefile(db_path + MDBX_LOCKNAME);
if (err == MDBX_SUCCESS || err == MDBX_ENOFILE)
err = osal_removefile(db_path + MDBX_DATANAME);
if (err == MDBX_SUCCESS || err == MDBX_ENOFILE)
err = osal_removedirectory(db_path);
} else if (err == MDBX_SUCCESS || err == MDBX_ENOFILE)
err = osal_removefile(db_path + MDBX_LOCK_SUFFIX);
if (err != MDBX_SUCCESS && err != MDBX_ENOFILE)
failure_perror(db_path.c_str(), err);
}