summaryrefslogtreecommitdiff
path: root/drivers/windows
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/windows')
-rw-r--r--drivers/windows/file_access_windows.cpp27
-rw-r--r--drivers/windows/stream_peer_tcp_winsock.cpp4
-rw-r--r--drivers/windows/tcp_server_winsock.cpp1
3 files changed, 28 insertions, 4 deletions
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index 23c8ea2ec7..aa0fd34e0a 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -85,10 +85,31 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
return ERR_FILE_CANT_OPEN;
};
+#ifdef TOOLS_ENABLED
+ // Windows is case insensitive, but all other platforms are sensitive to it
+ // To ease cross-platform development, we issue a warning if users try to access
+ // a file using the wrong case (which *works* on Windows, but won't on other
+ // platforms).
+ if (p_mode_flags == READ) {
+ WIN32_FIND_DATAW d = { 0 };
+ HANDLE f = FindFirstFileW(path.c_str(), &d);
+ if (f) {
+ String fname = d.cFileName;
+ if (fname != String()) {
+
+ String base_file = path.get_file();
+ if (base_file != fname && base_file.findn(fname) == 0) {
+ WARN_PRINTS("Case mismatch opening requested file '" + base_file + "', stored as '" + fname + "' in the filesystem. This file will not open when exported to other case-sensitive platforms.");
+ }
+ }
+ FindClose(f);
+ }
+ }
+#endif
+
if (is_backup_save_enabled() && p_mode_flags & WRITE && !(p_mode_flags & READ)) {
save_path = path;
path = path + ".tmp";
- //print_line("saving instead to "+path);
}
f = _wfopen(path.c_str(), mode_string);
@@ -113,7 +134,7 @@ void FileAccessWindows::close() {
if (save_path != "") {
//unlink(save_path.utf8().get_data());
- //print_line("renaming..");
+ //print_line("renaming...");
//_wunlink(save_path.c_str()); //unlink if exists
//int rename_error = _wrename((save_path+".tmp").c_str(),save_path.c_str());
@@ -141,7 +162,7 @@ void FileAccessWindows::close() {
}
if (rename_error) {
attempts--;
- OS::get_singleton()->delay_usec(1000000); //wait 100msec and try again
+ OS::get_singleton()->delay_usec(100000); // wait 100msec and try again
}
}
diff --git a/drivers/windows/stream_peer_tcp_winsock.cpp b/drivers/windows/stream_peer_tcp_winsock.cpp
index 55775fc231..cb501ce35d 100644
--- a/drivers/windows/stream_peer_tcp_winsock.cpp
+++ b/drivers/windows/stream_peer_tcp_winsock.cpp
@@ -335,7 +335,9 @@ Error StreamPeerTCPWinsock::connect_to_host(const IP_Address &p_host, uint16_t p
void StreamPeerTCPWinsock::set_no_delay(bool p_enabled) {
ERR_FAIL_COND(!is_connected_to_host());
int flag = p_enabled ? 1 : 0;
- setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int));
+ if (setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)) != 0) {
+ ERR_PRINT("Unable to set TCP no delay option");
+ }
}
int StreamPeerTCPWinsock::get_available_bytes() const {
diff --git a/drivers/windows/tcp_server_winsock.cpp b/drivers/windows/tcp_server_winsock.cpp
index 413a0d19b5..ddb955549f 100644
--- a/drivers/windows/tcp_server_winsock.cpp
+++ b/drivers/windows/tcp_server_winsock.cpp
@@ -105,6 +105,7 @@ Error TCPServerWinsock::listen(uint16_t p_port, const IP_Address &p_bind_address
ERR_FAIL_V(FAILED);
};
} else {
+ closesocket(sockfd);
return ERR_ALREADY_IN_USE;
};