59 const auto t = time_point_cast<std::chrono::seconds>(std::chrono::system_clock::now());
60 const auto get_new_path = [t,
this](
auto indFmt) {
61 std::string_view pathFmt = m_PathFmts.at(indFmt);
64 const auto lt = m_tz->to_local(t);
65 return std::vformat(pathFmt, make_format_args(lt));
67 return std::vformat(pathFmt, make_format_args(t));
71 nextPath = m_CurrPath;
75 nextPath = get_new_path(m_CurPathFmt);
81 if (m_CurrPath != nextPath)
84 if (m_CurrPath.empty())
88 while (m_CurPathFmt + 1 < m_PathFmts.size() &&
89 fs::is_regular_file(nextPath) &&
90 fs::file_size(nextPath) >= m_FileSizeLimit)
91 nextPath = get_new_path(++m_CurPathFmt);
97 auto s2 = get_new_path(m_CurPathFmt - 1);
102 nextPath = std::move(s2);
107 (void)create_directories(fs::path(nextPath).parent_path());
110 if (m_CurrPath.empty())
112 m_Out.open(nextPath, m_OpenMode|std::ios::ate|std::ios::in);
117 if (!m_Out.is_open())
121 m_Out.open(nextPath, m_OpenMode);
123 if (!m_Out.is_open())
126 m_CurrPath = nextPath;
130 m_CurPathFmt + 1 < m_PathFmts.size() &&
131 m_Out.tellp() >= std::streamoff(m_FileSizeLimit))
134 nextPath = get_new_path(++m_CurPathFmt);