From 12174187e8fd6f49f2d7c0b1132c0dbe82e9d97f Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sun, 4 Nov 2018 18:57:24 +0300 Subject: [PATCH] mdbx-tests: add osal_removefile(). Change-Id: Ifdacd1f799e3ed12f6b83bcdef0effbc0c41011c --- test/osal-unix.cc | 6 +++++- test/osal-windows.cc | 6 +++++- test/osal.h | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/test/osal-unix.cc b/test/osal-unix.cc index 6661ae42..1856d0f8 100644 --- a/test/osal-unix.cc +++ b/test/osal-unix.cc @@ -1,4 +1,4 @@ -/* +/* * Copyright 2017-2018 Leonid Yuriev * and other libmdbx authors: please see AUTHORS file. * All rights reserved. @@ -301,3 +301,7 @@ std::string osal_tempdir(void) { return "/dev/shm/"; return ""; } + +int osal_removefile(const std::string &pathname) { + return unlink(pathname.c_str()) ? errno : MDBX_SUCCESS; +} diff --git a/test/osal-windows.cc b/test/osal-windows.cc index 7d59f657..f7f1de56 100644 --- a/test/osal-windows.cc +++ b/test/osal-windows.cc @@ -1,4 +1,4 @@ -/* +/* * Copyright 2017-2018 Leonid Yuriev * and other libmdbx authors: please see AUTHORS file. * All rights reserved. @@ -405,3 +405,7 @@ std::string osal_tempdir(void) { DWORD len = GetTempPathA(sizeof(buf), buf); return std::string(buf, len); } + +int osal_removefile(const std::string &pathname) { + return DeleteFileA(pathname.c_str()) ? MDBX_SUCCESS : GetLastError(); +} diff --git a/test/osal.h b/test/osal.h index c27282a6..3ccc7bbe 100644 --- a/test/osal.h +++ b/test/osal.h @@ -1,4 +1,4 @@ -/* +/* * Copyright 2017-2018 Leonid Yuriev * and other libmdbx authors: please see AUTHORS file. * All rights reserved. @@ -32,6 +32,7 @@ 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); #ifdef _MSC_VER #ifndef STDIN_FILENO