mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-28 16:36:17 +02:00
save config
This commit is contained in:
parent
8a684233a2
commit
9200fec700
4 changed files with 24 additions and 1 deletions
|
@ -17,16 +17,34 @@
|
|||
***/
|
||||
|
||||
#include "config.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
Config::Config()
|
||||
{
|
||||
string dir = getenv("HOME") + string("/.config/SnapCast/");
|
||||
mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
filename_ = dir + "settings.json";
|
||||
cerr << filename_ << "\n";
|
||||
// fs::create_directory(filename_.parent_path());
|
||||
}
|
||||
|
||||
|
||||
void Config::save()
|
||||
{
|
||||
std::ofstream ofs(filename_.c_str(), std::ofstream::out|std::ofstream::trunc);
|
||||
json clients = {
|
||||
{"Client", getClientInfos()}
|
||||
};
|
||||
ofs << std::setw(4) << clients;
|
||||
ofs.close();
|
||||
}
|
||||
|
||||
|
||||
void Config::test()
|
||||
{
|
||||
|
@ -48,7 +66,7 @@ ClientInfoPtr Config::getClientInfo(const std::string& macAddress, bool add)
|
|||
{
|
||||
if (macAddress.empty())
|
||||
return nullptr;
|
||||
|
||||
|
||||
for (auto client: clients)
|
||||
{
|
||||
if (client->macAddress == macAddress)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue