const char *File::Get(const char *key, const char *defaultValue) { CAT_DEBUG_ENFORCE(key && defaultValue); // Add this path to the hash table SanitizedKey san_key(key); KeyAdapter key_input(san_key); LineItem *item = _table.Lookup(key_input); if (item) return item->GetValueStr(); // If default value is not undefined, #if !defined(CAT_RAGDOLL_STORE_EMPTY) if (defaultValue[0] != '\0') #endif { // Create a new item for this key item = _table.Create(key_input); if (item) { // Push onto the new list CAT_FSLL_PUSH_FRONT(_newest, item, _sort_next); item->_enlisted = true; SanitizeKeyStringCase(key, item->CaseKey()); item->SetValueStr(defaultValue); } } return defaultValue; }
void File::Set(const char *key, const char *value, RWLock *lock) { CAT_DEBUG_ENFORCE(key && lock && value); lock->WriteLock(); // Add this path to the hash table SanitizedKey san_key(key); KeyAdapter key_input(san_key); LineItem *item = _table.Lookup(key_input); if (!item) { #if !defined(CAT_RAGDOLL_STORE_EMPTY) if (value[0] != '\0') #endif { // Create a new item for this key item = _table.Create(key_input); if (item) { // Push onto the new list CAT_FSLL_PUSH_FRONT(_newest, item, _sort_next); item->_enlisted = true; SanitizeKeyStringCase(key, item->CaseKey()); item->SetValueStr(value); } } } else { // If item is not listed yet, if (!item->_enlisted) { CAT_FSLL_PUSH_FRONT(_modded, item, _sort_next); item->_enlisted = true; } item->SetValueStr(value); } lock->WriteUnlock(); }