diff options
Diffstat (limited to 'drivers/windows/dir_access_windows.cpp')
-rw-r--r-- | drivers/windows/dir_access_windows.cpp | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index a8618b05d7..b8153907a9 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -53,7 +53,6 @@ */ struct DirAccessWindowsPrivate { - HANDLE h; //handle for findfirstfile WIN32_FIND_DATA f; WIN32_FIND_DATAW fu; //unicode version @@ -62,18 +61,20 @@ struct DirAccessWindowsPrivate { // CreateFolderAsync Error DirAccessWindows::list_dir_begin() { - _cisdir = false; _cishidden = false; list_dir_end(); p->h = FindFirstFileExW((current_dir + "\\*").c_str(), FindExInfoStandard, &p->fu, FindExSearchNameMatch, nullptr, 0); - return (p->h == INVALID_HANDLE_VALUE) ? ERR_CANT_OPEN : OK; + if (p->h == INVALID_HANDLE_VALUE) { + return ERR_CANT_OPEN; + } + + return OK; } String DirAccessWindows::get_next() { - if (p->h == INVALID_HANDLE_VALUE) return ""; @@ -83,7 +84,6 @@ String DirAccessWindows::get_next() { String name = p->fu.cFileName; if (FindNextFileW(p->h, &p->fu) == 0) { - FindClose(p->h); p->h = INVALID_HANDLE_VALUE; } @@ -92,29 +92,25 @@ String DirAccessWindows::get_next() { } bool DirAccessWindows::current_is_dir() const { - return _cisdir; } bool DirAccessWindows::current_is_hidden() const { - return _cishidden; } void DirAccessWindows::list_dir_end() { - if (p->h != INVALID_HANDLE_VALUE) { - FindClose(p->h); p->h = INVALID_HANDLE_VALUE; } } -int DirAccessWindows::get_drive_count() { +int DirAccessWindows::get_drive_count() { return drive_count; } -String DirAccessWindows::get_drive(int p_drive) { +String DirAccessWindows::get_drive(int p_drive) { if (p_drive < 0 || p_drive >= drive_count) return ""; @@ -122,7 +118,6 @@ String DirAccessWindows::get_drive(int p_drive) { } Error DirAccessWindows::change_dir(String p_dir) { - GLOBAL_LOCK_FUNCTION p_dir = fix_path(p_dir); @@ -136,7 +131,6 @@ Error DirAccessWindows::change_dir(String p_dir) { String base = _get_root_path(); if (base != "") { - GetCurrentDirectoryW(2048, real_current_dir_name); String new_dir; new_dir = String(real_current_dir_name).replace("\\", "/"); @@ -146,7 +140,6 @@ Error DirAccessWindows::change_dir(String p_dir) { } if (worked) { - GetCurrentDirectoryW(2048, real_current_dir_name); current_dir = real_current_dir_name; // TODO, utf8 parser current_dir = current_dir.replace("\\", "/"); @@ -160,7 +153,6 @@ Error DirAccessWindows::change_dir(String p_dir) { } Error DirAccessWindows::make_dir(String p_dir) { - GLOBAL_LOCK_FUNCTION p_dir = fix_path(p_dir); @@ -190,10 +182,8 @@ Error DirAccessWindows::make_dir(String p_dir) { } String DirAccessWindows::get_current_dir(bool p_include_drive) { - String base = _get_root_path(); if (base != "") { - String bd = current_dir.replace("\\", "/").replace_first(base, ""); if (bd.begins_with("/")) return _get_root_string() + bd.substr(1, bd.length()); @@ -217,7 +207,6 @@ String DirAccessWindows::get_current_dir(bool p_include_drive) { } bool DirAccessWindows::file_exists(String p_file) { - GLOBAL_LOCK_FUNCTION if (!p_file.is_abs_path()) @@ -239,7 +228,6 @@ bool DirAccessWindows::file_exists(String p_file) { } bool DirAccessWindows::dir_exists(String p_dir) { - GLOBAL_LOCK_FUNCTION if (p_dir.is_rel_path()) @@ -260,7 +248,6 @@ bool DirAccessWindows::dir_exists(String p_dir) { } Error DirAccessWindows::rename(String p_path, String p_new_path) { - if (p_path.is_rel_path()) p_path = get_current_dir().plus_file(p_path); @@ -298,16 +285,11 @@ Error DirAccessWindows::rename(String p_path, String p_new_path) { } Error DirAccessWindows::remove(String p_path) { - if (p_path.is_rel_path()) p_path = get_current_dir().plus_file(p_path); p_path = fix_path(p_path); - printf("erasing %s\n", p_path.utf8().get_data()); - //WIN32_FILE_ATTRIBUTE_DATA fileInfo; - //DWORD fileAttr = GetFileAttributesExW(p_path.c_str(), GetFileExInfoStandard, &fileInfo); - DWORD fileAttr; fileAttr = GetFileAttributesW(p_path.c_str()); @@ -318,6 +300,7 @@ Error DirAccessWindows::remove(String p_path) { else return ::_wunlink(p_path.c_str()) == 0 ? OK : FAILED; } + /* FileType DirAccessWindows::get_file_type(const String& p_file) const { @@ -345,9 +328,9 @@ FileType DirAccessWindows::get_file_type(const String& p_file) const { return (attr&FILE_ATTRIBUTE_DIRECTORY)?FILE_TYPE_ } + */ size_t DirAccessWindows::get_space_left() { - uint64_t bytes = 0; if (!GetDiskFreeSpaceEx(nullptr, (PULARGE_INTEGER)&bytes, nullptr, nullptr)) return 0; @@ -377,7 +360,6 @@ String DirAccessWindows::get_filesystem_type() const { &dwFileSystemFlags, szFileSystemName, sizeof(szFileSystemName)) == TRUE) { - return String(szFileSystemName); } @@ -385,7 +367,6 @@ String DirAccessWindows::get_filesystem_type() const { } DirAccessWindows::DirAccessWindows() { - p = memnew(DirAccessWindowsPrivate); p->h = INVALID_HANDLE_VALUE; current_dir = "."; @@ -401,7 +382,6 @@ DirAccessWindows::DirAccessWindows() { DWORD mask = GetLogicalDrives(); for (int i = 0; i < MAX_DRIVES; i++) { - if (mask & (1 << i)) { //DRIVE EXISTS drives[drive_count] = 'A' + i; @@ -414,7 +394,6 @@ DirAccessWindows::DirAccessWindows() { } DirAccessWindows::~DirAccessWindows() { - memdelete(p); } |