sync() after write to avoid losing file data on power off.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#include "ofstream_synced.hpp"
|
||||
#include "unistd.h"
|
||||
|
||||
using namespace pipedal;
|
||||
|
||||
|
||||
void pipedal::FileSystemSync()
|
||||
{
|
||||
::sync();
|
||||
}
|
||||
|
||||
ofstream_synced::~ofstream_synced()
|
||||
{
|
||||
if (is_open())
|
||||
{
|
||||
close();
|
||||
::sync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user