mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 08:23:29 +00:00
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
This commit is contained in:
parent
b8d198eeed
commit
140350d767
694 changed files with 23283 additions and 12499 deletions
|
@ -61,8 +61,9 @@ Error DirAccessUnix::list_dir_begin() {
|
|||
//chdir(current_path.utf8().get_data());
|
||||
dir_stream = opendir(current_dir.utf8().get_data());
|
||||
//chdir(real_current_dir_name);
|
||||
if (!dir_stream)
|
||||
if (!dir_stream) {
|
||||
return ERR_CANT_OPEN; //error!
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -70,8 +71,9 @@ Error DirAccessUnix::list_dir_begin() {
|
|||
bool DirAccessUnix::file_exists(String p_file) {
|
||||
GLOBAL_LOCK_FUNCTION
|
||||
|
||||
if (p_file.is_rel_path())
|
||||
if (p_file.is_rel_path()) {
|
||||
p_file = current_dir.plus_file(p_file);
|
||||
}
|
||||
|
||||
p_file = fix_path(p_file);
|
||||
|
||||
|
@ -88,8 +90,9 @@ bool DirAccessUnix::file_exists(String p_file) {
|
|||
bool DirAccessUnix::dir_exists(String p_dir) {
|
||||
GLOBAL_LOCK_FUNCTION
|
||||
|
||||
if (p_dir.is_rel_path())
|
||||
if (p_dir.is_rel_path()) {
|
||||
p_dir = get_current_dir().plus_file(p_dir);
|
||||
}
|
||||
|
||||
p_dir = fix_path(p_dir);
|
||||
|
||||
|
@ -100,8 +103,9 @@ bool DirAccessUnix::dir_exists(String p_dir) {
|
|||
}
|
||||
|
||||
uint64_t DirAccessUnix::get_modified_time(String p_file) {
|
||||
if (p_file.is_rel_path())
|
||||
if (p_file.is_rel_path()) {
|
||||
p_file = current_dir.plus_file(p_file);
|
||||
}
|
||||
|
||||
p_file = fix_path(p_file);
|
||||
|
||||
|
@ -117,8 +121,9 @@ uint64_t DirAccessUnix::get_modified_time(String p_file) {
|
|||
};
|
||||
|
||||
String DirAccessUnix::get_next() {
|
||||
if (!dir_stream)
|
||||
if (!dir_stream) {
|
||||
return "";
|
||||
}
|
||||
|
||||
dirent *entry = readdir(dir_stream);
|
||||
|
||||
|
@ -161,8 +166,9 @@ bool DirAccessUnix::current_is_hidden() const {
|
|||
}
|
||||
|
||||
void DirAccessUnix::list_dir_end() {
|
||||
if (dir_stream)
|
||||
if (dir_stream) {
|
||||
closedir(dir_stream);
|
||||
}
|
||||
dir_stream = nullptr;
|
||||
_cisdir = false;
|
||||
}
|
||||
|
@ -263,8 +269,9 @@ bool DirAccessUnix::drives_are_shortcuts() {
|
|||
Error DirAccessUnix::make_dir(String p_dir) {
|
||||
GLOBAL_LOCK_FUNCTION
|
||||
|
||||
if (p_dir.is_rel_path())
|
||||
if (p_dir.is_rel_path()) {
|
||||
p_dir = get_current_dir().plus_file(p_dir);
|
||||
}
|
||||
|
||||
p_dir = fix_path(p_dir);
|
||||
|
||||
|
@ -291,8 +298,9 @@ Error DirAccessUnix::change_dir(String p_dir) {
|
|||
String prev_dir;
|
||||
char real_current_dir_name[2048];
|
||||
ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == nullptr, ERR_BUG);
|
||||
if (prev_dir.parse_utf8(real_current_dir_name))
|
||||
if (prev_dir.parse_utf8(real_current_dir_name)) {
|
||||
prev_dir = real_current_dir_name; //no utf8, maybe latin?
|
||||
}
|
||||
|
||||
// try_dir is the directory we are trying to change into
|
||||
String try_dir = "";
|
||||
|
@ -330,22 +338,25 @@ String DirAccessUnix::get_current_dir() {
|
|||
String base = _get_root_path();
|
||||
if (base != "") {
|
||||
String bd = current_dir.replace_first(base, "");
|
||||
if (bd.begins_with("/"))
|
||||
if (bd.begins_with("/")) {
|
||||
return _get_root_string() + bd.substr(1, bd.length());
|
||||
else
|
||||
} else {
|
||||
return _get_root_string() + bd;
|
||||
}
|
||||
}
|
||||
return current_dir;
|
||||
}
|
||||
|
||||
Error DirAccessUnix::rename(String p_path, String p_new_path) {
|
||||
if (p_path.is_rel_path())
|
||||
if (p_path.is_rel_path()) {
|
||||
p_path = get_current_dir().plus_file(p_path);
|
||||
}
|
||||
|
||||
p_path = fix_path(p_path);
|
||||
|
||||
if (p_new_path.is_rel_path())
|
||||
if (p_new_path.is_rel_path()) {
|
||||
p_new_path = get_current_dir().plus_file(p_new_path);
|
||||
}
|
||||
|
||||
p_new_path = fix_path(p_new_path);
|
||||
|
||||
|
@ -353,19 +364,22 @@ Error DirAccessUnix::rename(String p_path, String p_new_path) {
|
|||
}
|
||||
|
||||
Error DirAccessUnix::remove(String p_path) {
|
||||
if (p_path.is_rel_path())
|
||||
if (p_path.is_rel_path()) {
|
||||
p_path = get_current_dir().plus_file(p_path);
|
||||
}
|
||||
|
||||
p_path = fix_path(p_path);
|
||||
|
||||
struct stat flags;
|
||||
if ((stat(p_path.utf8().get_data(), &flags) != 0))
|
||||
if ((stat(p_path.utf8().get_data(), &flags) != 0)) {
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
if (S_ISDIR(flags.st_mode))
|
||||
if (S_ISDIR(flags.st_mode)) {
|
||||
return ::rmdir(p_path.utf8().get_data()) == 0 ? OK : FAILED;
|
||||
else
|
||||
} else {
|
||||
return ::unlink(p_path.utf8().get_data()) == 0 ? OK : FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
size_t DirAccessUnix::get_space_left() {
|
||||
|
@ -399,8 +413,9 @@ DirAccessUnix::DirAccessUnix() {
|
|||
// set current directory to an absolute path of the current directory
|
||||
char real_current_dir_name[2048];
|
||||
ERR_FAIL_COND(getcwd(real_current_dir_name, 2048) == nullptr);
|
||||
if (current_dir.parse_utf8(real_current_dir_name))
|
||||
if (current_dir.parse_utf8(real_current_dir_name)) {
|
||||
current_dir = real_current_dir_name;
|
||||
}
|
||||
|
||||
change_dir(current_dir);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue