Various minor cleanup

This commit is contained in:
emeric
2024-12-05 20:09:14 +01:00
parent 76b9c1fe10
commit 45175a721c
35 changed files with 104 additions and 137 deletions
+8 -8
View File
@@ -217,14 +217,14 @@ namespace lms::zip
if (!std::filesystem::is_regular_file(entry.filePath))
throw FileException{ entry.filePath, "not a regular file" };
ArchiveEntryPtr archiveEntry{ archive_entry_new() };
ArchiveEntryPtr archiveEntry{ ::archive_entry_new() };
if (!archiveEntry)
throw Exception{ "Cannot create archive entry control struct" };
archive_entry_set_pathname(archiveEntry.get(), entry.fileName.c_str());
archive_entry_set_size(archiveEntry.get(), std::filesystem::file_size(entry.filePath));
archive_entry_set_mode(archiveEntry.get(), permsToMode(std::filesystem::status(entry.filePath).permissions()));
archive_entry_set_filetype(archiveEntry.get(), AE_IFREG);
::archive_entry_set_pathname(archiveEntry.get(), entry.fileName.c_str());
::archive_entry_set_size(archiveEntry.get(), std::filesystem::file_size(entry.filePath));
::archive_entry_set_mode(archiveEntry.get(), permsToMode(std::filesystem::status(entry.filePath).permissions()));
::archive_entry_set_filetype(archiveEntry.get(), AE_IFREG);
return archiveEntry;
}
@@ -256,7 +256,7 @@ namespace lms::zip
if (!ifs.seekg(_currentEntryOffset, std::ios::beg))
throw FileException{ _currentEntry->filePath, "seek failed", errno };
if (!ifs.read(reinterpret_cast<char*>(&_readBuffer[0]), bytesToRead))
if (!ifs.read(reinterpret_cast<char*>(_readBuffer.data()), bytesToRead))
throw FileException{ _currentEntry->filePath, "read failed", errno };
const std::uint64_t actualBytesRead{ static_cast<std::uint64_t>(ifs.gcount()) };
@@ -266,7 +266,7 @@ namespace lms::zip
std::uint64_t remainingBytesToWrite{ actualBytesRead };
while (remainingBytesToWrite > 0)
{
const auto writtenBytes{ archive_write_data(_archive.get(), &_readBuffer[actualBytesRead - remainingBytesToWrite], remainingBytesToWrite) };
const auto writtenBytes{ ::archive_write_data(_archive.get(), &_readBuffer[actualBytesRead - remainingBytesToWrite], remainingBytesToWrite) };
if (writtenBytes < 0)
throw ArchiveException{ _archive.get() };
@@ -283,7 +283,7 @@ namespace lms::zip
{
if (!_currentOutputStream)
{
archive_set_error(_archive.get(), EIO, "IO error: operation cancelled");
::archive_set_error(_archive.get(), EIO, "IO error: operation cancelled");
return -1;
}
+2 -1
View File
@@ -35,7 +35,8 @@ namespace lms::zip
class ArchiveZipper : public IZipper
{
public:
ArchiveZipper(const EntryContainer& files);
ArchiveZipper(const EntryContainer& entries);
~ArchiveZipper() = default;
ArchiveZipper(const ArchiveZipper&) = delete;
ArchiveZipper& operator=(const ArchiveZipper&) = delete;
+4 -1
View File
@@ -36,8 +36,11 @@ namespace lms::core
class ChildProcess : public IChildProcess
{
public:
~ChildProcess();
ChildProcess(boost::asio::io_context& ioContext, const std::filesystem::path& path, const Args& args);
~ChildProcess() override;
ChildProcess(const ChildProcess&) = delete;
ChildProcess& operator=(const ChildProcess&) = delete;
private:
void asyncRead(std::byte* data, std::size_t bufferSize, ReadCallback callback) override;
+1 -2
View File
@@ -20,7 +20,6 @@
#pragma once
#include <memory>
#include <thread>
#include <boost/asio/io_context.hpp>
@@ -32,7 +31,7 @@ namespace lms::core
{
public:
ChildProcessManager(boost::asio::io_context& ioContext);
~ChildProcessManager() = default;
~ChildProcessManager() override = default;
ChildProcessManager(const ChildProcessManager&) = delete;
ChildProcessManager(ChildProcessManager&&) = delete;
-1
View File
@@ -20,7 +20,6 @@
#include "Config.hpp"
#include "core/Exception.hpp"
#include "core/ILogger.hpp"
namespace lms::core
{
+2 -2
View File
@@ -29,13 +29,14 @@ namespace lms::core
{
public:
Config(const std::filesystem::path& p);
~Config() = default;
~Config() override = default;
Config(const Config&) = delete;
Config& operator=(const Config&) = delete;
Config(Config&&) = delete;
Config& operator=(Config&&) = delete;
private:
// Default values are returned in case of setting not found
std::string_view getString(std::string_view setting, std::string_view def = "") override;
void visitStrings(std::string_view setting, std::function<void(std::string_view)> _func, std::initializer_list<std::string_view> defs) override;
@@ -44,7 +45,6 @@ namespace lms::core
long getLong(std::string_view setting, long def = 0) override;
bool getBool(std::string_view setting, bool def = false) override;
private:
libconfig::Config _config;
};
} // namespace lms::core
+3 -1
View File
@@ -44,6 +44,8 @@ namespace lms::core::tracing
private:
CurrentThreadUnregisterer(const CurrentThreadUnregisterer&) = delete;
CurrentThreadUnregisterer& operator=(const CurrentThreadUnregisterer&) = delete;
CurrentThreadUnregisterer(CurrentThreadUnregisterer&&) = delete;
CurrentThreadUnregisterer& operator=(CurrentThreadUnregisterer&&) = delete;
TraceLogger* _logger;
};
@@ -295,7 +297,7 @@ namespace lms::core::tracing
oss << threadId;
std::istringstream iss{ oss.str() };
std::uint64_t id;
std::uint64_t id{};
iss >> id;
return static_cast<std::uint32_t>(id);