QuasarAppLib
1.0.530.c9fba11
Toggle main menu visibility
qaplatformutils_linux.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2024-2026 QuasarApp.
3
* Distributed under the lgplv3 software license, see the accompanying
4
* Everyone is permitted to copy and distribute verbatim copies
5
* of this license document, but changing it is not allowed.
6
*/
7
8
#include "
qaplatformutils.h
"
9
10
#if defined(Q_OS_LINUX)
11
#include <QDir>
12
#include <QFileInfo>
13
#include <QProcessEnvironment>
14
#elif defined(Q_OS_ANDROID)
15
#elif defined(Q_OS_WIN32)
16
#elif defined(Q_OS_MACOS)
17
#elif defined(Q_OS_IOS)
18
#endif
19
20
namespace
QuasarAppUtils
{
21
22
#if defined(Q_OS_LINUX)
23
bool
PlatformUtils::isSnap
() {
24
return
QProcessEnvironment::systemEnvironment().value(
"SNAP"
).size();
25
}
26
27
QString
PlatformUtils::snapRootFS
() {
28
return
"/var/lib/snapd/hostfs"
;
29
}
30
31
QString
PlatformUtils::transportPathToSnapRoot
(
const
QString &path) {
32
if
(
isSnap
() &&
checkSystemBackupSnapInterface
()) {
33
34
if
(QFileInfo(path).isWritable()) {
35
return
path;
36
}
37
38
if
(path.size() && path[0] != QString(
"/"
)) {
39
auto
absalutPath = QProcessEnvironment::systemEnvironment().value(
"PWD"
) +
"/"
+ path;
40
if
(!absalutPath.contains(
snapRootFS
())) {
41
return
snapRootFS
() +
"/"
+ absalutPath;
42
}
43
}
44
45
if
(!path.contains(
snapRootFS
())) {
46
return
snapRootFS
() +
"/"
+ path;
47
}
48
}
49
50
return
path;
51
}
52
53
bool
PlatformUtils::checkSystemBackupSnapInterface
() {
54
return
QDir(
snapRootFS
()).entryList(QDir::AllEntries | QDir::NoDotAndDotDot).size();
55
}
56
57
#elif defined(Q_OS_ANDROID)
58
59
bool
PlatformUtils::isSnap
() {
return
false
;}
60
61
QString
PlatformUtils::snapRootFS
() {
return
""
;}
62
63
QString
PlatformUtils::transportPathToSnapRoot
(
const
QString &path) {
return
path; }
64
65
bool
PlatformUtils::checkSystemBackupSnapInterface
() {
return
false
; }
66
67
#elif defined(Q_OS_WIN32)
68
69
bool
PlatformUtils::isSnap
() {
return
false
;}
70
71
QString
PlatformUtils::snapRootFS
() {
return
""
;}
72
73
QString
PlatformUtils::transportPathToSnapRoot
(
const
QString &path) {
return
path; }
74
75
bool
PlatformUtils::checkSystemBackupSnapInterface
() {
return
false
; }
76
77
#elif defined(Q_OS_MACOS)
78
79
bool
PlatformUtils::isSnap
() {
return
false
;}
80
81
QString
PlatformUtils::snapRootFS
() {
return
""
;}
82
83
QString
PlatformUtils::transportPathToSnapRoot
(
const
QString &path) {
return
path; }
84
85
bool
PlatformUtils::checkSystemBackupSnapInterface
() {
return
false
; }
86
87
#elif defined(Q_OS_IOS)
88
89
bool
PlatformUtils::isSnap
() {
return
false
;}
90
91
QString
PlatformUtils::snapRootFS
() {
return
""
;}
92
93
QString
PlatformUtils::transportPathToSnapRoot
(
const
QString &path) {
return
path; }
94
95
bool
PlatformUtils::checkSystemBackupSnapInterface
() {
return
false
; }
96
97
#endif
98
99
}
QuasarAppUtils::PlatformUtils::snapRootFS
static QString snapRootFS()
snapRootFS returns root file system of main OS (available read only)
QuasarAppUtils::PlatformUtils::isSnap
static bool isSnap()
isSnap This method check distribution type. true if the application packed as a snap.
QuasarAppUtils::PlatformUtils::checkSystemBackupSnapInterface
static bool checkSystemBackupSnapInterface()
checkSystemBackupSnapInterface This method check access to backup permission of snap package....
QuasarAppUtils::PlatformUtils::transportPathToSnapRoot
static QString transportPathToSnapRoot(const QString &path)
transportPathToSnapRoot change path to snap available.
QuasarAppUtils
The QuasarAppUtils namespace contains the base functions for all applications of the QuasarApp group....
Definition
crc32constexper.h:16
qaplatformutils.h
qaplatformutils_linux.cpp
Generated by
1.18.0