Skip to content

Commit 2514ebc

Browse files
committed
Fix #1848
1 parent 4f9c654 commit 2514ebc

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

httplib.h

-4
Original file line numberDiff line numberDiff line change
@@ -2526,12 +2526,8 @@ inline std::string base64_encode(const std::string &in) {
25262526
}
25272527

25282528
inline bool is_file(const std::string &path) {
2529-
#ifdef _WIN32
2530-
return _access_s(path.c_str(), 0) == 0;
2531-
#else
25322529
struct stat st;
25332530
return stat(path.c_str(), &st) >= 0 && S_ISREG(st.st_mode);
2534-
#endif
25352531
}
25362532

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

test/test.cc

+11
Original file line numberDiff line numberDiff line change
@@ -7561,3 +7561,14 @@ TEST(UniversalClientImplTest, Ipv6LiteralAddress) {
75617561
CLIENT_PRIVATE_KEY_FILE);
75627562
EXPECT_EQ(cli.port(), port);
75637563
}
7564+
7565+
TEST(FileSystemTest, FileAndDirExistenceCheck) {
7566+
auto file_path = "./www/dir/index.html";
7567+
auto dir_path = "./www/dir";
7568+
7569+
EXPECT_TRUE(detail::is_file(file_path));
7570+
EXPECT_FALSE(detail::is_dir(file_path));
7571+
7572+
EXPECT_FALSE(detail::is_file(dir_path));
7573+
EXPECT_TRUE(detail::is_dir(dir_path));
7574+
}

0 commit comments

Comments
 (0)