mdbx-test: use mdbx_env_delete() in a test and drop aux functions.

Change-Id: I3b0e409c23067abcaefd4f9c5627df804382b348
This commit is contained in:
Leonid Yuriev 2020-10-10 00:59:12 +03:00
parent 0627d902dd
commit 9afbde9b0a
5 changed files with 4 additions and 37 deletions

View File

@ -1,8 +1,8 @@
#include "test.h"
void testcase_copy::copy_db(const bool with_compaction) {
int err = osal_removefile(copy_pathname);
if (err != MDBX_SUCCESS && err != MDBX_ENOFILE)
int err = mdbx_env_delete(copy_pathname.c_str(), MDBX_ENV_JUST_DELETE);
if (err != MDBX_SUCCESS && err != MDBX_RESULT_TRUE)
failure_perror("mdbx_removefile()", err);
err = mdbx_env_copy(db_guard.get(), copy_pathname.c_str(),

View File

@ -212,24 +212,9 @@ 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)
int err = mdbx_env_delete(db_path.c_str(), MDBX_ENV_JUST_DELETE);
if (err != MDBX_SUCCESS && err != MDBX_RESULT_TRUE)
failure_perror(db_path.c_str(), err);
}
log_trace("<< cleanup");

View File

@ -531,12 +531,4 @@ std::string osal_tempdir(void) {
return "";
}
int osal_removefile(const std::string &pathname) {
return unlink(pathname.c_str()) ? errno : MDBX_SUCCESS;
}
int osal_removedirectory(const std::string &pathname) {
return rmdir(pathname.c_str()) ? errno : MDBX_SUCCESS;
}
#endif /* !Windows */

View File

@ -452,12 +452,4 @@ std::string osal_tempdir(void) {
return std::string(buf, len);
}
int osal_removefile(const std::string &pathname) {
return DeleteFileA(pathname.c_str()) ? MDBX_SUCCESS : GetLastError();
}
int osal_removedirectory(const std::string &pathname) {
return RemoveDirectoryA(pathname.c_str()) ? MDBX_SUCCESS : GetLastError();
}
#endif /* Windows */

View File

@ -34,8 +34,6 @@ void osal_udelay(unsigned us);
void osal_yield(void);
bool osal_istty(int fd);
std::string osal_tempdir(void);
int osal_removefile(const std::string &pathname);
int osal_removedirectory(const std::string &pathname);
#ifdef _MSC_VER
#ifndef STDIN_FILENO