1 parent
fa30098129
commit
8583a479dd
11 files changed
+1763
-129
No files matched your search
@@ -19,6 +19,25 @@ namespace
|
||||
std::ifstream f(p);
|
||||
return {std::istreambuf_iterator<char>(f), {}};
|
||||
}
|
||||
|
||||
std::size_t archive_count(const std::filesystem::path& path)
|
||||
{
|
||||
const auto directory = path.parent_path() / "history";
|
||||
if (!std::filesystem::exists(directory)) {
|
||||
return 0;
|
||||
}
|
||||
const auto prefix = path.stem().string() + "-";
|
||||
std::size_t count = 0;
|
||||
for (const auto& entry :
|
||||
std::filesystem::directory_iterator(directory)) {
|
||||
const auto filename = entry.path().filename().string();
|
||||
if (entry.is_regular_file() && filename.starts_with(prefix) &&
|
||||
entry.path().extension() == path.extension()) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class SplitFileLoggerTests : public Void::Testing::Fixture
|
||||
@@ -135,8 +154,8 @@ class HistoryLoggerTests : public Void::Testing::Fixture
|
||||
std::to_string(i));
|
||||
}
|
||||
}
|
||||
auto rotated = path;
|
||||
rotated += ".1";
|
||||
Void::Testing::expect(std::filesystem::exists(rotated));
|
||||
const auto archives = archive_count(path);
|
||||
Void::Testing::expect(archives >= 1);
|
||||
Void::Testing::expect(archives <= 3);
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user