-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgfile.cpp
More file actions
60 lines (51 loc) · 1002 Bytes
/
gfile.cpp
File metadata and controls
60 lines (51 loc) · 1002 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
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
#include "gfile.h"
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QTextStream>
#include <QStandardPaths>
GFile::GFile(QObject *parent) :
QObject(parent)
{
}
QString GFile::read()
{
QString content;
QFile file(m_source);
if ( file.open(QIODevice::ReadOnly) ) {
content = file.readAll();
file.close();
}
return content;
}
QString GFile::getDesktop()
{
return QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
}
bool GFile::write(const QString& data)
{
QFile file(m_source);
if ( file.open(QFile::WriteOnly) ) {
QTextStream out(&file);
out<<data;
file.close();
return true;
}
else {
return false;
}
}
bool GFile::is(const QString &source)
{
QFileInfo file(source);
return file.isFile();
}
void GFile::create(const QString &source)
{
QDir qDir=source;
qDir.mkdir(source);
}
QString GFile::getUser()
{
return QDir::home().dirName();
}