diff options
Diffstat (limited to 'drivers/unix')
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 20 | ||||
-rw-r--r-- | drivers/unix/socket_helpers.h | 1 |
2 files changed, 6 insertions, 15 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index b85a63a44a..6b8038c3ef 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -221,37 +221,24 @@ Error DirAccessUnix::change_dir(String p_dir) { if (prev_dir.parse_utf8(real_current_dir_name)) prev_dir = real_current_dir_name; //no utf8, maybe latin? - //print_line("directory we are changing out of (prev_dir): " + prev_dir); - // try_dir is the directory we are trying to change into String try_dir = ""; if (p_dir.is_rel_path()) { String next_dir = current_dir + "/" + p_dir; - //print_line("p_dir is relative: " + p_dir + " about to simplfy: " + next_dir); next_dir = next_dir.simplify_path(); try_dir = next_dir; } else { try_dir = p_dir; - //print_line("p_dir is absolute: " + p_dir); - } - - // if try_dir is nothing, it is not changing directory so change it to a "." otherwise chdir will fail - if (try_dir == "") { - try_dir = "."; } - //print_line("directory we are changing in to (try_dir): " + try_dir); - bool worked = (chdir(try_dir.utf8().get_data()) == 0); // we can only give this utf8 if (!worked) { - //print_line("directory does not exist"); return ERR_INVALID_PARAMETER; } // the directory exists, so set current_dir to try_dir current_dir = try_dir; chdir(prev_dir.utf8().get_data()); - //print_line("directory exists, setting current_dir to: " + current_dir); return OK; } @@ -319,11 +306,16 @@ size_t DirAccessUnix::get_space_left() { DirAccessUnix::DirAccessUnix() { dir_stream = 0; - current_dir = "."; _cisdir = false; /* determine drive count */ + // set current directory to an absolute path of the current directory + char real_current_dir_name[2048]; + getcwd(real_current_dir_name, 2048); + if (current_dir.parse_utf8(real_current_dir_name)) + current_dir = real_current_dir_name; + change_dir(current_dir); } diff --git a/drivers/unix/socket_helpers.h b/drivers/unix/socket_helpers.h index 3fc0144294..0995e5236f 100644 --- a/drivers/unix/socket_helpers.h +++ b/drivers/unix/socket_helpers.h @@ -64,7 +64,6 @@ static size_t _set_sockaddr(struct sockaddr_storage *p_addr, const IP_Address &p // IPv4 socket with IPv6 address ERR_FAIL_COND_V(!p_ip.is_ipv4(), 0); - uint32_t ipv4 = *((uint32_t *)p_ip.get_ipv4()); struct sockaddr_in *addr4 = (struct sockaddr_in *)p_addr; addr4->sin_family = AF_INET; addr4->sin_port = htons(p_port); // short, network byte order |