-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcontactexporter.cpp
44 lines (30 loc) · 1020 Bytes
/
contactexporter.cpp
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
34
35
36
37
38
39
40
41
42
43
44
#include "contactexporter.h"
#include <QFile>
#include <QTextStream>
#include <QStandardPaths>
#include <QDebug>
#include <QDir>
void writeStringToFile(const QString &vals) {
auto path {QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/csv/"};
auto fileName{"contacts.csv"};
QDir temp{path};
if (!temp.exists()) {
qDebug() << "Warning, shareable folder does not exist: " << path << "\n";
QDir("").mkdir(path);
}
QFile file(path + fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)){
qDebug() << "Something broke while trying to write the file\n";
qDebug() << "You tried writing: " << fileName << "\n";
return;
}
QTextStream out(&file);
out << vals;
qDebug() << "Wrote data";
file.close();
}
QString getFilePath() {
auto path {QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/csv/"};
auto fileName{"contacts.csv"};
return path + fileName;
}