Skip to content

Commit 8da5133

Browse files
committed
Fix Windows mkdir compatibility issue
On Windows/MinGW, mkdir() only takes one argument (path), while POSIX mkdir() takes two (path and mode). Add a MKDIR macro that uses the appropriate signature for each platform.
1 parent 1f1071c commit 8da5133

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/integ/file_upload.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020

2121
#include <curl/curl.h>
2222
#include <sys/stat.h>
23+
#ifdef _WIN32
24+
#include <direct.h>
25+
#define MKDIR(path) _mkdir(path)
26+
#else
27+
#define MKDIR(path) mkdir(path, 0755)
28+
#endif
2329
#include <cassert>
2430
#include <cstddef>
2531
#include <cstdio>
@@ -891,7 +897,7 @@ LT_END_AUTO_TEST(file_cleanup_no_callback_deletes)
891897
LT_BEGIN_AUTO_TEST(file_upload_suite, file_upload_original_filename)
892898
// Use a subdirectory to avoid overwriting the test input file
893899
string upload_directory = "upload_test_dir";
894-
mkdir(upload_directory.c_str(), 0755);
900+
MKDIR(upload_directory.c_str());
895901

896902
auto ws = std::make_unique<webserver>(create_webserver(PORT)
897903
.file_upload_target(httpserver::FILE_UPLOAD_DISK_ONLY)

0 commit comments

Comments
 (0)