mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-24 17:41:34 +08:00
Fix fopen_s error reporting with PREVENT_CHILD_FD
This commit is contained in:
parent
7f8a61e79d
commit
5ee969e4f6
@ -145,7 +145,7 @@ SPDLOG_INLINE bool fopen_s(FILE **fp, const filename_t &filename, const filename
|
||||
const int fd = ::open((filename.c_str()), O_CREAT | O_WRONLY | O_CLOEXEC | mode_flag, mode_t(0644));
|
||||
if (fd == -1)
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
*fp = ::fdopen(fd, mode.c_str());
|
||||
if (*fp == nullptr)
|
||||
|
@ -154,3 +154,15 @@ TEST_CASE("file_event_handlers", "[file_helper]")
|
||||
REQUIRE(events == std::vector<flags>{flags::before_close, flags::after_close});
|
||||
REQUIRE(file_contents(TEST_FILENAME) == "after_open\nbefore_close\n");
|
||||
}
|
||||
|
||||
TEST_CASE("file_helper_open", "[file_helper]")
|
||||
{
|
||||
prepare_logdir();
|
||||
spdlog::filename_t target_filename = SPDLOG_FILENAME_T(TEST_FILENAME);
|
||||
file_helper helper;
|
||||
helper.open(target_filename);
|
||||
helper.close();
|
||||
|
||||
target_filename += SPDLOG_FILENAME_T("/invalid");
|
||||
REQUIRE_THROWS_AS(helper.open(target_filename), spdlog::spdlog_ex);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user