Added fsync for unix/windows in file utils
This commit is contained in:
parent
263d9ccaf6
commit
3bc1fa944c
@ -215,6 +215,7 @@ set (wsjtx_CXXSRCS
|
||||
logbook/countrydat.cpp
|
||||
logbook/countriesworked.cpp
|
||||
logbook/logbook.cpp
|
||||
fileutils.cpp
|
||||
psk_reporter.cpp
|
||||
Modulator.cpp
|
||||
Detector.cpp
|
||||
|
11
fileutils.cpp
Normal file
11
fileutils.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "fileutils.h"
|
||||
|
||||
void flushFileBuffer(const QFile &f){
|
||||
#ifdef Q_OS_WIN
|
||||
FlushFileBuffers(reinterpret_cast<HANDLE>(f.handle()));
|
||||
#elif _POSIX_SYNCHRONIZED_IO > 0
|
||||
fdatasync(f.handle());
|
||||
#else
|
||||
fsync(f.handle());
|
||||
#endif
|
||||
}
|
14
fileutils.h
Normal file
14
fileutils.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef FILEUTILS_H
|
||||
#define FILEUTILS_H
|
||||
|
||||
#include <QFile>
|
||||
#ifdef Q_OS_WIN
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
void flushFileBuffer(const QFile &f);
|
||||
|
||||
#endif // FILEUTILS_H
|
@ -93,7 +93,8 @@ SOURCES += \
|
||||
DecoderThread.cpp \
|
||||
Decoder.cpp \
|
||||
APRSISClient.cpp \
|
||||
MessageServer.cpp
|
||||
MessageServer.cpp \
|
||||
fileutils.cpp
|
||||
|
||||
HEADERS += qt_helpers.hpp \
|
||||
pimpl_h.hpp pimpl_impl.hpp \
|
||||
@ -137,7 +138,8 @@ HEADERS += qt_helpers.hpp \
|
||||
DecoderThread.h \
|
||||
Decoder.h \
|
||||
APRSISClient.h \
|
||||
MessageServer.h
|
||||
MessageServer.h \
|
||||
fileutils.h
|
||||
|
||||
|
||||
INCLUDEPATH += qmake_only
|
||||
|
@ -394,6 +394,7 @@ bool ADIF::addQSOToFile(QByteArray const& ADIF_record)
|
||||
|
||||
out << ADIF_record << " <eor>" << endl;
|
||||
out.flush();
|
||||
flushFileBuffer(f2);
|
||||
f2.close();
|
||||
}
|
||||
return true;
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include <QtGui>
|
||||
#endif
|
||||
|
||||
#include "fileutils.h"
|
||||
|
||||
class QDateTime;
|
||||
|
||||
extern const QStringList ADIF_FIELDS;
|
||||
|
@ -318,6 +318,7 @@ void LogQSO::accept()
|
||||
QTextStream out(&f);
|
||||
out << logEntryItems.join(",") << endl;
|
||||
out.flush();
|
||||
flushFileBuffer(f);
|
||||
f.close();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user