|
|
|
@ -62,13 +62,13 @@ void file_helper::reopen(bool truncate) {
|
|
|
|
|
this->open(filename_, truncate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void file_helper::flush() {
|
|
|
|
|
void file_helper::flush() const {
|
|
|
|
|
if (std::fflush(fd_) != 0) {
|
|
|
|
|
throw_spdlog_ex("Failed flush to file " + os::filename_to_str(filename_), errno);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void file_helper::sync() {
|
|
|
|
|
void file_helper::sync() const {
|
|
|
|
|
if (!os::fsync(fd_)) {
|
|
|
|
|
throw_spdlog_ex("Failed to fsync file " + os::filename_to_str(filename_), errno);
|
|
|
|
|
}
|
|
|
|
@ -89,9 +89,9 @@ void file_helper::close() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void file_helper::write(const memory_buf_t &buf) {
|
|
|
|
|
void file_helper::write(const memory_buf_t &buf) const {
|
|
|
|
|
if (fd_ == nullptr) return;
|
|
|
|
|
size_t msg_size = buf.size();
|
|
|
|
|
const size_t msg_size = buf.size();
|
|
|
|
|
const auto *data = buf.data();
|
|
|
|
|
if (std::fwrite(data, 1, msg_size, fd_) != msg_size) {
|
|
|
|
|
throw_spdlog_ex("Failed writing to file " + os::filename_to_str(filename_), errno);
|
|
|
|
|