From 9f96545fa7ee3370047eac5e00937ea894944323 Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 25 Oct 2019 16:52:12 +0300 Subject: [PATCH] refactoed file_helper --- include/spdlog/details/file_helper-inl.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/spdlog/details/file_helper-inl.h b/include/spdlog/details/file_helper-inl.h index cc21075c..3c1d8056 100644 --- a/include/spdlog/details/file_helper-inl.h +++ b/include/spdlog/details/file_helper-inl.h @@ -29,13 +29,12 @@ SPDLOG_INLINE void file_helper::open(const filename_t &fname, bool truncate) { close(); filename_ = fname; - - // create containing folder if not empty string and not exists already - os::create_dir(os::dir_name(fname)); - auto *mode = truncate ? SPDLOG_FILENAME_T("wb") : SPDLOG_FILENAME_T("ab"); + for (int tries = 0; tries < open_tries_; ++tries) { + // create containing folder if not exists already. + os::create_dir(os::dir_name(fname)); if (!os::fopen_s(&fd_, fname, mode)) { return;