-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilesystem.cpp
executable file
·73 lines (60 loc) · 1.43 KB
/
filesystem.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
#include "filesystem.h"
#include "stbpluginobject.h"
#include "browser.h"
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QDebug>
using namespace yasem;
FileSystem::FileSystem(Profile *profile, QWidget *parent):
BaseWidget(profile, parent)
{
}
QString FileSystem::path()
{
STUB();
return profile->getProfilePlugin()->browser()->browserRootDir();
}
QObject* FileSystem::openFile(const QString &name, const QString &access)
{
qDebug() << "name:" << name;
QFile* file = new QFile(name);
bool isOpened = file->open(QFile::ReadOnly);
if(!isOpened)
qWarning() << "File '%1' is not opened!" << name;
return file;
}
void FileSystem::closeFile(QObject *file) const
{
QFile* f = dynamic_cast<QFile*>(file);
if(f->isOpen())
f->close();
}
QString FileSystem::readLine(QObject *file) const
{
QFile* f = dynamic_cast<QFile*>(file);
if(f->isOpen())
return QString(f->readLine());
return "";
}
QString FileSystem::readAll(QObject *file) const
{
QFile* f = dynamic_cast<QFile*>(file);
if(f->isOpen())
return QString(f->readAll());
return "";
}
bool FileSystem::fileExists(const QString &name)
{
QFile file(name);
qDebug() << "fileExists:" << name;
return file.exists();
}
QString FileSystem::GetPluginInfo(int infoId)
{
return profile->datasource()->get(group(), "version", "0.1");
}
QString FileSystem::group()
{
return "FileSystem";
}