diff options
author | marynate <mary.w.nate@gmail.com> | 2014-07-06 20:28:30 +0800 |
---|---|---|
committer | marynate <mary.w.nate@gmail.com> | 2014-07-06 20:32:29 +0800 |
commit | 034aec2539f50f3943581c30fdf3eff3e66f7532 (patch) | |
tree | 93a539cb8c89e862a35d0c42bfffe832e90468de | |
parent | cd80d442a212a119b4bfce95dce78a08cbc49490 (diff) |
Fixed DirAccessWindows::change_dir not working properly; Minor code formating clean up
-rw-r--r-- | drivers/windows/dir_access_windows.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index aacd02ca24..49aca55301 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -172,9 +172,10 @@ Error DirAccessWindows::change_dir(String p_dir) { current_dir=real_current_dir_name; // TODO, utf8 parser current_dir=current_dir.replace("\\","/"); - } + } else { - SetCurrentDirectoryW(prev_dir.c_str()); + SetCurrentDirectoryW(prev_dir.c_str()); + } return worked?OK:ERR_INVALID_PARAMETER; } else { @@ -192,9 +193,10 @@ Error DirAccessWindows::change_dir(String p_dir) { current_dir=real_current_dir_name; // TODO, utf8 parser current_dir=current_dir.replace("\\","/"); - } + } else { - SetCurrentDirectoryA(prev_dir.ascii().get_data()); + SetCurrentDirectoryA(prev_dir.ascii().get_data()); + } return worked?OK:ERR_INVALID_PARAMETER; @@ -274,29 +276,31 @@ bool DirAccessWindows::file_exists(String p_file) { GLOBAL_LOCK_FUNCTION - if (!p_file.is_abs_path()) - p_file=get_current_dir()+"/"+p_file; + if (!p_file.is_abs_path()) + p_file=get_current_dir()+"/"+p_file; + p_file=fix_path(p_file); p_file.replace("/","\\"); if (unicode) { - DWORD fileAttr; + DWORD fileAttr; fileAttr = GetFileAttributesW(p_file.c_str()); if (0xFFFFFFFF == fileAttr) return false; - return !(fileAttr&FILE_ATTRIBUTE_DIRECTORY); + return !(fileAttr&FILE_ATTRIBUTE_DIRECTORY); } else { - DWORD fileAttr; + DWORD fileAttr; fileAttr = GetFileAttributesA(p_file.ascii().get_data()); if (0xFFFFFFFF == fileAttr) return false; - return !(fileAttr&FILE_ATTRIBUTE_DIRECTORY); + + return !(fileAttr&FILE_ATTRIBUTE_DIRECTORY); } @@ -307,15 +311,16 @@ bool DirAccessWindows::dir_exists(String p_dir) { GLOBAL_LOCK_FUNCTION - if (!p_dir.is_abs_path()) - p_dir=get_current_dir()+"/"+p_dir; + if (!p_dir.is_abs_path()) + p_dir=get_current_dir()+"/"+p_dir; + p_dir=fix_path(p_dir); p_dir.replace("/","\\"); if (unicode) { - DWORD fileAttr; + DWORD fileAttr; fileAttr = GetFileAttributesW(p_dir.c_str()); if (0xFFFFFFFF == fileAttr) @@ -324,11 +329,12 @@ bool DirAccessWindows::dir_exists(String p_dir) { return (fileAttr&FILE_ATTRIBUTE_DIRECTORY); } else { - DWORD fileAttr; + DWORD fileAttr; fileAttr = GetFileAttributesA(p_dir.ascii().get_data()); if (0xFFFFFFFF == fileAttr) return false; + return (fileAttr&FILE_ATTRIBUTE_DIRECTORY); } |