blob: cbdd640d14ff90d3dce69610c0cec6fa61e748fe (
plain)
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
77
78
79
80
81
|
#include "file_functions.h"
#include <QCoreApplication>
#include <QDir>
#include <QFileInfo>
bool file_exists(QString file_path)
{
if (file_path.isEmpty())
{
return false;
}
QFileInfo check_file(file_path);
return check_file.exists() && check_file.isFile();
}
bool dir_exists(QString dir_path)
{
if (dir_path == "")
{
return false;
}
QDir check_dir(dir_path);
return check_dir.exists();
}
bool exists(QString p_path)
{
QFile file(p_path);
return file.exists();
}
QString get_app_path()
{
QString path = QCoreApplication::applicationDirPath();
#ifdef Q_OS_ANDROID
QString storage_path = qgetenv("SECONDARY_STORAGE");
if (dir_exists(storage_path))
{
path = storage_path;
}
else
{
QString external_path = qgetenv("EXTERNAL_STORAGE");
if (dir_exists(external_path))
{
path = external_path;
}
}
#endif
#ifdef Q_OS_LINUX
QString app_path = qgetenv("APPIMAGE");
if (!app_path.isEmpty())
{
path = QFileInfo(app_path).absoluteDir().path();
}
#endif
#ifdef Q_OS_MAC
path += "/../../..";
#endif
if (path.endsWith(QDir::separator()))
{
path.chop(1);
}
return path;
}
QString get_base_path()
{
return QDir(get_app_path()).absoluteFilePath("base") + "/";
}
|