summaryrefslogtreecommitdiff
path: root/core/io/config_file.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:41:43 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 21:57:34 +0200
commit0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (patch)
tree198d4ff7665d89307f6ca2469fa38620a9eb1672 /core/io/config_file.cpp
parent07bc4e2f96f8f47991339654ff4ab16acc19d44f (diff)
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
Diffstat (limited to 'core/io/config_file.cpp')
-rw-r--r--core/io/config_file.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index 334c8f143e..1af9142317 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -63,8 +63,9 @@ PackedStringArray ConfigFile::_get_section_keys(const String &p_section) const {
void ConfigFile::set_value(const String &p_section, const String &p_key, const Variant &p_value) {
if (p_value.get_type() == Variant::NIL) {
//erase
- if (!values.has(p_section))
+ if (!values.has(p_section)) {
return; // ?
+ }
values[p_section].erase(p_key);
if (values[p_section].empty()) {
values.erase(p_section);
@@ -94,8 +95,9 @@ bool ConfigFile::has_section(const String &p_section) const {
}
bool ConfigFile::has_section_key(const String &p_section, const String &p_key) const {
- if (!values.has(p_section))
+ if (!values.has(p_section)) {
return false;
+ }
return values[p_section].has(p_key);
}
@@ -130,8 +132,9 @@ Error ConfigFile::save(const String &p_path) {
FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
if (err) {
- if (file)
+ if (file) {
memdelete(file);
+ }
return err;
}
@@ -142,8 +145,9 @@ Error ConfigFile::save_encrypted(const String &p_path, const Vector<uint8_t> &p_
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE, &err);
- if (err)
+ if (err) {
return err;
+ }
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
err = fae->open_and_parse(f, p_key, FileAccessEncrypted::MODE_WRITE_AES256);
@@ -159,8 +163,9 @@ Error ConfigFile::save_encrypted_pass(const String &p_path, const String &p_pass
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE, &err);
- if (err)
+ if (err) {
return err;
+ }
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
err = fae->open_and_parse_password(f, p_pass, FileAccessEncrypted::MODE_WRITE_AES256);
@@ -175,8 +180,9 @@ Error ConfigFile::save_encrypted_pass(const String &p_path, const String &p_pass
Error ConfigFile::_internal_save(FileAccess *file) {
for (OrderedHashMap<String, OrderedHashMap<String, Variant>>::Element E = values.front(); E; E = E.next()) {
- if (E != values.front())
+ if (E != values.front()) {
file->store_string("\n");
+ }
file->store_string("[" + E.key() + "]\n\n");
for (OrderedHashMap<String, Variant>::Element F = E.get().front(); F; F = F.next()) {
@@ -195,8 +201,9 @@ Error ConfigFile::load(const String &p_path) {
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- if (!f)
+ if (!f) {
return err;
+ }
return _internal_load(p_path, f);
}
@@ -205,8 +212,9 @@ Error ConfigFile::load_encrypted(const String &p_path, const Vector<uint8_t> &p_
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- if (err)
+ if (err) {
return err;
+ }
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
err = fae->open_and_parse(f, p_key, FileAccessEncrypted::MODE_READ);
@@ -222,8 +230,9 @@ Error ConfigFile::load_encrypted_pass(const String &p_path, const String &p_pass
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- if (err)
+ if (err) {
return err;
+ }
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
err = fae->open_and_parse_password(f, p_pass, FileAccessEncrypted::MODE_READ);