summaryrefslogtreecommitdiff
path: root/core/os
diff options
context:
space:
mode:
Diffstat (limited to 'core/os')
-rw-r--r--core/os/dir_access.cpp21
-rw-r--r--core/os/file_access.cpp10
-rw-r--r--core/os/main_loop.cpp2
-rw-r--r--core/os/os.cpp2
4 files changed, 17 insertions, 18 deletions
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index b444f0ae1e..e7496055ec 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -244,7 +244,7 @@ DirAccess *DirAccess::open(const String &p_path, Error *r_error) {
DirAccess *da = create_for_path(p_path);
- ERR_FAIL_COND_V(!da, NULL);
+ ERR_FAIL_COND_V_MSG(!da, NULL, "Cannot create DirAccess for path '" + p_path + "'.");
Error err = da->change_dir(p_path);
if (r_error)
*r_error = err;
@@ -384,39 +384,36 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag
String target_dir = p_to + rel_path;
if (!p_target_da->dir_exists(target_dir)) {
Error err = p_target_da->make_dir(target_dir);
- ERR_FAIL_COND_V(err, err);
+ ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + target_dir + "'.");
}
Error err = change_dir(E->get());
- ERR_FAIL_COND_V(err, err);
+ ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot change current directory to '" + E->get() + "'.");
+
err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags);
if (err) {
change_dir("..");
- ERR_PRINT("Failed to copy recursively");
- return err;
+ ERR_FAIL_V_MSG(err, "Failed to copy recursively.");
}
err = change_dir("..");
- if (err) {
- ERR_PRINT("Failed to go back");
- return err;
- }
+ ERR_FAIL_COND_V_MSG(err != OK, err, "Failed to go back.");
}
return OK;
}
Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags) {
- ERR_FAIL_COND_V(!dir_exists(p_from), ERR_FILE_NOT_FOUND);
+ ERR_FAIL_COND_V_MSG(!dir_exists(p_from), ERR_FILE_NOT_FOUND, "Source directory doesn't exist.");
DirAccess *target_da = DirAccess::create_for_path(p_to);
- ERR_FAIL_COND_V(!target_da, ERR_CANT_CREATE);
+ ERR_FAIL_COND_V_MSG(!target_da, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_to + "'.");
if (!target_da->dir_exists(p_to)) {
Error err = target_da->make_dir_recursive(p_to);
if (err) {
memdelete(target_da);
}
- ERR_FAIL_COND_V(err, err);
+ ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + p_to + "'.");
}
if (!p_to.ends_with("/")) {
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 9a8315a3bb..738e597730 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -498,7 +498,7 @@ uint64_t FileAccess::get_modified_time(const String &p_file) {
return 0;
FileAccess *fa = create_for_path(p_file);
- ERR_FAIL_COND_V(!fa, 0);
+ ERR_FAIL_COND_V_MSG(!fa, 0, "Cannot create FileAccess for path '" + p_file + "'.");
uint64_t mt = fa->_get_modified_time(p_file);
memdelete(fa);
@@ -511,7 +511,7 @@ uint32_t FileAccess::get_unix_permissions(const String &p_file) {
return 0;
FileAccess *fa = create_for_path(p_file);
- ERR_FAIL_COND_V(!fa, 0);
+ ERR_FAIL_COND_V_MSG(!fa, 0, "Cannot create FileAccess for path '" + p_file + "'.");
uint32_t mt = fa->_get_unix_permissions(p_file);
memdelete(fa);
@@ -521,7 +521,7 @@ uint32_t FileAccess::get_unix_permissions(const String &p_file) {
Error FileAccess::set_unix_permissions(const String &p_file, uint32_t p_permissions) {
FileAccess *fa = create_for_path(p_file);
- ERR_FAIL_COND_V(!fa, ERR_CANT_CREATE);
+ ERR_FAIL_COND_V_MSG(!fa, ERR_CANT_CREATE, "Cannot create FileAccess for path '" + p_file + "'.");
Error err = fa->_set_unix_permissions(p_file, p_permissions);
memdelete(fa);
@@ -599,7 +599,7 @@ Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path, Error *r_err
if (r_error) { // if error requested, do not throw error
return Vector<uint8_t>();
}
- ERR_FAIL_V_MSG(Vector<uint8_t>(), "Can't open file from path: " + String(p_path) + ".");
+ ERR_FAIL_V_MSG(Vector<uint8_t>(), "Can't open file from path '" + String(p_path) + "'.");
}
Vector<uint8_t> data;
data.resize(f->get_len());
@@ -619,7 +619,7 @@ String FileAccess::get_file_as_string(const String &p_path, Error *r_error) {
if (r_error) {
return String();
}
- ERR_FAIL_V_MSG(String(), "Can't get file as string from path: " + String(p_path) + ".");
+ ERR_FAIL_V_MSG(String(), "Can't get file as string from path '" + String(p_path) + "'.");
}
String ret;
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index eca3b2a7f4..5587e827ba 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -63,6 +63,8 @@ void MainLoop::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_WM_ABOUT);
BIND_CONSTANT(NOTIFICATION_CRASH);
BIND_CONSTANT(NOTIFICATION_OS_IME_UPDATE);
+ BIND_CONSTANT(NOTIFICATION_APP_RESUMED);
+ BIND_CONSTANT(NOTIFICATION_APP_PAUSED);
};
void MainLoop::set_init_script(const Ref<Script> &p_init_script) {
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 7531900480..b44487b908 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -722,7 +722,7 @@ int OS::get_audio_driver_count() const {
const char *OS::get_audio_driver_name(int p_driver) const {
AudioDriver *driver = AudioDriverManager::get_driver(p_driver);
- ERR_FAIL_COND_V(!driver, "");
+ ERR_FAIL_COND_V_MSG(!driver, "", "Cannot get audio driver at index '" + itos(p_driver) + "'.");
return AudioDriverManager::get_driver(p_driver)->get_name();
}