From 7cf172d282d1b4b5d1f9159d04e1327ffbf42875 Mon Sep 17 00:00:00 2001 From: x86kernel Date: Sat, 19 Dec 2015 23:38:41 +0000 Subject: [PATCH] some modification about directory feature --- include/spdlog/details/file_helper.h | 7 ++++++- include/spdlog/details/os.h | 8 -------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/spdlog/details/file_helper.h b/include/spdlog/details/file_helper.h index 0a544ca1..6a7b31ff 100644 --- a/include/spdlog/details/file_helper.h +++ b/include/spdlog/details/file_helper.h @@ -51,8 +51,12 @@ public: _filename = fname; for (int tries = 0; tries < open_tries; ++tries) { + if (os::dir_check(fname, dirs)) + if(os::create_dirs(dirs)) + return; + if (!os::fopen_s(&_fd, fname, mode)) - return; + return ; std::this_thread::sleep_for(std::chrono::milliseconds(open_interval)); } @@ -133,6 +137,7 @@ public: private: FILE* _fd; + std::list dirs; std::string _filename; bool _force_flush; diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 8c45a854..8f1beadf 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -195,14 +195,6 @@ inline int fopen_s(FILE** fp, const std::string& filename, const char* mode) *fp = _fsopen((filename.c_str()), mode, _SH_DENYWR); return *fp == nullptr; #else - std::list dirs; - - if(dir_check(filename, dirs)) - { - if(create_dirs(dirs)) - return true; - } - *fp = fopen((filename.c_str()), mode); return *fp == nullptr;