ofstream_synced close
This commit is contained in:
@@ -10,6 +10,7 @@ namespace pipedal
|
|||||||
class ofstream_synced : public std::ofstream
|
class ofstream_synced : public std::ofstream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using super = std::ofstream;
|
||||||
ofstream_synced() {}
|
ofstream_synced() {}
|
||||||
|
|
||||||
explicit ofstream_synced(const std::string &filename, ios_base::openmode mode = ios_base::out)
|
explicit ofstream_synced(const std::string &filename, ios_base::openmode mode = ios_base::out)
|
||||||
@@ -20,6 +21,7 @@ namespace pipedal
|
|||||||
: std::ofstream(filename, mode)
|
: std::ofstream(filename, mode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
void close();
|
||||||
~ofstream_synced();
|
~ofstream_synced();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,14 @@ void pipedal::FileSystemSync()
|
|||||||
{
|
{
|
||||||
::sync();
|
::sync();
|
||||||
}
|
}
|
||||||
|
void ofstream_synced::close() {
|
||||||
ofstream_synced::~ofstream_synced()
|
|
||||||
{
|
|
||||||
if (is_open())
|
if (is_open())
|
||||||
{
|
{
|
||||||
close();
|
super::close();
|
||||||
::sync();
|
::sync();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
ofstream_synced::~ofstream_synced()
|
||||||
|
{
|
||||||
|
ofstream_synced::close();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user