sync() after write to avoid losing file data on power off.

This commit is contained in:
Robin Davies
2024-09-01 09:53:32 -04:00
parent abb8a1a53c
commit b8c4fafd3a
21 changed files with 102 additions and 34 deletions
@@ -0,0 +1,26 @@
#pragma once
#include <fstream>
namespace pipedal
{
void FileSystemSync();
class ofstream_synced : public std::ofstream
{
public:
ofstream_synced() {}
explicit ofstream_synced(const std::string &filename, ios_base::openmode mode = ios_base::out)
: std::ofstream(filename, mode)
{
}
explicit ofstream_synced(const char *filename, ios_base::openmode mode = ios_base::out)
: std::ofstream(filename, mode)
{
}
~ofstream_synced();
};
}