-
Notifications
You must be signed in to change notification settings - Fork 0
/
filesystem.cpp
38 lines (29 loc) · 745 Bytes
/
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
#include "filesystem.h"
#include <QDir>
#include <QFile>
#include <QUrl>
FileSystem::FileSystem(QObject *parent)
: QObject{parent}
{
}
bool FileSystem::exists(const QString& filename) const
{
return QFile::exists(filename);
}
QString FileSystem::readFile(const QString& filename) const
{
QFile file(filename);
if(file.open(QIODevice::ReadOnly)) {
return file.readAll();
}
return "";
}
QStringList FileSystem::listFiles(const QString& path) const
{
QDir directory(path);
return directory.entryList(QDir::Files | QDir::NoDot | QDir::NoDotDot);
}
QString FileSystem::toUrl(const QString& filename) const
{
return QUrl::fromLocalFile(filename).toString();
}