-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtls_files.cpp
More file actions
33 lines (24 loc) · 732 Bytes
/
Copy pathtls_files.cpp
File metadata and controls
33 lines (24 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <QFile>
#include <QDateTime>
void file_write(const QString& fn, const QString& data, bool append) {
if (data.isEmpty()) return;
QFile file(fn);
if (append) {
file.open(QIODevice::Append | QIODevice::Unbuffered);
} else {
file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Unbuffered);
}
file.write(data.toUtf8());
file.size();
file.flush();
file.close();
}
void file_append(const QString& fn, const QString& s) {
file_write(fn, s, true);
}
void file_log(const QString& fn, const QString& s) {
QString ss =
QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss") +
": " + s + "\r\n";
file_append(fn, ss);
}