-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathBuildFile.cpp
103 lines (72 loc) · 2.08 KB
/
BuildFile.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "BuildFile.h"
#include <QTextStream>
#include <QDateTime>
void buildFile()//建立存放数据的文件
{
QString infoPath = QDir::currentPath();
infoPath = infoPath + "/info";
QDir dirs;
dirs.mkpath(infoPath); //创建目录
QString name1 = infoPath + "/nickName.txt";
QString name2 = infoPath + "/userName.txt";
QString passWord = infoPath + "/passWord.txt";
QString age = infoPath + "/age.txt";
QString sex = infoPath + "/sex.txt";
QString registTime = infoPath + "/registTime.txt";
QFile file;
//程序第一次运行时初始化数据
if (!file.exists(name1))
{
QFile newFile(name1);
newFile.open(QIODevice::WriteOnly);
QTextStream name1IO(&newFile);
QString model("爱编程");
model = model + "\n";
name1IO << model;
newFile.close();
}
if (!file.exists(name2))
{
QFile newFile(name2);
newFile.open(QIODevice::WriteOnly);
QTextStream name1IO(&newFile);
name1IO << 20160000 << "\n";
newFile.close();
}
if (!file.exists(passWord))
{
QFile newFile(passWord);
newFile.open(QIODevice::WriteOnly);
QTextStream name1IO(&newFile);
name1IO << "10086" << "\n";
newFile.close();
}
if (!file.exists(age))
{
QFile newFile(age);
newFile.open(QIODevice::WriteOnly);
QTextStream name1IO(&newFile);
name1IO << "18" << "\n";
newFile.close();
}
if (!file.exists(registTime))
{
QFile newFile(registTime);
newFile.open(QIODevice::WriteOnly);
QTextStream name1IO(&newFile);
QDateTime time = QDateTime::currentDateTime();
QString str = time.toString("yyyy-MM-dd");
name1IO << str << "\n";
newFile.close();
}
if (!file.exists(sex))
{
QFile newFile(sex);
newFile.open(QIODevice::WriteOnly);
QTextStream name1IO(&newFile);
QString model("女");
model = model + "\n";
name1IO << model;
newFile.close();
}
}