Safer getcwd in DirAccess
Fix [-Wunused-result]
This commit is contained in:
parent
5393e7310d
commit
12124d2d44
1 changed files with 3 additions and 3 deletions
|
@ -309,7 +309,7 @@ Error DirAccessUnix::change_dir(String p_dir) {
|
|||
// prev_dir is the directory we are changing out of
|
||||
String prev_dir;
|
||||
char real_current_dir_name[2048];
|
||||
getcwd(real_current_dir_name, 2048);
|
||||
ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == NULL, ERR_BUG);
|
||||
if (prev_dir.parse_utf8(real_current_dir_name))
|
||||
prev_dir = real_current_dir_name; //no utf8, maybe latin?
|
||||
|
||||
|
@ -330,7 +330,7 @@ Error DirAccessUnix::change_dir(String p_dir) {
|
|||
|
||||
// the directory exists, so set current_dir to try_dir
|
||||
current_dir = try_dir;
|
||||
chdir(prev_dir.utf8().get_data());
|
||||
ERR_FAIL_COND_V(chdir(prev_dir.utf8().get_data()) != 0, ERR_BUG);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -405,7 +405,7 @@ DirAccessUnix::DirAccessUnix() {
|
|||
|
||||
// set current directory to an absolute path of the current directory
|
||||
char real_current_dir_name[2048];
|
||||
getcwd(real_current_dir_name, 2048);
|
||||
ERR_FAIL_COND(getcwd(real_current_dir_name, 2048) == NULL);
|
||||
if (current_dir.parse_utf8(real_current_dir_name))
|
||||
current_dir = real_current_dir_name;
|
||||
|
||||
|
|
Loading…
Reference in a new issue