VGamepad PC
The PC app for the virtual game controller.
Loading...
Searching...
No Matches
appdir.hpp File Reference
#include <QApplication>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QMessageBox>
#include <QStandardPaths>
#include <QTemporaryFile>
#include <cstdlib>
Include dependency graph for appdir.hpp:
This graph shows which files directly or indirectly include this file:

Functions

constexpr bool isPortableMode ()
 Determines if the application should run in portable mode.
bool isDirWritable (const QString &path)
 Checks writability by creating a file.
QString getConfigDir ()
 Returns the directory for configuration files (settings.ini).
QString getDataDir ()
 Returns the directory for application data files (profiles, etc.).

Function Documentation

◆ getConfigDir()

QString getConfigDir ( )
inline

Returns the directory for configuration files (settings.ini).

  • Portable mode: Parent directory of the executable's directory
  • Installable mode:
    • Linux: ~/.config/VirtualGamePad/
    • Windows: LOCALAPPDATA%/<org>/<app>/ (Qt AppConfigLocation)
  • Debug builds: Always use application directory
Warning
Instantiate the QApplication object first

◆ getDataDir()

QString getDataDir ( )
inline

Returns the directory for application data files (profiles, etc.).

  • Portable mode: Same as config directory
  • Installable mode:
    • Linux: ~/.local/share/VirtualGamePad/
    • Windows: LOCALAPPDATA%/<org>/<app>/ (Qt AppConfigLocation, same as config)
  • Debug builds: Always use application directory
Warning
Instantiate the QApplication object first

◆ isDirWritable()

bool isDirWritable ( const QString & path)
inline

Checks writability by creating a file.

QFileInfo::isWritable() ignores NTFS ACLs unless a global flag is set, so it cannot be trusted.

◆ isPortableMode()

bool isPortableMode ( )
constexpr

Determines if the application should run in portable mode.

Portable mode is determined by the build-time flag PORTABLE_BUILD.

In portable mode, settings and data are stored in the application directory (the parent of the directory containing the executable). In installable mode, standard OS locations are used (~/.config, LOCALAPPDATA%, etc.).