mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-14 19:59:59 +01:00
Fixed system toolkit: use $HOME for location of settings. Compilation
warning fixed.
This commit is contained in:
@@ -51,9 +51,11 @@ long SystemToolkit::memory_usage()
|
|||||||
FILE *file = fopen("/proc/self/statm", "r");
|
FILE *file = fopen("/proc/self/statm", "r");
|
||||||
if (file) {
|
if (file) {
|
||||||
unsigned long m = 0;
|
unsigned long m = 0;
|
||||||
fscanf (file, "%lu", &m); // virtual mem program size,
|
int ret = 0;
|
||||||
fscanf (file, "%lu", &m); // resident set size,
|
ret = fscanf (file, "%lu", &m); // virtual mem program size,
|
||||||
|
ret = fscanf (file, "%lu", &m); // resident set size,
|
||||||
fclose (file);
|
fclose (file);
|
||||||
|
if (ret>0)
|
||||||
size = (size_t)m * getpagesize();
|
size = (size_t)m * getpagesize();
|
||||||
}
|
}
|
||||||
return (long)size;
|
return (long)size;
|
||||||
@@ -167,17 +169,14 @@ std::string SystemToolkit::home_path()
|
|||||||
{
|
{
|
||||||
// 1. find home
|
// 1. find home
|
||||||
char *mHomePath;
|
char *mHomePath;
|
||||||
|
|
||||||
// try the environment variable
|
|
||||||
mHomePath = getenv("HOME");
|
|
||||||
|
|
||||||
if (!mHomePath) {
|
|
||||||
// try the system user info
|
// try the system user info
|
||||||
|
// NB: avoids depending on changes of the $HOME env. variable
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
struct passwd* pwd = getpwuid(getuid());
|
||||||
if (pwd)
|
if (pwd)
|
||||||
mHomePath = pwd->pw_dir;
|
mHomePath = pwd->pw_dir;
|
||||||
|
else
|
||||||
}
|
// try the $HOME environment variable
|
||||||
|
mHomePath = getenv("HOME");
|
||||||
|
|
||||||
return string(mHomePath) + PATH_SEP;
|
return string(mHomePath) + PATH_SEP;
|
||||||
}
|
}
|
||||||
@@ -217,13 +216,16 @@ bool SystemToolkit::create_directory(const string& path)
|
|||||||
|
|
||||||
string SystemToolkit::settings_path()
|
string SystemToolkit::settings_path()
|
||||||
{
|
{
|
||||||
string home(home_path());
|
// start from home folder
|
||||||
|
// NB: use the env.variable $HOME to allow system to specify
|
||||||
|
// another directory (e.g. inside a snap)
|
||||||
|
string home(getenv("HOME"));
|
||||||
|
|
||||||
// 2. try to access user settings folder
|
// 2. try to access user settings folder
|
||||||
string settingspath = home + PATH_SETTINGS;
|
string settingspath = home + PATH_SETTINGS;
|
||||||
if (SystemToolkit::file_exists(settingspath)) {
|
if (SystemToolkit::file_exists(settingspath)) {
|
||||||
// good, we have a place to put the settings file
|
// good, we have a place to put the settings file
|
||||||
// settings should be in 'vmix' subfolder
|
// settings should be in 'vimix' subfolder
|
||||||
settingspath += APP_NAME;
|
settingspath += APP_NAME;
|
||||||
|
|
||||||
// 3. create the vmix subfolder in settings folder if not existing already
|
// 3. create the vmix subfolder in settings folder if not existing already
|
||||||
|
|||||||
Reference in New Issue
Block a user