From b4a6a615134b59435efbecdd8c5b5407b6af8e8f Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Fri, 5 Jun 2015 04:31:56 -0500 Subject: refactor win32 shims into posix_win.c this also adds a rename shim that allows overwrites --- include/stdio.h | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'include/stdio.h') diff --git a/include/stdio.h b/include/stdio.h index db369c9..76bd9da 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -15,35 +15,16 @@ int asprintf(char **str, const char *fmt, ...); #endif #ifdef _WIN32 -#include -#include -static inline void -posix_perror(const char *s) -{ - fprintf(stderr, "%s: %s\n", s, strerror(errno)); -} +void posix_perror(const char *s); +FILE * posix_fopen(const char *path, const char *mode); +int posix_rename(const char *oldpath, const char *newpath); +#ifndef NO_REDEF_POSIX_FUNCTIONS #define perror(errnum) posix_perror(errnum) - -static inline FILE * -posix_fopen(const char *path, const char *mode) -{ - char *bin_mode = mode; - if (strchr(mode, 'b') == NULL) { - bin_mode = NULL; - if (asprintf(&bin_mode, "%sb", mode) == -1) - return NULL; - fprintf(stderr, "opening bin file %s\n", bin_mode); - } - - FILE *f = fopen(path, bin_mode); - if (bin_mode != mode) - free(bin_mode); - return f; -} - #define fopen(path, mode) posix_fopen(path, mode) +#define rename(oldpath, newpath) posix_rename(oldpath, newpath) +#endif #endif -- cgit v1.2.3-55-g6feb