summaryrefslogtreecommitdiff
path: root/drivers/windows/dir_access_windows.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/windows/dir_access_windows.cpp')
-rw-r--r--drivers/windows/dir_access_windows.cpp63
1 files changed, 52 insertions, 11 deletions
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp
index aacd02ca24..e07c9bb354 100644
--- a/drivers/windows/dir_access_windows.cpp
+++ b/drivers/windows/dir_access_windows.cpp
@@ -26,7 +26,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifdef WINDOWS_ENABLED
+#if defined(WINDOWS_ENABLED)
#include "dir_access_windows.h"
@@ -36,6 +36,13 @@
#include <wchar.h>
#include <stdio.h>
#include "print_string.h"
+
+#ifdef WINRT_ENABLED
+#include <Synchapi.h>
+#include <collection.h>
+#include <ppltasks.h>
+#endif
+
/*
[03:57] <reduz> yessopie, so i dont havemak to rely on unicows
@@ -56,6 +63,7 @@ struct DirAccessWindowsPrivate {
WIN32_FIND_DATAW fu; //unicode version
};
+// CreateFolderAsync
bool DirAccessWindows::list_dir_begin() {
@@ -63,13 +71,13 @@ bool DirAccessWindows::list_dir_begin() {
if (unicode) {
list_dir_end();
- p->h = FindFirstFileW((current_dir+"\\*").c_str(), &p->fu);
+ 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 = FindFirstFileA((current_dir+"\\*").ascii().get_data(), &p->f);
+ p->h = FindFirstFileExA((current_dir+"\\*").ascii().get_data(), FindExInfoStandard, &p->fu, FindExSearchNameMatch, NULL, 0);
return (p->h==INVALID_HANDLE_VALUE);
@@ -144,6 +152,15 @@ Error DirAccessWindows::change_dir(String p_dir) {
GLOBAL_LOCK_FUNCTION
+#ifdef WINRT_ENABLED
+
+ p_dir = fix_path(p_dir);
+ current_dir = normalize_path(p_dir);
+
+ return OK;
+#else
+
+
p_dir=fix_path(p_dir);
if (unicode) {
@@ -201,13 +218,19 @@ Error DirAccessWindows::change_dir(String p_dir) {
}
return OK;
-
+#endif
}
Error DirAccessWindows::make_dir(String p_dir) {
GLOBAL_LOCK_FUNCTION
+#ifdef WINRT_ENABLED
+
+ return ERR_CANT_CREATE;
+
+#else
+
p_dir=fix_path(p_dir);
p_dir.replace("/","\\");
@@ -248,6 +271,8 @@ Error DirAccessWindows::make_dir(String p_dir) {
};
return ERR_CANT_CREATE;
+
+#endif
}
@@ -280,11 +305,13 @@ bool DirAccessWindows::file_exists(String p_file) {
p_file.replace("/","\\");
+ WIN32_FILE_ATTRIBUTE_DATA fileInfo;
+
if (unicode) {
DWORD fileAttr;
- fileAttr = GetFileAttributesW(p_file.c_str());
+ fileAttr = GetFileAttributesExW(p_file.c_str(), GetFileExInfoStandard, &fileInfo);
if (0xFFFFFFFF == fileAttr)
return false;
@@ -293,7 +320,7 @@ bool DirAccessWindows::file_exists(String p_file) {
} else {
DWORD fileAttr;
- fileAttr = GetFileAttributesA(p_file.ascii().get_data());
+ fileAttr = GetFileAttributesExA(p_file.ascii().get_data(), GetFileExInfoStandard, &fileInfo);
if (0xFFFFFFFF == fileAttr)
return false;
return !(fileAttr&FILE_ATTRIBUTE_DIRECTORY);
@@ -313,11 +340,13 @@ bool DirAccessWindows::dir_exists(String p_dir) {
p_dir.replace("/","\\");
+ WIN32_FILE_ATTRIBUTE_DATA fileInfo;
+
if (unicode) {
DWORD fileAttr;
- fileAttr = GetFileAttributesW(p_dir.c_str());
+ fileAttr = GetFileAttributesExW(p_dir.c_str(), GetFileExInfoStandard, &fileInfo);
if (0xFFFFFFFF == fileAttr)
return false;
@@ -326,7 +355,7 @@ bool DirAccessWindows::dir_exists(String p_dir) {
} else {
DWORD fileAttr;
- fileAttr = GetFileAttributesA(p_dir.ascii().get_data());
+ fileAttr = GetFileAttributesExA(p_dir.ascii().get_data(), GetFileExInfoStandard, &fileInfo);
if (0xFFFFFFFF == fileAttr)
return false;
return (fileAttr&FILE_ATTRIBUTE_DIRECTORY);
@@ -355,7 +384,8 @@ Error DirAccessWindows::remove(String p_path) {
p_path=fix_path(p_path);
printf("erasing %s\n",p_path.utf8().get_data());
- DWORD fileAttr = GetFileAttributesW(p_path.c_str());
+ WIN32_FILE_ATTRIBUTE_DATA fileInfo;
+ DWORD fileAttr = GetFileAttributesExW(p_path.c_str(), GetFileExInfoStandard, &fileInfo);
if (fileAttr == INVALID_FILE_ATTRIBUTES)
return FAILED;
@@ -378,7 +408,8 @@ FileType DirAccessWindows::get_file_type(const String& p_file) const {
DWORD attr;
if (worked) {
- attr = GetFileAttributesW(p_file.c_str());
+ WIN32_FILE_ATTRIBUTE_DATA fileInfo;
+ attr = GetFileAttributesExW(p_file.c_str(), GetFileExInfoStandard, &fileInfo);
}
@@ -399,9 +430,18 @@ size_t DirAccessWindows::get_space_left() {
DirAccessWindows::DirAccessWindows() {
p = memnew( DirAccessWindowsPrivate );
+ p->h=INVALID_HANDLE_VALUE;
current_dir=".";
drive_count=0;
+
+#ifdef WINRT_ENABLED
+ Windows::Storage::StorageFolder ^install_folder = Windows::ApplicationModel::Package::Current->InstalledLocation;
+ change_dir(install_folder->Path->Data());
+
+#else
+
+
DWORD mask=GetLogicalDrives();
for (int i=0;i<MAX_DRIVES;i++) {
@@ -415,12 +455,13 @@ 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;
- p->h=INVALID_HANDLE_VALUE;
change_dir(".");
+#endif
}