mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-03 16:18:51 -04:00
ams: use R_SUCCEED, R_THROW globally
This commit is contained in:
parent
e5b1739f65
commit
dd78ede99f
370 changed files with 2107 additions and 2107 deletions
|
@ -72,7 +72,7 @@ namespace ams::kvdb {
|
|||
R_UNLESS(m_buffer != nullptr, kvdb::ResultAllocationFailed());
|
||||
|
||||
m_size = size;
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result Initialize(const void *buf, size_t size) {
|
||||
|
@ -82,7 +82,7 @@ namespace ams::kvdb {
|
|||
/* Copy the input data in. */
|
||||
std::memcpy(m_buffer, buf, size);
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
};
|
||||
}
|
|
@ -51,7 +51,7 @@ namespace ams::kvdb {
|
|||
LruHeader new_header = { .entry_count = 0, };
|
||||
R_TRY(fs::WriteFile(file, 0, std::addressof(new_header), sizeof(new_header), fs::WriteOption::Flush));
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
private:
|
||||
void RemoveIndex(size_t i) {
|
||||
|
@ -91,7 +91,7 @@ namespace ams::kvdb {
|
|||
/* Read entries. */
|
||||
R_TRY(fs::ReadFile(file, sizeof(m_header), m_keys, BufferSize));
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result Save() {
|
||||
|
@ -109,7 +109,7 @@ namespace ams::kvdb {
|
|||
/* Flush. */
|
||||
R_TRY(fs::FlushFile(file));
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
size_t GetCount() const {
|
||||
|
@ -223,7 +223,7 @@ namespace ams::kvdb {
|
|||
|
||||
/* The entry exists and is the correct type. */
|
||||
*out = true;
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
static Result DirectoryExists(bool *out, const char *path) {
|
||||
|
@ -239,7 +239,7 @@ namespace ams::kvdb {
|
|||
R_TRY(LeastRecentlyUsedList::CreateNewList(GetLeastRecentlyUsedListPath(dir)));
|
||||
R_TRY(fs::CreateDirectory(dir));
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
static Result ValidateExistingCache(const char *dir) {
|
||||
|
@ -254,7 +254,7 @@ namespace ams::kvdb {
|
|||
/* If one exists but not the other, we have an invalid state. */
|
||||
R_UNLESS(has_lru && has_kvs, kvdb::ResultInvalidFilesystemState());
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
private:
|
||||
void RemoveOldestKey() {
|
||||
|
@ -276,7 +276,7 @@ namespace ams::kvdb {
|
|||
/* layout it can't really be fixed without breaking existing devices... */
|
||||
R_TRY(m_kvs.Initialize(dir));
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
size_t GetCount() const {
|
||||
|
@ -335,7 +335,7 @@ namespace ams::kvdb {
|
|||
if (m_lru_list.GetCount() == 1) {
|
||||
m_lru_list.Pop();
|
||||
R_TRY(m_lru_list.Save());
|
||||
return fs::ResultNotEnoughFreeSpace();
|
||||
R_THROW(fs::ResultNotEnoughFreeSpace());
|
||||
}
|
||||
|
||||
/* Otherwise, remove the oldest element from the cache and try again. */
|
||||
|
@ -351,7 +351,7 @@ namespace ams::kvdb {
|
|||
/* Save the list. */
|
||||
R_TRY(m_lru_list.Save());
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
|
@ -365,7 +365,7 @@ namespace ams::kvdb {
|
|||
R_TRY(m_kvs.Remove(key));
|
||||
R_TRY(m_lru_list.Save());
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result RemoveAll() {
|
||||
|
@ -375,7 +375,7 @@ namespace ams::kvdb {
|
|||
}
|
||||
R_TRY(m_lru_list.Save());
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace ams::kvdb {
|
|||
size_t size = 0;
|
||||
R_TRY(this->Get(std::addressof(size), out_value, sizeof(Value), key));
|
||||
AMS_ABORT_UNLESS(size >= sizeof(Value));
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
template<typename Key>
|
||||
|
|
|
@ -125,7 +125,7 @@ namespace ams::kvdb {
|
|||
R_UNLESS(m_entries != nullptr, kvdb::ResultAllocationFailed());
|
||||
m_capacity = capacity;
|
||||
m_memory_resource = mr;
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result Set(const Key &key, const void *value, size_t value_size) {
|
||||
|
@ -148,14 +148,14 @@ namespace ams::kvdb {
|
|||
|
||||
/* Save the new Entry in the map. */
|
||||
*it = Entry(key, new_value, value_size);
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result AddUnsafe(const Key &key, void *value, size_t value_size) {
|
||||
R_UNLESS(m_count < m_capacity, kvdb::ResultOutOfKeyResource());
|
||||
|
||||
m_entries[m_count++] = Entry(key, value, value_size);
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result Remove(const Key &key) {
|
||||
|
@ -167,7 +167,7 @@ namespace ams::kvdb {
|
|||
m_memory_resource->Deallocate(it->GetValuePointer(), it->GetValueSize());
|
||||
std::memmove(it, it + 1, sizeof(*it) * (this->end() - (it + 1)));
|
||||
m_count--;
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Entry *begin() {
|
||||
|
@ -276,7 +276,7 @@ namespace ams::kvdb {
|
|||
R_TRY(m_index.Initialize(capacity, mr));
|
||||
m_memory_resource = mr;
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result Initialize(size_t capacity, MemoryResource *mr) {
|
||||
|
@ -288,7 +288,7 @@ namespace ams::kvdb {
|
|||
/* Initialize our index. */
|
||||
R_TRY(m_index.Initialize(capacity, mr));
|
||||
m_memory_resource = mr;
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
size_t GetCount() const {
|
||||
|
@ -384,7 +384,7 @@ namespace ams::kvdb {
|
|||
size_t size = std::min(max_out_size, it->GetValueSize());
|
||||
std::memcpy(out_value, it->GetValuePointer(), size);
|
||||
*out_size = size;
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
template<typename Value = void>
|
||||
|
@ -394,7 +394,7 @@ namespace ams::kvdb {
|
|||
R_UNLESS(it != this->end(), kvdb::ResultKeyNotFound());
|
||||
|
||||
*out_value = it->template GetValuePointer<Value>();
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
template<typename Value = void>
|
||||
|
@ -404,7 +404,7 @@ namespace ams::kvdb {
|
|||
R_UNLESS(it != this->end(), kvdb::ResultKeyNotFound());
|
||||
|
||||
*out_value = it->template GetValuePointer<Value>();
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
|
@ -414,7 +414,7 @@ namespace ams::kvdb {
|
|||
R_UNLESS(it != this->end(), kvdb::ResultKeyNotFound());
|
||||
|
||||
*out_value = it->template GetValue<Value>();
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result GetValueSize(size_t *out_size, const Key &key) const {
|
||||
|
@ -423,7 +423,7 @@ namespace ams::kvdb {
|
|||
R_UNLESS(it != this->end(), kvdb::ResultKeyNotFound());
|
||||
|
||||
*out_size = it->GetValueSize();
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result Remove(const Key &key) {
|
||||
|
@ -485,7 +485,7 @@ namespace ams::kvdb {
|
|||
R_TRY(fs::WriteFile(file, 0, buf, size, fs::WriteOption::Flush));
|
||||
}
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result Commit(const AutoBuffer &buffer, bool destructive) {
|
||||
|
@ -503,7 +503,7 @@ namespace ams::kvdb {
|
|||
R_TRY(fs::RenameFile(m_temp_path.Get(), m_path.Get()));
|
||||
}
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
size_t GetArchiveSize() const {
|
||||
|
@ -530,7 +530,7 @@ namespace ams::kvdb {
|
|||
R_TRY(dst->Initialize(static_cast<size_t>(archive_size)));
|
||||
R_TRY(fs::ReadFile(file, 0, dst->Get(), dst->GetSize()));
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue