mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-10 01:33:53 +00:00
Fix #1848
This commit is contained in:
parent
4f9c6540b2
commit
2514ebc20f
@ -2526,12 +2526,8 @@ inline std::string base64_encode(const std::string &in) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool is_file(const std::string &path) {
|
inline bool is_file(const std::string &path) {
|
||||||
#ifdef _WIN32
|
|
||||||
return _access_s(path.c_str(), 0) == 0;
|
|
||||||
#else
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
return stat(path.c_str(), &st) >= 0 && S_ISREG(st.st_mode);
|
return stat(path.c_str(), &st) >= 0 && S_ISREG(st.st_mode);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool is_dir(const std::string &path) {
|
inline bool is_dir(const std::string &path) {
|
||||||
|
11
test/test.cc
11
test/test.cc
@ -7561,3 +7561,14 @@ TEST(UniversalClientImplTest, Ipv6LiteralAddress) {
|
|||||||
CLIENT_PRIVATE_KEY_FILE);
|
CLIENT_PRIVATE_KEY_FILE);
|
||||||
EXPECT_EQ(cli.port(), port);
|
EXPECT_EQ(cli.port(), port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(FileSystemTest, FileAndDirExistenceCheck) {
|
||||||
|
auto file_path = "./www/dir/index.html";
|
||||||
|
auto dir_path = "./www/dir";
|
||||||
|
|
||||||
|
EXPECT_TRUE(detail::is_file(file_path));
|
||||||
|
EXPECT_FALSE(detail::is_dir(file_path));
|
||||||
|
|
||||||
|
EXPECT_FALSE(detail::is_file(dir_path));
|
||||||
|
EXPECT_TRUE(detail::is_dir(dir_path));
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user