summaryrefslogtreecommitdiff
path: root/drivers/windows
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/windows')
-rw-r--r--drivers/windows/dir_access_windows.cpp46
-rw-r--r--drivers/windows/file_access_windows.cpp4
-rw-r--r--drivers/windows/thread_windows.cpp9
-rw-r--r--drivers/windows/thread_windows.h1
4 files changed, 38 insertions, 22 deletions
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp
index b9476b870b..90e43d2518 100644
--- a/drivers/windows/dir_access_windows.cpp
+++ b/drivers/windows/dir_access_windows.cpp
@@ -69,7 +69,7 @@ bool DirAccessWindows::list_dir_begin() {
_cisdir=false;
_cishidden=false;
-
+
list_dir_end();
p->h = FindFirstFileExW((current_dir+"\\*").c_str(), FindExInfoStandard, &p->fu, FindExSearchNameMatch, NULL, 0);
@@ -83,7 +83,7 @@ String DirAccessWindows::get_next() {
if (p->h==INVALID_HANDLE_VALUE)
return "";
-
+
_cisdir=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
_cishidden=(p->fu.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN);
@@ -191,23 +191,21 @@ Error DirAccessWindows::make_dir(String p_dir) {
#else
+ if (p_dir.is_rel_path())
+ p_dir=get_current_dir().plus_file(p_dir);
+
p_dir=fix_path(p_dir);
-
- //p_dir.replace("/","\\");
+ p_dir = p_dir.replace("/","\\");
bool success;
int err;
- wchar_t real_current_dir_name[2048];
- GetCurrentDirectoryW(2048,real_current_dir_name);
-
- SetCurrentDirectoryW(current_dir.c_str());
+ p_dir="\\\\?\\"+p_dir; //done according to
+// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363855(v=vs.85).aspx
success=CreateDirectoryW(p_dir.c_str(), NULL);
err = GetLastError();
- SetCurrentDirectoryW(real_current_dir_name);
-
if (success) {
return OK;
};
@@ -249,7 +247,7 @@ bool DirAccessWindows::file_exists(String 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;
@@ -270,8 +268,8 @@ bool DirAccessWindows::dir_exists(String p_dir) {
if (p_dir.is_rel_path())
p_dir=get_current_dir().plus_file(p_dir);
- else
- p_dir=fix_path(p_dir);
+
+ p_dir=fix_path(p_dir);
//p_dir.replace("/","\\");
@@ -291,13 +289,13 @@ 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);
- else
- p_path=fix_path(p_path);
+
+ 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);
+
+ p_new_path=fix_path(p_new_path);
if (file_exists(p_new_path)) {
if (remove(p_new_path) != OK) {
@@ -312,8 +310,9 @@ Error DirAccessWindows::remove(String p_path) {
if (p_path.is_rel_path())
p_path=get_current_dir().plus_file(p_path);
- else
- p_path=fix_path(p_path);
+
+ p_path=fix_path(p_path);
+
printf("erasing %s\n",p_path.utf8().get_data());
//WIN32_FILE_ATTRIBUTE_DATA fileInfo;
@@ -359,8 +358,13 @@ FileType DirAccessWindows::get_file_type(const String& p_file) const {
*/
size_t DirAccessWindows::get_space_left() {
- return -1;
-};
+ uint64_t bytes = 0;
+ if (!GetDiskFreeSpaceEx(NULL,(PULARGE_INTEGER)&bytes,NULL,NULL))
+ return 0;
+
+ //this is either 0 or a value in bytes.
+ return (size_t)bytes;
+}
DirAccessWindows::DirAccessWindows() {
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index 66181a6f44..3f27068fb2 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -131,6 +131,10 @@ void FileAccessWindows::close() {
//atomic replace for existing file
rename_error = !ReplaceFileW(save_path.c_str(), (save_path+".tmp").c_str(), NULL, 2|4, NULL, NULL);
}
+ if (rename_error && close_fail_notify) {
+ close_fail_notify(save_path);
+ }
+
save_path="";
ERR_FAIL_COND( rename_error );
}
diff --git a/drivers/windows/thread_windows.cpp b/drivers/windows/thread_windows.cpp
index d5e489aab4..884575e81e 100644
--- a/drivers/windows/thread_windows.cpp
+++ b/drivers/windows/thread_windows.cpp
@@ -32,6 +32,7 @@
#include "os/memory.h"
+
Thread::ID ThreadWindows::get_ID() const {
return id;
@@ -45,8 +46,14 @@ Thread* ThreadWindows::create_thread_windows() {
DWORD ThreadWindows::thread_callback( LPVOID userdata ) {
ThreadWindows *t=reinterpret_cast<ThreadWindows*>(userdata);
- t->callback(t->user);
+
+ ScriptServer::thread_enter(); //scripts may need to attach a stack
+
t->id=(ID)GetCurrentThreadId(); // must implement
+ t->callback(t->user);
+
+ ScriptServer::thread_exit();
+
return 0;
}
diff --git a/drivers/windows/thread_windows.h b/drivers/windows/thread_windows.h
index b051bfe370..1c90504dde 100644
--- a/drivers/windows/thread_windows.h
+++ b/drivers/windows/thread_windows.h
@@ -36,6 +36,7 @@
#ifdef WINDOWS_ENABLED
#include "os/thread.h"
+#include "script_language.h"
#include <windows.h>
class ThreadWindows : public Thread {