From 797bcf9acac3e6941bd8d2cb96395613ebcfbc8d Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Sat, 30 Jun 2018 14:20:55 +0300 Subject: [PATCH] mdbx: add mdbx_removefile(). Change-Id: I985926bdef28387d5872317a3ecf47953ce4812c --- src/osal.c | 7 +++++++ src/osal.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/osal.c b/src/osal.c index 37a9c2d3..c2fced0b 100644 --- a/src/osal.c +++ b/src/osal.c @@ -408,6 +408,13 @@ int mdbx_fastmutex_release(mdbx_fastmutex_t *fastmutex) { /*----------------------------------------------------------------------------*/ +int mdbx_removefile(const char *pathname) { +#if defined(_WIN32) || defined(_WIN64) + return DeleteFileA(pathname) ? MDBX_SUCCESS : GetLastError(); +#else + return unlink(pathname) ? errno : MDBX_SUCCESS; +#endif +} int mdbx_openfile(const char *pathname, int flags, mode_t mode, mdbx_filehandle_t *fd, bool exclusive) { *fd = INVALID_HANDLE_VALUE; diff --git a/src/osal.h b/src/osal.h index 5c74fd93..daa79064 100644 --- a/src/osal.h +++ b/src/osal.h @@ -479,6 +479,7 @@ int mdbx_filesize(mdbx_filehandle_t fd, uint64_t *length); int mdbx_openfile(const char *pathname, int flags, mode_t mode, mdbx_filehandle_t *fd, bool exclusive); int mdbx_closefile(mdbx_filehandle_t fd); +int mdbx_removefile(const char *pathname); typedef struct mdbx_mmap_param { union {