From e6c9ccf3a1a4ce2c39b859352065c4206b0b404f Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 4 Nov 2017 13:12:13 +0200 Subject: [PATCH] Changed tmpfileplus() to our needs Removed exclusive flag, made it C++ friendly, replaced unlink() with remove() --- src/tmpfileplus.c | 6 +++--- src/tmpfileplus.h | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/tmpfileplus.c b/src/tmpfileplus.c index 9af0260b38..ddb71de092 100644 --- a/src/tmpfileplus.c +++ b/src/tmpfileplus.c @@ -200,13 +200,13 @@ static FILE *mktempfile_internal(const char *tmpdir, const char *pfx, char **tmp */ #ifdef _WIN32 /* MSVC flags */ - oflag = _O_BINARY|_O_CREAT|_O_EXCL|_O_RDWR; + oflag = _O_BINARY|_O_CREAT|_O_RDWR; if (!keep) oflag |= _O_TEMPORARY; pmode = _S_IREAD | _S_IWRITE; #else /* Standard POSIX flags */ - oflag = O_CREAT|O_EXCL|O_RDWR; + oflag = O_CREAT|O_RDWR; pmode = S_IRUSR|S_IWUSR; #endif @@ -239,7 +239,7 @@ static FILE *mktempfile_internal(const char *tmpdir, const char *pfx, char **tmp #ifndef _WIN32 /* [Unix only] And make sure the file will be deleted once closed */ - if (!keep) unlink(tmpname); + if (!keep) remove(tmpname); #endif } diff --git a/src/tmpfileplus.h b/src/tmpfileplus.h index 6c6ac38a75..e32ff5042d 100644 --- a/src/tmpfileplus.h +++ b/src/tmpfileplus.h @@ -23,6 +23,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /** Create a unique temporary file. @param dir (optional) directory to create file. If NULL use default TMP directory. @param prefix (optional) prefix for file name. If NULL use "tmp.". @@ -50,4 +54,8 @@ FILE *tmpfileplus_f(const char *dir, const char *prefix, char *pathnamebuf, size #define TMPFILE_KEEP 1 +#ifdef __cplusplus +} +#endif + #endif /* end TMPFILEPLUS_H_ */