summaryrefslogtreecommitdiff
path: root/drivers/windows
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/windows')
-rw-r--r--drivers/windows/dir_access_windows.cpp35
-rw-r--r--drivers/windows/dir_access_windows.h1
-rw-r--r--drivers/windows/file_access_windows.cpp43
-rw-r--r--drivers/windows/file_access_windows.h3
-rw-r--r--drivers/windows/semaphore_windows.cpp3
-rw-r--r--drivers/windows/shell_windows.cpp67
-rw-r--r--drivers/windows/shell_windows.h52
7 files changed, 65 insertions, 139 deletions
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp
index 8ac4e53c65..9eac15f774 100644
--- a/drivers/windows/dir_access_windows.cpp
+++ b/drivers/windows/dir_access_windows.cpp
@@ -347,27 +347,26 @@ size_t DirAccessWindows::get_space_left() {
}
String DirAccessWindows::get_filesystem_type() const {
- String path = fix_path(const_cast<DirAccessWindows*>(this)->get_current_dir());
- print_line("fixed path: "+path);
+ 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) + "\\";
- print_line("unit: "+unit);
+ 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) {
+ 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);
}
@@ -395,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 b8599d5c26..10eee07f0c 100644
--- a/drivers/windows/dir_access_windows.h
+++ b/drivers/windows/dir_access_windows.h
@@ -84,7 +84,6 @@ public:
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 babb393dcb..c13300d09f 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -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,9 +339,20 @@ uint64_t FileAccessWindows::_get_modified_time(const String &p_file) {
}
}
+uint32_t FileAccessWindows::_get_unix_permissions(const String &p_file) {
+ ERR_PRINT("Windows does not support unix permissions");
+ return 0;
+}
+
+Error FileAccessWindows::_set_unix_permissions(const String &p_file, uint32_t p_permissions) {
+ ERR_PRINT("Windows does not support unix permissions");
+ return FAILED;
+}
+
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 c105eb5265..2848ed5279 100644
--- a/drivers/windows/file_access_windows.h
+++ b/drivers/windows/file_access_windows.h
@@ -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;
@@ -79,6 +80,8 @@ public:
virtual bool file_exists(const String &p_name); ///< return true if a file exists
uint64_t _get_modified_time(const String &p_file);
+ virtual uint32_t _get_unix_permissions(const String &p_file);
+ virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions);
FileAccessWindows();
virtual ~FileAccessWindows();
diff --git a/drivers/windows/semaphore_windows.cpp b/drivers/windows/semaphore_windows.cpp
index 718bb81836..55b47e45eb 100644
--- a/drivers/windows/semaphore_windows.cpp
+++ b/drivers/windows/semaphore_windows.cpp
@@ -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/shell_windows.cpp b/drivers/windows/shell_windows.cpp
deleted file mode 100644
index 731d16d18d..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-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 */
-/* "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 9e9edd2f62..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-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 */
-/* "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