diff options
Diffstat (limited to 'drivers/windows/dir_access_windows.cpp')
-rw-r--r-- | drivers/windows/dir_access_windows.cpp | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 881575d245..c085ba372b 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -157,10 +157,10 @@ Error DirAccessWindows::make_dir(String p_dir) { p_dir = fix_path(p_dir); if (p_dir.is_relative_path()) { - p_dir = current_dir.plus_file(p_dir); + p_dir = current_dir.path_join(p_dir); } - p_dir = p_dir.replace("/", "\\"); + p_dir = p_dir.simplify_path().replace("/", "\\"); bool success; int err; @@ -200,9 +200,9 @@ String DirAccessWindows::get_current_dir(bool p_include_drive) const { return current_dir; } else { if (_get_root_string().is_empty()) { - int p = current_dir.find(":"); - if (p != -1) { - return current_dir.substr(p + 1); + int pos = current_dir.find(":"); + if (pos != -1) { + return current_dir.substr(pos + 1); } } return current_dir; @@ -213,7 +213,7 @@ bool DirAccessWindows::file_exists(String p_file) { GLOBAL_LOCK_FUNCTION if (!p_file.is_absolute_path()) { - p_file = get_current_dir().plus_file(p_file); + p_file = get_current_dir().path_join(p_file); } p_file = fix_path(p_file); @@ -232,7 +232,7 @@ bool DirAccessWindows::dir_exists(String p_dir) { GLOBAL_LOCK_FUNCTION if (p_dir.is_relative_path()) { - p_dir = get_current_dir().plus_file(p_dir); + p_dir = get_current_dir().path_join(p_dir); } p_dir = fix_path(p_dir); @@ -247,13 +247,13 @@ bool DirAccessWindows::dir_exists(String p_dir) { Error DirAccessWindows::rename(String p_path, String p_new_path) { if (p_path.is_relative_path()) { - p_path = get_current_dir().plus_file(p_path); + p_path = get_current_dir().path_join(p_path); } p_path = fix_path(p_path); if (p_new_path.is_relative_path()) { - p_new_path = get_current_dir().plus_file(p_new_path); + p_new_path = get_current_dir().path_join(p_new_path); } p_new_path = fix_path(p_new_path); @@ -291,7 +291,7 @@ Error DirAccessWindows::rename(String p_path, String p_new_path) { Error DirAccessWindows::remove(String p_path) { if (p_path.is_relative_path()) { - p_path = get_current_dir().plus_file(p_path); + p_path = get_current_dir().path_join(p_path); } p_path = fix_path(p_path); @@ -309,39 +309,13 @@ Error DirAccessWindows::remove(String p_path) { } } -/* - -FileType DirAccessWindows::get_file_type(const String& p_file) const { - WCHAR real_current_dir_name[2048]; - GetCurrentDirectoryW(2048, real_current_dir_name); - String prev_dir = Strong::utf16((const char16_t *)real_current_dir_name); - - bool worked = SetCurrentDirectoryW((LPCWSTR)(current_dir.utf16().get_data())); - - DWORD attr; - if (worked) { - WIN32_FILE_ATTRIBUTE_DATA fileInfo; - attr = GetFileAttributesExW((LPCWSTR)(p_file.utf16().get_data()), GetFileExInfoStandard, &fileInfo); - } - - SetCurrentDirectoryW((LPCWSTR)(prev_dir.utf16().get_data())); - - if (!worked) { - return FILE_TYPE_NONE; - } - - return (attr & FILE_ATTRIBUTE_DIRECTORY) ? FILE_TYPE_ -} - -*/ - uint64_t DirAccessWindows::get_space_left() { uint64_t bytes = 0; if (!GetDiskFreeSpaceEx(nullptr, (PULARGE_INTEGER)&bytes, nullptr, nullptr)) { return 0; } - //this is either 0 or a value in bytes. + // This is either 0 or a value in bytes. return bytes; } @@ -402,6 +376,8 @@ DirAccessWindows::DirAccessWindows() { } DirAccessWindows::~DirAccessWindows() { + list_dir_end(); + memdelete(p); } |