Skip to content

Commit c5ee208

Browse files
committed
Fix build error on Mac and Linux
1 parent ddfdacf commit c5ee208

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

httplib.h

+14-10
Original file line numberDiff line numberDiff line change
@@ -2198,6 +2198,10 @@ make_basic_authentication_header(const std::string &username,
21982198

21992199
namespace detail {
22002200

2201+
bool is_file(const std::string &path);
2202+
2203+
bool is_dir(const std::string &path);
2204+
22012205
std::string encode_query_param(const std::string &value);
22022206

22032207
std::string decode_url(const std::string &s, bool convert_plus_to_space);
@@ -2525,16 +2529,6 @@ inline std::string base64_encode(const std::string &in) {
25252529
return out;
25262530
}
25272531

2528-
inline bool is_file(const std::string &path) {
2529-
struct stat st;
2530-
return stat(path.c_str(), &st) >= 0 && S_ISREG(st.st_mode);
2531-
}
2532-
2533-
inline bool is_dir(const std::string &path) {
2534-
struct stat st;
2535-
return stat(path.c_str(), &st) >= 0 && S_ISDIR(st.st_mode);
2536-
}
2537-
25382532
inline bool is_valid_path(const std::string &path) {
25392533
size_t level = 0;
25402534
size_t i = 0;
@@ -2577,6 +2571,16 @@ inline bool is_valid_path(const std::string &path) {
25772571
return true;
25782572
}
25792573

2574+
inline bool is_file(const std::string &path) {
2575+
struct stat st;
2576+
return stat(path.c_str(), &st) >= 0 && S_ISREG(st.st_mode);
2577+
}
2578+
2579+
inline bool is_dir(const std::string &path) {
2580+
struct stat st;
2581+
return stat(path.c_str(), &st) >= 0 && S_ISDIR(st.st_mode);
2582+
}
2583+
25802584
inline std::string encode_query_param(const std::string &value) {
25812585
std::ostringstream escaped;
25822586
escaped.fill('0');

test/test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -7563,8 +7563,8 @@ TEST(UniversalClientImplTest, Ipv6LiteralAddress) {
75637563
}
75647564

75657565
TEST(FileSystemTest, FileAndDirExistenceCheck) {
7566-
std::string file_path = "./www/dir/index.html";
7567-
std::string dir_path = "./www/dir";
7566+
auto file_path = "./www/dir/index.html";
7567+
auto dir_path = "./www/dir";
75687568

75697569
EXPECT_TRUE(detail::is_file(file_path));
75707570
EXPECT_FALSE(detail::is_dir(file_path));

0 commit comments

Comments
 (0)