-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcfiles.cpp
More file actions
70 lines (59 loc) · 1.18 KB
/
Copy pathcfiles.cpp
File metadata and controls
70 lines (59 loc) · 1.18 KB
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
#include "cfiles.h"
#include <QErrorMessage>
#include <QDebug>
#include <QMessageBox>
CFiles::
CFiles()
{
OUT = QDir::temp()
.absoluteFilePath("CPROJECT_XXXXXX.out");
SRC.setFileTemplate(QDir::temp()
.absoluteFilePath("CPROJECT_XXXXXX.cpp"));
OBJ.setFileTemplate(QDir::temp()
.absoluteFilePath("CPROJECT_XXXXXX.obj"));
if(!SRC.open() || !OBJ.open())
{
qDebug() << "Couldn't make an SRC file";
}
qDebug() << OUT;
SRC.close();
OBJ.close();
}
bool CFiles::
readSrc()
{
QString filePath{
QFileDialog::getOpenFileName(nullptr
, "Select source", ""
, "(*.cpp);;All Files (*)")
};
QFile file{filePath};
if(!file.open(QIODevice::ReadWrite
| QIODevice::Text))
{
qDebug() << "couldn't";
return false;
}
if( !SRC.open() )
{
return false;
}
SRC.write( file.readAll() );
SRC.flush();
SRC.close();
return true;
}
void CFiles::
writeSrc(QString text)
{
QFile SRCTRUNCATE{SRC.fileName()};
if (! SRCTRUNCATE.open(QIODevice::WriteOnly
| QIODevice::Truncate))
{
qDebug() << "couldn't save temp files";
return;
}
SRCTRUNCATE.write( text.toUtf8() );
SRCTRUNCATE.flush();
SRCTRUNCATE.close();
}