Changeset View
Changeset View
Standalone View
Standalone View
source/ps/ConfigDB.cpp
Show First 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void CConfigDB::SetValueBool(EConfigNamespace ns, const CStr& name, const bool value) | void CConfigDB::SetValueBool(EConfigNamespace ns, const CStr& name, const bool value) | ||||
{ | { | ||||
CStr valueString = value ? "true" : "false"; | CStr valueString = value ? "true" : "false"; | ||||
SetValueString(ns, name, valueString); | SetValueString(ns, name, valueString); | ||||
} | } | ||||
void CConfigDB::SetValueList(EConfigNamespace ns, const CStr& name, std::vector<CStr> values) | |||||
{ | |||||
CHECK_NS(;); | |||||
std::lock_guard<std::recursive_mutex> s(cfgdb_mutex); | |||||
TConfigMap::iterator it = m_Map[ns].find(name); | |||||
if (it == m_Map[ns].end()) | |||||
it = m_Map[ns].insert(m_Map[ns].begin(), make_pair(name, CConfigValueSet(1))); | |||||
it->second = values; | |||||
} | |||||
void CConfigDB::RemoveValue(EConfigNamespace ns, const CStr& name) | void CConfigDB::RemoveValue(EConfigNamespace ns, const CStr& name) | ||||
{ | { | ||||
CHECK_NS(;); | CHECK_NS(;); | ||||
std::lock_guard<std::recursive_mutex> s(cfgdb_mutex); | std::lock_guard<std::recursive_mutex> s(cfgdb_mutex); | ||||
TConfigMap::iterator it = m_Map[ns].find(name); | TConfigMap::iterator it = m_Map[ns].find(name); | ||||
if (it == m_Map[ns].end()) | if (it == m_Map[ns].end()) | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | bool CConfigDB::WriteFile(EConfigNamespace ns, const VfsPath& path) const | ||||
char* pos = (char*)buf.get(); | char* pos = (char*)buf.get(); | ||||
for (const std::pair<CStr, CConfigValueSet>& p : m_Map[ns]) | for (const std::pair<CStr, CConfigValueSet>& p : m_Map[ns]) | ||||
{ | { | ||||
size_t i; | size_t i; | ||||
pos += sprintf(pos, "%s = ", p.first.c_str()); | pos += sprintf(pos, "%s = ", p.first.c_str()); | ||||
for (i = 0; i < p.second.size() - 1; ++i) | for (i = 0; i < p.second.size() - 1; ++i) | ||||
pos += sprintf(pos, "\"%s\", ", EscapeString(p.second[i]).c_str()); | pos += sprintf(pos, "\"%s\", ", EscapeString(p.second[i]).c_str()); | ||||
pos += sprintf(pos, "\"%s\"\n", EscapeString(p.second[i]).c_str()); | pos += sprintf(pos, "\"%s\"\n", EscapeString(p.second[i]).c_str()); | ||||
} | } | ||||
wraitii: debug left in, sorry | |||||
const size_t len = pos - (char*)buf.get(); | const size_t len = pos - (char*)buf.get(); | ||||
Status ret = g_VFS->CreateFile(path, buf, len); | Status ret = g_VFS->CreateFile(path, buf, len); | ||||
if (ret < 0) | if (ret < 0) | ||||
{ | { | ||||
LOGERROR("CConfigDB::WriteFile(): CreateFile \"%s\" failed (error: %d)", path.string8(), (int)ret); | LOGERROR("CConfigDB::WriteFile(): CreateFile \"%s\" failed (error: %d)", path.string8(), (int)ret); | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
debug left in, sorry