Static Public Member Functions | List of all members
App Struct Referencefinal

Utilities for accessing application information. More...

#include <App.hpp>

Static Public Member Functions

static Resource::File getApplicationRuntimeDataDirectory (const std::string &appGroup, const std::string &appName)
 Get the runtime data directory for the current application. More...
 
static Resource::File getGlobalApplicationConfigDirectory (const std::string &appGroup, const std::string &appName)
 Get the global config directory for the specified application group/name. More...
 
static Resource::File getGlobalApplicationDataDirectory (const std::string &appGroup, const std::string &appName)
 Get the global data directory for the specified application group/name. More...
 
static Resource::File getUserApplicationConfigDirectory (const std::string &appGroup, const std::string &appName)
 Get the user config directory for the specified application group/name. More...
 
static Resource::File getUserApplicationDataDirectory (const std::string &appGroup, const std::string &appName)
 Get the user data directory for the specified application group/name. More...
 

Detailed Description

Utilities for accessing application information.

Member Function Documentation

◆ getApplicationRuntimeDataDirectory()

static Resource::File getApplicationRuntimeDataDirectory ( const std::string &  appGroup,
const std::string &  appName 
)
inlinestatic

Get the runtime data directory for the current application.

The directory is fixed at the first call this function and will not change for the life of the process.

The directory is read-write for the user that owns the process.

The directory returned depends on file system availability. Specifically, the directory:

  • must be owned by the user;
  • must have access rights restricted to the user only (for Unix OSes, the access mode must be 0700);
  • must be on a local file system and not shared with any other system;
  • must be fully-featured by the standards of the operating system;

This function will create the directory on the first call, if the directory does not already exist.

For Unix type OSes, the directory is "${XDG_RUNTIME_DIR}/appGroup/appName" or "${TMPDIR}/appGroup/appName" or "/tmp/${USER}/appGroup/appName" depending on the existence of the XDG_RUNTIME_DIR and TMPDIR environment variables.

For Windows type OSes, the directory is "GetTempPath() / appGroup / appName".

This function does not implement any logic to handle:

  • the lifetime of the directory being bound to the logged in user;
  • the removal of the directory when the user fully logs out;
  • possible loss of data due to periodic clean-ups of the temporary directory by other processes.

Applications should provide suitable logic to deal with these requirements, including updating file access timestamps every 6 hours and/or setting the sticky bit of each file.

Parameters
appGroupthe application group name (normally the company name without spaces)
appNamethe application group name (without spaces)
Exceptions
NotFoundExceptionif the user config directory could not be located

◆ getGlobalApplicationConfigDirectory()

static Resource::File getGlobalApplicationConfigDirectory ( const std::string &  appGroup,
const std::string &  appName 
)
inlinestatic

Get the global config directory for the specified application group/name.

The directory is fixed at the first call this function and will not change for the life of the process.

The directory is normally read-only.

For Unix type OSes, the directory is "${PROGRAM_LOCATION}/../share/appGroup/appName/config". For Windows type OSes, the directory is "${PROGRAM_LOCATION}/config".

Parameters
appGroupthe application group name (normally the company name without spaces)
appNamethe application group name (without spaces)
Exceptions
NotFoundExceptionif the user config directory could not be located

◆ getGlobalApplicationDataDirectory()

static Resource::File getGlobalApplicationDataDirectory ( const std::string &  appGroup,
const std::string &  appName 
)
inlinestatic

Get the global data directory for the specified application group/name.

The directory is fixed at the first call this function and will not change for the life of the process.

The directory is normally read-only.

For Unix type OSes, the directory is "${PROGRAM_LOCATION}/../share/appGroup/appName/data". For Windows type OSes, the directory is "${PROGRAM_LOCATION}/data".

Parameters
appGroupthe application group name (normally the company name without spaces)
appNamethe application group name (without spaces)
Exceptions
NotFoundExceptionif the global data directory could not be located

◆ getUserApplicationConfigDirectory()

static Resource::File getUserApplicationConfigDirectory ( const std::string &  appGroup,
const std::string &  appName 
)
inlinestatic

Get the user config directory for the specified application group/name.

The directory is fixed at the first call this function and will not change for the life of the process.

The directory is read-write and specific to the user running the process.

For Unix type OSes, the directory is "${XDG_CONFIG_HOME}/appGroup/appName" or "${HOME}/.config/appGroup/appName" if ${XDG_CONFIG_HOME} is not defined.

For Windows type OSes, the directory is "${HOME}/AppData/Roaming/appGroup/appName/config".

Parameters
appGroupthe application group name (normally the company name without spaces)
appNamethe application group name (without spaces)
Exceptions
NotFoundExceptionif the user config directory could not be located

◆ getUserApplicationDataDirectory()

static Resource::File getUserApplicationDataDirectory ( const std::string &  appGroup,
const std::string &  appName 
)
inlinestatic

Get the user data directory for the specified application group/name.

The directory is fixed at the first call this function and will not change for the life of the process.

The directory is read-write and specific to the user running the process.

For Unix type OSes, the directory is "${XDG_DATA_HOME}/appGroup/appName" or "${HOME}/.local/share/appGroup/appName" if ${XDG_DATA_HOME} is not defined.

For Windows type OSes, the directory is "${HOME}/AppData/Roaming/appGroup/appName/share".

Parameters
appGroupthe application group name (normally the company name without spaces)
appNamethe application group name (without spaces)
Exceptions
NotFoundExceptionif the user data directory could not be located

The documentation for this struct was generated from the following file: