Fix build error on Mac and Linux
This commit is contained in:
parent
ddfdacfa49
commit
c5ee208775
24
httplib.h
24
httplib.h
@ -2198,6 +2198,10 @@ make_basic_authentication_header(const std::string &username,
|
|||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
bool is_file(const std::string &path);
|
||||||
|
|
||||||
|
bool is_dir(const std::string &path);
|
||||||
|
|
||||||
std::string encode_query_param(const std::string &value);
|
std::string encode_query_param(const std::string &value);
|
||||||
|
|
||||||
std::string decode_url(const std::string &s, bool convert_plus_to_space);
|
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) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool is_file(const std::string &path) {
|
|
||||||
struct stat st;
|
|
||||||
return stat(path.c_str(), &st) >= 0 && S_ISREG(st.st_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool is_dir(const std::string &path) {
|
|
||||||
struct stat st;
|
|
||||||
return stat(path.c_str(), &st) >= 0 && S_ISDIR(st.st_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool is_valid_path(const std::string &path) {
|
inline bool is_valid_path(const std::string &path) {
|
||||||
size_t level = 0;
|
size_t level = 0;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
@ -2577,6 +2571,16 @@ inline bool is_valid_path(const std::string &path) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool is_file(const std::string &path) {
|
||||||
|
struct stat st;
|
||||||
|
return stat(path.c_str(), &st) >= 0 && S_ISREG(st.st_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_dir(const std::string &path) {
|
||||||
|
struct stat st;
|
||||||
|
return stat(path.c_str(), &st) >= 0 && S_ISDIR(st.st_mode);
|
||||||
|
}
|
||||||
|
|
||||||
inline std::string encode_query_param(const std::string &value) {
|
inline std::string encode_query_param(const std::string &value) {
|
||||||
std::ostringstream escaped;
|
std::ostringstream escaped;
|
||||||
escaped.fill('0');
|
escaped.fill('0');
|
||||||
|
@ -7563,8 +7563,8 @@ TEST(UniversalClientImplTest, Ipv6LiteralAddress) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(FileSystemTest, FileAndDirExistenceCheck) {
|
TEST(FileSystemTest, FileAndDirExistenceCheck) {
|
||||||
std::string file_path = "./www/dir/index.html";
|
auto file_path = "./www/dir/index.html";
|
||||||
std::string dir_path = "./www/dir";
|
auto dir_path = "./www/dir";
|
||||||
|
|
||||||
EXPECT_TRUE(detail::is_file(file_path));
|
EXPECT_TRUE(detail::is_file(file_path));
|
||||||
EXPECT_FALSE(detail::is_dir(file_path));
|
EXPECT_FALSE(detail::is_dir(file_path));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user