diff options
Diffstat (limited to 'drivers/windows')
-rw-r--r-- | drivers/windows/dir_access_windows.cpp | 34 | ||||
-rw-r--r-- | drivers/windows/dir_access_windows.h | 6 | ||||
-rw-r--r-- | drivers/windows/file_access_windows.cpp | 46 | ||||
-rw-r--r-- | drivers/windows/file_access_windows.h | 5 | ||||
-rw-r--r-- | drivers/windows/mutex_windows.cpp | 4 | ||||
-rw-r--r-- | drivers/windows/mutex_windows.h | 4 | ||||
-rw-r--r-- | drivers/windows/rw_lock_windows.cpp | 4 | ||||
-rw-r--r-- | drivers/windows/rw_lock_windows.h | 4 | ||||
-rw-r--r-- | drivers/windows/semaphore_windows.cpp | 7 | ||||
-rw-r--r-- | drivers/windows/semaphore_windows.h | 4 | ||||
-rw-r--r-- | drivers/windows/shell_windows.cpp | 67 | ||||
-rw-r--r-- | drivers/windows/shell_windows.h | 52 | ||||
-rw-r--r-- | drivers/windows/thread_windows.cpp | 20 | ||||
-rw-r--r-- | drivers/windows/thread_windows.h | 4 |
14 files changed, 101 insertions, 160 deletions
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 589e9e0870..9eac15f774 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -346,6 +346,34 @@ size_t DirAccessWindows::get_space_left() { return (size_t)bytes; } +String DirAccessWindows::get_filesystem_type() const { + String path = fix_path(const_cast<DirAccessWindows *>(this)->get_current_dir()); + + int unit_end = path.find(":"); + ERR_FAIL_COND_V(unit_end == -1, String()); + String unit = path.substr(0, unit_end + 1) + "\\"; + + WCHAR szVolumeName[100]; + WCHAR szFileSystemName[10]; + DWORD dwSerialNumber = 0; + DWORD dwMaxFileNameLength = 0; + DWORD dwFileSystemFlags = 0; + + if (::GetVolumeInformationW(unit.c_str(), + szVolumeName, + sizeof(szVolumeName), + &dwSerialNumber, + &dwMaxFileNameLength, + &dwFileSystemFlags, + szFileSystemName, + sizeof(szFileSystemName)) == TRUE) { + + return String(szFileSystemName); + } + + ERR_FAIL_V(""); +} + DirAccessWindows::DirAccessWindows() { p = memnew(DirAccessWindowsPrivate); @@ -366,7 +394,7 @@ DirAccessWindows::DirAccessWindows() { if (mask & (1 << i)) { //DRIVE EXISTS - drives[drive_count] = 'a' + i; + drives[drive_count] = 'A' + i; drive_count++; } } diff --git a/drivers/windows/dir_access_windows.h b/drivers/windows/dir_access_windows.h index 9f5d0b6d93..10eee07f0c 100644 --- a/drivers/windows/dir_access_windows.h +++ b/drivers/windows/dir_access_windows.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -82,6 +82,8 @@ public: //virtual FileType get_file_type() const; size_t get_space_left(); + virtual String get_filesystem_type() const; + DirAccessWindows(); ~DirAccessWindows(); }; diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 2582478259..c4c5e0d709 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -197,12 +197,14 @@ void FileAccessWindows::seek(size_t p_position) { last_error = OK; if (fseek(f, p_position, SEEK_SET)) check_errors(); + prev_op = 0; } void FileAccessWindows::seek_end(int64_t p_position) { ERR_FAIL_COND(!f); if (fseek(f, p_position, SEEK_END)) check_errors(); + prev_op = 0; } size_t FileAccessWindows::get_position() const { @@ -234,6 +236,12 @@ bool FileAccessWindows::eof_reached() const { uint8_t FileAccessWindows::get_8() const { ERR_FAIL_COND_V(!f, 0); + if (flags == READ_WRITE || flags == WRITE_READ) { + if (prev_op == WRITE) { + fflush(f); + } + prev_op = READ; + } uint8_t b; if (fread(&b, 1, 1, f) == 0) { check_errors(); @@ -246,6 +254,12 @@ uint8_t FileAccessWindows::get_8() const { int FileAccessWindows::get_buffer(uint8_t *p_dst, int p_length) const { ERR_FAIL_COND_V(!f, -1); + if (flags == READ_WRITE || flags == WRITE_READ) { + if (prev_op == WRITE) { + fflush(f); + } + prev_op = READ; + } int read = fread(p_dst, 1, p_length, f); check_errors(); return read; @@ -260,16 +274,34 @@ void FileAccessWindows::flush() { ERR_FAIL_COND(!f); fflush(f); + if (prev_op == WRITE) + prev_op = 0; } void FileAccessWindows::store_8(uint8_t p_dest) { ERR_FAIL_COND(!f); + if (flags == READ_WRITE || flags == WRITE_READ) { + if (prev_op == READ) { + if (last_error != ERR_FILE_EOF) { + fseek(f, 0, SEEK_CUR); + } + } + prev_op = WRITE; + } fwrite(&p_dest, 1, 1, f); } void FileAccessWindows::store_buffer(const uint8_t *p_src, int p_length) { ERR_FAIL_COND(!f); + if (flags == READ_WRITE || flags == WRITE_READ) { + if (prev_op == READ) { + if (last_error != ERR_FILE_EOF) { + fseek(f, 0, SEEK_CUR); + } + } + prev_op = WRITE; + } ERR_FAIL_COND(fwrite(p_src, 1, p_length, f) != p_length); } @@ -307,11 +339,11 @@ uint64_t FileAccessWindows::_get_modified_time(const String &p_file) { } } -FileAccessWindows::FileAccessWindows() { - - f = NULL; - flags = 0; - last_error = OK; +FileAccessWindows::FileAccessWindows() : + f(NULL), + flags(0), + prev_op(0), + last_error(OK) { } FileAccessWindows::~FileAccessWindows() { diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h index 6f985e68b4..35b1f0b2d8 100644 --- a/drivers/windows/file_access_windows.h +++ b/drivers/windows/file_access_windows.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -47,6 +47,7 @@ class FileAccessWindows : public FileAccess { FILE *f; int flags; void check_errors() const; + mutable int prev_op; mutable Error last_error; String path; String path_src; diff --git a/drivers/windows/mutex_windows.cpp b/drivers/windows/mutex_windows.cpp index 9fc6485be3..cfb72293aa 100644 --- a/drivers/windows/mutex_windows.cpp +++ b/drivers/windows/mutex_windows.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* 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 5c3a8eb331..6d3b641a26 100644 --- a/drivers/windows/mutex_windows.h +++ b/drivers/windows/mutex_windows.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* 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/rw_lock_windows.cpp b/drivers/windows/rw_lock_windows.cpp index ef00141928..40e424c4af 100644 --- a/drivers/windows/rw_lock_windows.cpp +++ b/drivers/windows/rw_lock_windows.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* 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/rw_lock_windows.h b/drivers/windows/rw_lock_windows.h index 742a0930d4..1e768728a0 100644 --- a/drivers/windows/rw_lock_windows.h +++ b/drivers/windows/rw_lock_windows.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* 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 34dd387705..55b47e45eb 100644 --- a/drivers/windows/semaphore_windows.cpp +++ b/drivers/windows/semaphore_windows.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -54,7 +54,8 @@ int SemaphoreWindows::get() const { case WAIT_TIMEOUT: { return 0; } break; - default: {} + default: { + } } ERR_FAIL_V(-1); diff --git a/drivers/windows/semaphore_windows.h b/drivers/windows/semaphore_windows.h index 1e2f9c152e..8adeffbb7f 100644 --- a/drivers/windows/semaphore_windows.h +++ b/drivers/windows/semaphore_windows.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* 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 deleted file mode 100644 index 20e996d776..0000000000 --- a/drivers/windows/shell_windows.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************/ -/* shell_windows.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* 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 - -#ifdef UWP_ENABLED - -// Use Launcher class on windows 8 - -#else - -// -// C++ Implementation: shell_windows -// -// Description: -// -// -// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2008 -// -// Copyright: See COPYING file that comes with this distribution -// -// -#include "shell_windows.h" - -#include <windows.h> - -void ShellWindows::execute(String p_path) { - - ShellExecuteW(NULL, L"open", p_path.c_str(), NULL, NULL, SW_SHOWNORMAL); -} - -ShellWindows::ShellWindows() { -} - -ShellWindows::~ShellWindows() { -} - -#endif - -#endif diff --git a/drivers/windows/shell_windows.h b/drivers/windows/shell_windows.h deleted file mode 100644 index 98972a9bb1..0000000000 --- a/drivers/windows/shell_windows.h +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************/ -/* shell_windows.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef SHELL_WINDOWS_H -#define SHELL_WINDOWS_H - -#include "core/os/shell.h" - -#ifdef WINDOWS_ENABLED - -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ - -class ShellWindows : public Shell { -public: - virtual void execute(String p_path); - - ShellWindows(); - - ~ShellWindows(); -}; - -#endif -#endif diff --git a/drivers/windows/thread_windows.cpp b/drivers/windows/thread_windows.cpp index 52dcfacdf8..8a2992e0c2 100644 --- a/drivers/windows/thread_windows.cpp +++ b/drivers/windows/thread_windows.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -52,6 +52,7 @@ DWORD ThreadWindows::thread_callback(LPVOID userdata) { t->id = (ID)GetCurrentThreadId(); // must implement t->callback(t->user); + SetEvent(t->handle); ScriptServer::thread_exit(); @@ -63,13 +64,9 @@ Thread *ThreadWindows::create_func_windows(ThreadCreateCallback p_callback, void ThreadWindows *tr = memnew(ThreadWindows); tr->callback = p_callback; tr->user = p_user; - tr->handle = CreateThread( - NULL, // default security attributes - 0, // use default stack size - thread_callback, // thread function name - tr, // argument to thread function - 0, // use default creation flags - NULL); // returns the thread identifier + tr->handle = CreateEvent(NULL, TRUE, FALSE, NULL); + + QueueUserWorkItem(thread_callback, tr, WT_EXECUTELONGFUNCTION); return tr; } @@ -93,9 +90,8 @@ void ThreadWindows::make_default() { wait_to_finish_func = wait_to_finish_func_windows; } -ThreadWindows::ThreadWindows() { - - handle = NULL; +ThreadWindows::ThreadWindows() : + handle(NULL) { } ThreadWindows::~ThreadWindows() { diff --git a/drivers/windows/thread_windows.h b/drivers/windows/thread_windows.h index 5d2838e54f..a74d4e46f3 100644 --- a/drivers/windows/thread_windows.h +++ b/drivers/windows/thread_windows.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ |