irccd  3.0.3
Functions
irccd::sys Namespace Reference

Namespace for system functions. More...

Functions

void set_program_name (std::string name) noexcept
 
auto name () -> std::string
 
auto version () -> std::string
 
auto uptime () -> std::uint64_t
 
auto ticks () -> std::uint64_t
 
auto env (const std::string &var) -> std::string
 
auto home () -> std::string
 
auto cachedir () -> boost::filesystem::path
 
auto datadir () -> boost::filesystem::path
 
auto sysconfdir () -> boost::filesystem::path
 
auto plugindir () -> boost::filesystem::path
 
auto username () -> std::string
 
auto config_filenames (std::string_view file) -> std::vector< std::string >
 
auto plugin_filenames (const std::string &name, const std::vector< std::string > &extensions) -> std::vector< std::string >
 

Detailed Description

Namespace for system functions.

Function Documentation

◆ cachedir()

auto irccd::sys::cachedir ( ) -> boost::filesystem::path

Get the cache directory as specified as compile time option IRCCD_INSTALL_LOCALSTATEDIR, if the value is absolute, it is returned as-is.

If the component is relative, it is evaluated using the binary executable path.

Returns
the evaluated cache directory.
See also
datadir
configdir

◆ config_filenames()

auto irccd::sys::config_filenames ( std::string_view  file) -> std::vector< std::string >

Construct a list of paths to read configuration files from.

This function does not test the presence of the files as a condition race may occur.

The caller is responsible of opening files for each path.

Parameters
filethe filename to append for convenience
Returns
the list of paths to check in order

◆ datadir()

auto irccd::sys::datadir ( ) -> boost::filesystem::path

Like cachedir but for IRCCD_INSTALL_DATADIR.

Returns
the evaluated data directory.
See also
cachedir
datadir

◆ env()

auto irccd::sys::env ( const std::string &  var) -> std::string

Get an environment variable.

Parameters
varthe environment variable
Returns
the value or empty string

◆ home()

auto irccd::sys::home ( ) -> std::string

Get home directory usually /home/foo

Returns
the home directory

◆ name()

auto irccd::sys::name ( ) -> std::string

Get the system name.

Returns
the name

◆ plugin_filenames()

auto irccd::sys::plugin_filenames ( const std::string &  name,
const std::vector< std::string > &  extensions 
) -> std::vector< std::string >

Construct a list of paths for reading plugins.

Parameters
namethe plugin id (without extension)
extensionsthe list of extensions supported
Returns
the list of filenames to check

◆ plugindir()

auto irccd::sys::plugindir ( ) -> boost::filesystem::path

Like cachedir but for IRCCD_INSTALL_LIBDIR.

Returns
the evaluated system plugin directory.
See also
cachedir
datadir

◆ set_program_name()

void irccd::sys::set_program_name ( std::string  name)
noexcept

Set the program name, needed for some functions or some systems.

Parameters
namethe program name

◆ sysconfdir()

auto irccd::sys::sysconfdir ( ) -> boost::filesystem::path

Like cachedir but for IRCCD_INSTALL_SYSCONFDIR.

Returns
the evaluated config directory.
See also
cachedir
datadir
Note
use config_filenames for irccd.conf, irccdctl.conf files

◆ ticks()

auto irccd::sys::ticks ( ) -> std::uint64_t

Get the milliseconds elapsed since the application startup.

Returns
the milliseconds

◆ uptime()

auto irccd::sys::uptime ( ) -> std::uint64_t

Get the number of seconds elapsed since the boottime.

Returns
the number of seconds

◆ username()

auto irccd::sys::username ( ) -> std::string

Get user account login or empty if not available.

Returns
the user account name

◆ version()

auto irccd::sys::version ( ) -> std::string

Get the system version.

Returns
the version