Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
d8424726
Commit
d8424726
authored
Nov 30, 2012
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using O_BINARY on win32 for uploaded files
parent
080cb2dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
Makefile
examples/Makefile
+1
-0
upload.c
examples/upload.c
+6
-3
No files found.
examples/Makefile
View file @
d8424726
...
...
@@ -17,6 +17,7 @@ CLFLAGS = /MD /TC /nologo $(DBG) /W3 /DNO_SSL \
/link /incremental:no /libpath:
$(MSVC)
/lib /machine:IX86
windows
:
$(CL)
upload.c ../mongoose.c
$(CLFLAGS)
$(CL)
hello.c ../mongoose.c
$(CLFLAGS)
$(CL)
upload.c ../mongoose.c
$(CLFLAGS)
$(CL)
post.c ../mongoose.c
$(CLFLAGS)
...
...
examples/upload.c
View file @
d8424726
...
...
@@ -12,9 +12,12 @@
typedef
__int64
int64_t
;
#define O_CLOEXEC 0
#define O_EXLOCK 0
#else
#else
#include <inttypes.h>
#include <unistd.h>
#ifndef O_BINARY
#define O_BINARY 0
#endif
#endif // !_WIN32
#include "mongoose.h"
...
...
@@ -27,7 +30,7 @@ static const char *html_form =
"<input type=
\"
file
\"
name=
\"
file
\"
/> <br/>"
"<input type=
\"
submit
\"
value=
\"
Upload
\"
/>"
"</form></body></html>"
;
static
const
char
*
HTTP_500
=
"HTTP/1.0 500 Server Error
\r\n\r\n
"
;
static
void
handle_file_upload
(
struct
mg_connection
*
conn
)
{
...
...
@@ -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"
);
}
else
if
(
cl
<=
0
)
{
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
)
{
// 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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment