QuasarAppLib 1.0.530.c9fba11
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
20namespace QuasarAppUtils {
21
22#if defined(Q_OS_LINUX)
24 return QProcessEnvironment::systemEnvironment().value("SNAP").size();
25}
26
28 return "/var/lib/snapd/hostfs";
29}
30
31QString PlatformUtils::transportPathToSnapRoot(const QString &path) {
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
54 return QDir(snapRootFS()).entryList(QDir::AllEntries | QDir::NoDotAndDotDot).size();
55}
56
57#elif defined(Q_OS_ANDROID)
58
59bool PlatformUtils::isSnap() { return false;}
60
61QString PlatformUtils::snapRootFS() { return "";}
62
63QString PlatformUtils::transportPathToSnapRoot(const QString &path) { return path; }
64
66
67#elif defined(Q_OS_WIN32)
68
69bool PlatformUtils::isSnap() { return false;}
70
71QString PlatformUtils::snapRootFS() { return "";}
72
73QString PlatformUtils::transportPathToSnapRoot(const QString &path) { return path; }
74
76
77#elif defined(Q_OS_MACOS)
78
79bool PlatformUtils::isSnap() { return false;}
80
81QString PlatformUtils::snapRootFS() { return "";}
82
83QString PlatformUtils::transportPathToSnapRoot(const QString &path) { return path; }
84
86
87#elif defined(Q_OS_IOS)
88
89bool PlatformUtils::isSnap() { return false;}
90
91QString PlatformUtils::snapRootFS() { return "";}
92
93QString PlatformUtils::transportPathToSnapRoot(const QString &path) { return path; }
94
96
97#endif
98
99}
static QString snapRootFS()
snapRootFS returns root file system of main OS (available read only)
static bool isSnap()
isSnap This method check distribution type. true if the application packed as a snap.
static bool checkSystemBackupSnapInterface()
checkSystemBackupSnapInterface This method check access to backup permission of snap package....
static QString transportPathToSnapRoot(const QString &path)
transportPathToSnapRoot change path to snap available.
The QuasarAppUtils namespace contains the base functions for all applications of the QuasarApp group....