gio-qt 0.0.16
Loading...
Searching...
No Matches
DGlibUtils Class Reference

Static Public Member Functions

static QString userSpecialDir (DGlibUserDirectory userDirectory)
 Get the full path by directory type.
static QStringList systemDataDirs ()
 Get an ordered list of base directories in which to access system-wide application data.
static QString userDataDir ()
 Get a base directory in which to access application data such as icons that is customized for a particular user.
static QString tmpDir ()
 Gets the directory to use for temporary files.
static QString formatSize (quint64 size, DGlibFormatSizeFlags flags=FORMAT_SIZE_DEFAULT)
 Formats a size (for example the size of a file) into a human readable string.

Member Function Documentation

◆ formatSize()

QString DGlibUtils::formatSize ( quint64 size,
DGlibFormatSizeFlags flags = FORMAT_SIZE_DEFAULT )
static

Formats a size (for example the size of a file) into a human readable string.

Sizes are rounded to the nearest size prefix (kB, MB, GB) and are displayed rounded to the nearest tenth. E.g. the file size 3292528 bytes will be converted into the string "3.2 MB".

The prefix units base is 1000 (i.e. 1 kB is 1000 bytes), unless the DGlibFormatSizeFlags::FORMAT_SIZE_IEC_UNITS flag is set.

Parameters
sizeA size in bytes.
flagsFlags to modify the output.
Returns
A formatted string containing a human readable file size.

◆ systemDataDirs()

QStringList DGlibUtils::systemDataDirs ( )
static

Get an ordered list of base directories in which to access system-wide application data.

Wrapper of Glib::get_system_data_dirs(), behavior similar (should be the same under UNIX) to QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).

On UNIX platforms this is determined using the mechanisms described in the XDG Base Directory Specification In this case the list of directories retrieved will be XDG_DATA_DIRS.

◆ tmpDir()

QString DGlibUtils::tmpDir ( )
static

Gets the directory to use for temporary files.

Wrapper of Glib::get_user_data_dir(), behavior similar (but not the same) to QDir::temp() or QStandardPaths::writableLocation(QStandardPaths::TempLocation).

This is found from inspecting the environment variables TMPDIR, TMP, and TEMP in that order. If none of those are defined "/tmp" is returned on UNIX and "C:\\" on Windows.

Returns
The directory to use for temporary files.

◆ userDataDir()

QString DGlibUtils::userDataDir ( )
static

Get a base directory in which to access application data such as icons that is customized for a particular user.

Wrapper of Glib::get_user_data_dir(), behavior similar (should be the same under UNIX) to QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).

On UNIX platforms this is determined using the mechanisms described in the XDG Base Directory Specification. In this case the directory retrieved will be XDG_DATA_HOME.

◆ userSpecialDir()

QString DGlibUtils::userSpecialDir ( DGlibUserDirectory userDirectory)
static

Get the full path by directory type.

Wrapper of Glib::get_user_data_dir(), behavior similar to QStandardPaths::writableLocation(), but at least it has USER_DIRECTORY_TEMPLATES .

On UNIX platforms this is determined using the mechanisms described in the XDG Base Directory Specification.

Parameters
userDirectoryThe logical id of special directory.
Returns
The path to the specified special directory, or an empty string if the logical id was not found.

The documentation for this class was generated from the following files: