diff --git a/examples/upload.c b/examples/upload.c index 908024f4..93c353d5 100644 --- a/examples/upload.c +++ b/examples/upload.c @@ -10,14 +10,9 @@ #include #define strtoll strtol typedef __int64 int64_t; -#define O_CLOEXEC 0 -#define O_EXLOCK 0 #else #include #include -#ifndef O_BINARY -#define O_BINARY 0 -#endif #endif // !_WIN32 #include "mongoose.h" @@ -85,8 +80,13 @@ static void handle_file_upload(struct mg_connection *conn) { mg_printf(conn, "%s%s", HTTP_500, "Can't get file name"); } else if (cl <= 0) { mg_printf(conn, "%s%s", HTTP_500, "Empty file"); - } else if ((fd = open(path, O_CREAT | O_TRUNC | O_BINARY | - O_WRONLY | O_EXLOCK | O_CLOEXEC)) < 0) { + } else if ((fd = open(path, O_CREAT | O_TRUNC | +#ifdef _WIN32 + O_BINARY | +#else + O_EXLOCK | O_CLOEXEC | +#endif + O_WRONLY)) < 0) { // We're opening the file with exclusive lock held. This guarantee us that // there is no other thread can save into the same file simultaneously. mg_printf(conn, "%s%s", HTTP_500, "Cannot open file");