mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-17 19:30:36 +00:00
Using O_BINARY on win32 for uploaded files
This commit is contained in:
1 parent
080cb2dd4b
commit
d8424726bb
2 files changed
+5
-1
No files matched your search
@@ -17,6 +17,7 @@ CLFLAGS = /MD /TC /nologo $(DBG) /W3 /DNO_SSL \
|
|||||||
/link /incremental:no /libpath:$(MSVC)/lib /machine:IX86
|
/link /incremental:no /libpath:$(MSVC)/lib /machine:IX86
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
|
$(CL) upload.c ../mongoose.c $(CLFLAGS)
|
||||||
$(CL) hello.c ../mongoose.c $(CLFLAGS)
|
$(CL) hello.c ../mongoose.c $(CLFLAGS)
|
||||||
$(CL) upload.c ../mongoose.c $(CLFLAGS)
|
$(CL) upload.c ../mongoose.c $(CLFLAGS)
|
||||||
$(CL) post.c ../mongoose.c $(CLFLAGS)
|
$(CL) post.c ../mongoose.c $(CLFLAGS)
|
||||||
|
|||||||
+4
-1
@@ -15,6 +15,9 @@ typedef __int64 int64_t;
|
|||||||
#else
|
#else
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#ifndef O_BINARY
|
||||||
|
#define O_BINARY 0
|
||||||
|
#endif
|
||||||
#endif // !_WIN32
|
#endif // !_WIN32
|
||||||
|
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
@@ -82,7 +85,7 @@ static void handle_file_upload(struct mg_connection *conn) {
|
|||||||
mg_printf(conn, "%s%s", HTTP_500, "Can't get file name");
|
mg_printf(conn, "%s%s", HTTP_500, "Can't get file name");
|
||||||
} else if (cl <= 0) {
|
} else if (cl <= 0) {
|
||||||
mg_printf(conn, "%s%s", HTTP_500, "Empty file");
|
mg_printf(conn, "%s%s", HTTP_500, "Empty file");
|
||||||
} else if ((fd = open(path, O_CREAT | O_TRUNC |
|
} else if ((fd = open(path, O_CREAT | O_TRUNC | O_BINARY |
|
||||||
O_WRONLY | O_EXLOCK | O_CLOEXEC)) < 0) {
|
O_WRONLY | O_EXLOCK | O_CLOEXEC)) < 0) {
|
||||||
// We're opening the file with exclusive lock held. This guarantee us that
|
// 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.
|
// there is no other thread can save into the same file simultaneously.
|
||||||
|
|||||||
Reference in new issue
Block a user