Skip to content

Commit 17abe22

Browse files
authored
Fix is_file problem on Windows (yhirose#1153)
1 parent 4a7a81e commit 17abe22

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

httplib.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ using socket_t = int;
218218

219219
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
220220
// these are defined in wincrypt.h and it breaks compilation if BoringSSL is used
221-
#if defined(_WIN32)
221+
#ifdef _WIN32
222222
#undef X509_NAME
223223
#undef X509_CERT_PAIR
224224
#undef X509_EXTENSIONS
@@ -1950,8 +1950,12 @@ inline std::string base64_encode(const std::string &in) {
19501950
}
19511951

19521952
inline bool is_file(const std::string &path) {
1953+
#ifdef _WIN32
1954+
return (_access_s(path.c_str(), 0 ) == 0);
1955+
#else
19531956
struct stat st;
19541957
return stat(path.c_str(), &st) >= 0 && S_ISREG(st.st_mode);
1958+
#endif
19551959
}
19561960

19571961
inline bool is_dir(const std::string &path) {

0 commit comments

Comments
 (0)