first commit
This commit is contained in:
22
src/config_file.cpp
Normal file
22
src/config_file.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "config_file.hpp"
|
||||
#include <stdlib.h>
|
||||
|
||||
sc::config_file::config_file(const std::string& prog_name, bool has_dir)
|
||||
: _has_dir {has_dir}, _prog_name {prog_name}
|
||||
{
|
||||
std::string cfg_path;
|
||||
_root = getenv("HOME");
|
||||
_root += "/.config/";
|
||||
if (has_dir) {
|
||||
_root += prog_name + "/";
|
||||
cfg_path = _root + "config"; // sensible default
|
||||
// TODO maybe also look for <progname>.conf or <progname>rc here.
|
||||
} else {
|
||||
cfg_path = _root + prog_name + "rc"; // standard "run control" file
|
||||
}
|
||||
_cfg = sc::parse_ini_file(cfg_path);
|
||||
}
|
||||
|
||||
std::string sc::config_file::path_for_file_name(const std::string& file_name) {
|
||||
return _root + file_name;
|
||||
}
|
Reference in New Issue
Block a user