diff options
Diffstat (limited to 'drivers/windows')
| -rw-r--r-- | drivers/windows/dir_access_windows.cpp | 247 | ||||
| -rw-r--r-- | drivers/windows/dir_access_windows.h | 4 | ||||
| -rw-r--r-- | drivers/windows/file_access_windows.cpp | 2 | ||||
| -rw-r--r-- | drivers/windows/file_access_windows.h | 2 | ||||
| -rw-r--r-- | drivers/windows/mutex_windows.cpp | 2 | ||||
| -rw-r--r-- | drivers/windows/mutex_windows.h | 2 | ||||
| -rw-r--r-- | drivers/windows/semaphore_windows.cpp | 2 | ||||
| -rw-r--r-- | drivers/windows/semaphore_windows.h | 2 | ||||
| -rw-r--r-- | drivers/windows/shell_windows.cpp | 2 | ||||
| -rw-r--r-- | drivers/windows/shell_windows.h | 2 | ||||
| -rw-r--r-- | drivers/windows/thread_windows.cpp | 2 | ||||
| -rw-r--r-- | drivers/windows/thread_windows.h | 2 |
12 files changed, 89 insertions, 182 deletions
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 4c265a1ab..7c81e8e05 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -70,21 +70,11 @@ bool DirAccessWindows::list_dir_begin() { _cisdir=false; _cishidden=false; - if (unicode) { - list_dir_end(); - p->h = FindFirstFileExW((current_dir+"\\*").c_str(), FindExInfoStandard, &p->fu, FindExSearchNameMatch, NULL, 0); + list_dir_end(); + p->h = FindFirstFileExW((current_dir+"\\*").c_str(), FindExInfoStandard, &p->fu, FindExSearchNameMatch, NULL, 0); - return (p->h==INVALID_HANDLE_VALUE); - } else { - - list_dir_end(); - p->h = FindFirstFileExA((current_dir+"\\*").ascii().get_data(), FindExInfoStandard, &p->fu, FindExSearchNameMatch, NULL, 0); - - return (p->h==INVALID_HANDLE_VALUE); - - } + return (p->h==INVALID_HANDLE_VALUE); - return false; } @@ -93,38 +83,20 @@ String DirAccessWindows::get_next() { if (p->h==INVALID_HANDLE_VALUE) return ""; - if (unicode) { - _cisdir=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); - _cishidden=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN); + _cisdir=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); + _cishidden=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN); - String name=p->fu.cFileName; - - if (FindNextFileW(p->h, &p->fu) == 0) { - - FindClose(p->h); - p->h=INVALID_HANDLE_VALUE; - } - - return name; - } else { + String name=p->fu.cFileName; -#ifndef WINRT_ENABLED - _cisdir=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); - _cishidden=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN); + if (FindNextFileW(p->h, &p->fu) == 0) { - String name=p->f.cFileName; - - if (FindNextFileA(p->h, &p->f) == 0) { + FindClose(p->h); + p->h=INVALID_HANDLE_VALUE; + } - FindClose(p->h); - p->h=INVALID_HANDLE_VALUE; - } + return name; - return name; -#endif - return ""; - } } bool DirAccessWindows::current_is_dir() const { @@ -174,63 +146,38 @@ Error DirAccessWindows::change_dir(String p_dir) { p_dir=fix_path(p_dir); - if (unicode) { - wchar_t real_current_dir_name[2048]; - GetCurrentDirectoryW(2048,real_current_dir_name); - String prev_dir=real_current_dir_name; + wchar_t real_current_dir_name[2048]; + GetCurrentDirectoryW(2048,real_current_dir_name); + String prev_dir=real_current_dir_name; - SetCurrentDirectoryW(current_dir.c_str()); - bool worked=(SetCurrentDirectoryW(p_dir.c_str())!=0); + SetCurrentDirectoryW(current_dir.c_str()); + bool worked=(SetCurrentDirectoryW(p_dir.c_str())!=0); - String base = _get_root_path(); - if (base!="") { + String base = _get_root_path(); + if (base!="") { - GetCurrentDirectoryW(2048,real_current_dir_name); - String new_dir; - new_dir = String(real_current_dir_name).replace("\\","/"); - if (!new_dir.begins_with(base)) { - worked=false; - } + GetCurrentDirectoryW(2048,real_current_dir_name); + String new_dir; + new_dir = String(real_current_dir_name).replace("\\","/"); + if (!new_dir.begins_with(base)) { + worked=false; } + } - if (worked) { - - GetCurrentDirectoryW(2048,real_current_dir_name); - current_dir=real_current_dir_name; // TODO, utf8 parser - current_dir=current_dir.replace("\\","/"); - - } //else { - - SetCurrentDirectoryW(prev_dir.c_str()); - //} - - return worked?OK:ERR_INVALID_PARAMETER; - } else { - - char real_current_dir_name[2048]; - GetCurrentDirectoryA(2048,real_current_dir_name); - String prev_dir=real_current_dir_name; - - SetCurrentDirectoryA(current_dir.ascii().get_data()); - bool worked=(SetCurrentDirectory(p_dir.ascii().get_data())!=0); - - if (worked) { - - GetCurrentDirectoryA(2048,real_current_dir_name); - current_dir=real_current_dir_name; // TODO, utf8 parser - current_dir=current_dir.replace("\\","/"); + if (worked) { - }// else { - SetCurrentDirectoryA(prev_dir.ascii().get_data()); - //} + GetCurrentDirectoryW(2048,real_current_dir_name); + current_dir=real_current_dir_name; // TODO, utf8 parser + current_dir=current_dir.replace("\\","/"); - return worked?OK:ERR_INVALID_PARAMETER; + } //else { - } + SetCurrentDirectoryW(prev_dir.c_str()); + //} - return OK; + return worked?OK:ERR_INVALID_PARAMETER; #endif } @@ -246,34 +193,20 @@ Error DirAccessWindows::make_dir(String p_dir) { p_dir=fix_path(p_dir); - p_dir.replace("/","\\"); + //p_dir.replace("/","\\"); bool success; int err; - if (unicode) { - wchar_t real_current_dir_name[2048]; - GetCurrentDirectoryW(2048,real_current_dir_name); - - SetCurrentDirectoryW(current_dir.c_str()); - - success=CreateDirectoryW(p_dir.c_str(), NULL); - err = GetLastError(); - - SetCurrentDirectoryW(real_current_dir_name); - - } else { + wchar_t real_current_dir_name[2048]; + GetCurrentDirectoryW(2048,real_current_dir_name); - char real_current_dir_name[2048]; - GetCurrentDirectoryA(2048,real_current_dir_name); + SetCurrentDirectoryW(current_dir.c_str()); - SetCurrentDirectoryA(current_dir.ascii().get_data()); + success=CreateDirectoryW(p_dir.c_str(), NULL); + err = GetLastError(); - success=CreateDirectoryA(p_dir.ascii().get_data(), NULL); - err = GetLastError(); - - SetCurrentDirectoryA(real_current_dir_name); - } + SetCurrentDirectoryW(real_current_dir_name); if (success) { return OK; @@ -313,81 +246,59 @@ bool DirAccessWindows::file_exists(String p_file) { GLOBAL_LOCK_FUNCTION if (!p_file.is_abs_path()) - p_file=get_current_dir()+"/"+p_file; + p_file=get_current_dir().plus_file(p_file); p_file=fix_path(p_file); - p_file.replace("/","\\"); - - WIN32_FILE_ATTRIBUTE_DATA fileInfo; - - if (unicode) { + //p_file.replace("/","\\"); - DWORD fileAttr; + //WIN32_FILE_ATTRIBUTE_DATA fileInfo; - fileAttr = GetFileAttributesExW(p_file.c_str(), GetFileExInfoStandard, &fileInfo); - if (0 == fileAttr) - return false; + DWORD fileAttr; - return !(fileAttr&FILE_ATTRIBUTE_DIRECTORY); - - } else { - DWORD fileAttr; + fileAttr = GetFileAttributesW(p_file.c_str()); + if (INVALID_FILE_ATTRIBUTES == fileAttr) + return false; - fileAttr = GetFileAttributesExA(p_file.ascii().get_data(), GetFileExInfoStandard, &fileInfo); - if (0 == fileAttr) - return false; + return !(fileAttr&FILE_ATTRIBUTE_DIRECTORY); - return !(fileAttr&FILE_ATTRIBUTE_DIRECTORY); - - } - - return false; } bool DirAccessWindows::dir_exists(String p_dir) { GLOBAL_LOCK_FUNCTION - if (!p_dir.is_abs_path()) - p_dir=get_current_dir()+"/"+p_dir; - - p_dir=fix_path(p_dir); - - p_dir.replace("/","\\"); - - WIN32_FILE_ATTRIBUTE_DATA fileInfo; - - if (unicode) { - - DWORD fileAttr; + if (p_dir.is_rel_path()) + p_dir=get_current_dir().plus_file(p_dir); + else + p_dir=fix_path(p_dir); - fileAttr = GetFileAttributesExW(p_dir.c_str(), GetFileExInfoStandard, &fileInfo); - if (0 == fileAttr) - return false; + //p_dir.replace("/","\\"); - return (fileAttr&FILE_ATTRIBUTE_DIRECTORY); + //WIN32_FILE_ATTRIBUTE_DATA fileInfo; - } else { -#ifndef WINRT_ENABLED - DWORD fileAttr; - fileAttr = GetFileAttributesExA(p_dir.ascii().get_data(), GetFileExInfoStandard, &fileInfo); - if (0 == fileAttr) - return false; + DWORD fileAttr; - return (fileAttr&FILE_ATTRIBUTE_DIRECTORY); + fileAttr = GetFileAttributesW(p_dir.c_str()); + if (INVALID_FILE_ATTRIBUTES == fileAttr) + return false; + return (fileAttr&FILE_ATTRIBUTE_DIRECTORY); -#endif - } - return false; } Error DirAccessWindows::rename(String p_path,String p_new_path) { - p_path=fix_path(p_path); - p_new_path=fix_path(p_new_path); - + if (p_path.is_rel_path()) + p_path=get_current_dir().plus_file(p_path); + else + p_path=fix_path(p_path); + + if (p_new_path.is_rel_path()) + p_new_path=get_current_dir().plus_file(p_new_path); + else + p_new_path=fix_path(p_new_path); + if (file_exists(p_new_path)) { if (remove(p_new_path) != OK) { return FAILED; @@ -402,12 +313,15 @@ Error DirAccessWindows::remove(String 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); - if (fileAttr == INVALID_FILE_ATTRIBUTES) - return FAILED; + //WIN32_FILE_ATTRIBUTE_DATA fileInfo; + //DWORD fileAttr = GetFileAttributesExW(p_path.c_str(), GetFileExInfoStandard, &fileInfo); - if (fileAttr & FILE_ATTRIBUTE_DIRECTORY) + DWORD fileAttr; + + fileAttr = GetFileAttributesW(p_path.c_str()); + if (INVALID_FILE_ATTRIBUTES == fileAttr) + return FAILED; + if ((fileAttr&FILE_ATTRIBUTE_DIRECTORY)) return ::_wrmdir(p_path.c_str())==0?OK:FAILED; else return ::_wunlink(p_path.c_str())==0?OK:FAILED; @@ -471,13 +385,6 @@ DirAccessWindows::DirAccessWindows() { } } - unicode=true; - - - /* We are running Windows 95/98/ME, so no unicode allowed */ - if ( SetCurrentDirectoryW ( L"." ) == FALSE && GetLastError () == ERROR_CALL_NOT_IMPLEMENTED ) - unicode=false; - change_dir("."); #endif } diff --git a/drivers/windows/dir_access_windows.h b/drivers/windows/dir_access_windows.h index 4a668a736..384bc8327 100644 --- a/drivers/windows/dir_access_windows.h +++ b/drivers/windows/dir_access_windows.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -56,7 +56,7 @@ class DirAccessWindows : public DirAccess { String current_dir; - bool unicode; + bool _cisdir; bool _cishidden; diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 19a62967e..90903f2cb 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h index 8f16d66fe..a2598bfee 100644 --- a/drivers/windows/file_access_windows.h +++ b/drivers/windows/file_access_windows.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/drivers/windows/mutex_windows.cpp b/drivers/windows/mutex_windows.cpp index 3b2004285..09f859051 100644 --- a/drivers/windows/mutex_windows.cpp +++ b/drivers/windows/mutex_windows.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/drivers/windows/mutex_windows.h b/drivers/windows/mutex_windows.h index 9a3875f05..9447f17a1 100644 --- a/drivers/windows/mutex_windows.h +++ b/drivers/windows/mutex_windows.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/drivers/windows/semaphore_windows.cpp b/drivers/windows/semaphore_windows.cpp index bfd53f983..50cdf7cce 100644 --- a/drivers/windows/semaphore_windows.cpp +++ b/drivers/windows/semaphore_windows.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/drivers/windows/semaphore_windows.h b/drivers/windows/semaphore_windows.h index f87b868a6..43f6c0b56 100644 --- a/drivers/windows/semaphore_windows.h +++ b/drivers/windows/semaphore_windows.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/drivers/windows/shell_windows.cpp b/drivers/windows/shell_windows.cpp index 3994252c4..670f4e483 100644 --- a/drivers/windows/shell_windows.cpp +++ b/drivers/windows/shell_windows.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/drivers/windows/shell_windows.h b/drivers/windows/shell_windows.h index 8bbf51514..98eae8117 100644 --- a/drivers/windows/shell_windows.h +++ b/drivers/windows/shell_windows.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/drivers/windows/thread_windows.cpp b/drivers/windows/thread_windows.cpp index 40efa5acd..6a9e97ba0 100644 --- a/drivers/windows/thread_windows.cpp +++ b/drivers/windows/thread_windows.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/drivers/windows/thread_windows.h b/drivers/windows/thread_windows.h index d15e77d06..3c8f92ce5 100644 --- a/drivers/windows/thread_windows.h +++ b/drivers/windows/thread_windows.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ |
