From 3358efc24aff86b8295cfb1aeb99758d940f47b9 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 25 Aug 2011 18:59:01 +0200 Subject: [PATCH] Support for remove in Windows. --- mingw.c | 10 ++++++++++ mingw.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/mingw.c b/mingw.c index 9eefbbb3..2512fc82 100644 --- a/mingw.c +++ b/mingw.c @@ -335,6 +335,16 @@ int windows_rename(const char* a, const char* b) return 0; } +int windows_remove(const char* a) +{ + if (!_wremove(u8tou16(a))) { + windows_errno(GetLastError()); + return -1; + } + + return 0; +} + FILE* windows_fopen(const char* file, const char* mode) { return _wfopen(u8tou16(file), u8tou16(mode)); diff --git a/mingw.h b/mingw.h index 5b1a63c9..97d1eee8 100644 --- a/mingw.h +++ b/mingw.h @@ -42,6 +42,7 @@ #define HAVE_FSYNC 1 #define fsync _commit #define rename windows_rename +#define remove windows_remove #define mkdir(a, b) windows_mkdir(a) #define dirent windows_dirent #define DIR windows_dir @@ -102,6 +103,11 @@ int windows_ftruncate(int fd, off64_t off); */ int windows_rename(const char* a, const char* b); +/** + * Like the C remove(). + */ +int windows_remove(const char* a); + /** * Like the C fopen(). */