feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -70,17 +70,17 @@ struct DirAccessWindowsPrivate {
|
|||
};
|
||||
|
||||
String DirAccessWindows::fix_path(const String &p_path) const {
|
||||
String r_path = DirAccess::fix_path(p_path.trim_prefix(R"(\\?\)").replace("\\", "/"));
|
||||
String r_path = DirAccess::fix_path(p_path.trim_prefix(R"(\\?\)").replace_char('\\', '/'));
|
||||
if (r_path.ends_with(":")) {
|
||||
r_path += "/";
|
||||
}
|
||||
if (r_path.is_relative_path()) {
|
||||
r_path = current_dir.trim_prefix(R"(\\?\)").replace("\\", "/").path_join(r_path);
|
||||
r_path = current_dir.trim_prefix(R"(\\?\)").replace_char('\\', '/').path_join(r_path);
|
||||
} else if (r_path == ".") {
|
||||
r_path = current_dir.trim_prefix(R"(\\?\)").replace("\\", "/");
|
||||
r_path = current_dir.trim_prefix(R"(\\?\)").replace_char('\\', '/');
|
||||
}
|
||||
r_path = r_path.simplify_path();
|
||||
r_path = r_path.replace("/", "\\");
|
||||
r_path = r_path.replace_char('/', '\\');
|
||||
if (!r_path.is_network_share_path() && !r_path.begins_with(R"(\\?\)")) {
|
||||
r_path = R"(\\?\)" + r_path;
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ Error DirAccessWindows::change_dir(String p_dir) {
|
|||
str_len = GetCurrentDirectoryW(0, nullptr);
|
||||
real_current_dir_name.resize(str_len + 1);
|
||||
GetCurrentDirectoryW(real_current_dir_name.size(), (LPWSTR)real_current_dir_name.ptrw());
|
||||
String new_dir = String::utf16((const char16_t *)real_current_dir_name.get_data()).trim_prefix(R"(\\?\)").replace("\\", "/");
|
||||
String new_dir = String::utf16((const char16_t *)real_current_dir_name.get_data()).trim_prefix(R"(\\?\)").replace_char('\\', '/');
|
||||
if (!new_dir.begins_with(base)) {
|
||||
worked = false;
|
||||
}
|
||||
|
|
@ -215,12 +215,12 @@ Error DirAccessWindows::make_dir(String p_dir) {
|
|||
}
|
||||
|
||||
String DirAccessWindows::get_current_dir(bool p_include_drive) const {
|
||||
String cdir = current_dir.trim_prefix(R"(\\?\)").replace("\\", "/");
|
||||
String cdir = current_dir.trim_prefix(R"(\\?\)").replace_char('\\', '/');
|
||||
String base = _get_root_path();
|
||||
if (!base.is_empty()) {
|
||||
String bd = cdir.replace_first(base, "");
|
||||
if (bd.begins_with("/")) {
|
||||
return _get_root_string() + bd.substr(1, bd.length());
|
||||
return _get_root_string() + bd.substr(1);
|
||||
} else {
|
||||
return _get_root_string() + bd;
|
||||
}
|
||||
|
|
@ -391,6 +391,38 @@ bool DirAccessWindows::is_case_sensitive(const String &p_path) const {
|
|||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
ULONGLONG LowPart;
|
||||
ULONGLONG HighPart;
|
||||
} GD_FILE_ID_128;
|
||||
|
||||
typedef struct {
|
||||
ULONGLONG VolumeSerialNumber;
|
||||
GD_FILE_ID_128 FileId;
|
||||
} GD_FILE_ID_INFO;
|
||||
|
||||
bool DirAccessWindows::is_equivalent(const String &p_path_a, const String &p_path_b) const {
|
||||
String f1 = fix_path(p_path_a);
|
||||
GD_FILE_ID_INFO st1;
|
||||
HANDLE h1 = ::CreateFileW((LPCWSTR)(f1.utf16().get_data()), FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
|
||||
if (h1 == INVALID_HANDLE_VALUE) {
|
||||
return DirAccess::is_equivalent(p_path_a, p_path_b);
|
||||
}
|
||||
::GetFileInformationByHandleEx(h1, (FILE_INFO_BY_HANDLE_CLASS)0x12 /*FileIdInfo*/, &st1, sizeof(st1));
|
||||
::CloseHandle(h1);
|
||||
|
||||
String f2 = fix_path(p_path_b);
|
||||
GD_FILE_ID_INFO st2;
|
||||
HANDLE h2 = ::CreateFileW((LPCWSTR)(f2.utf16().get_data()), FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
|
||||
if (h2 == INVALID_HANDLE_VALUE) {
|
||||
return DirAccess::is_equivalent(p_path_a, p_path_b);
|
||||
}
|
||||
::GetFileInformationByHandleEx(h2, (FILE_INFO_BY_HANDLE_CLASS)0x12 /*FileIdInfo*/, &st2, sizeof(st2));
|
||||
::CloseHandle(h2);
|
||||
|
||||
return (st1.VolumeSerialNumber == st2.VolumeSerialNumber) && (st1.FileId.LowPart == st2.FileId.LowPart) && (st1.FileId.HighPart == st2.FileId.HighPart);
|
||||
}
|
||||
|
||||
bool DirAccessWindows::is_link(String p_file) {
|
||||
String f = fix_path(p_file);
|
||||
|
||||
|
|
@ -419,7 +451,7 @@ String DirAccessWindows::read_link(String p_file) {
|
|||
GetFinalPathNameByHandleW(hfile, (LPWSTR)cs.ptrw(), ret, VOLUME_NAME_DOS | FILE_NAME_NORMALIZED);
|
||||
CloseHandle(hfile);
|
||||
|
||||
return String::utf16((const char16_t *)cs.ptr(), ret).trim_prefix(R"(\\?\)").replace("\\", "/");
|
||||
return String::utf16((const char16_t *)cs.ptr(), ret).trim_prefix(R"(\\?\)").replace_char('\\', '/');
|
||||
}
|
||||
|
||||
Error DirAccessWindows::create_link(String p_source, String p_target) {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef DIR_ACCESS_WINDOWS_H
|
||||
#define DIR_ACCESS_WINDOWS_H
|
||||
#pragma once
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
|
||||
|
|
@ -38,6 +37,7 @@
|
|||
struct DirAccessWindowsPrivate;
|
||||
|
||||
class DirAccessWindows : public DirAccess {
|
||||
GDSOFTCLASS(DirAccessWindows, DirAccess);
|
||||
enum {
|
||||
MAX_DRIVES = 26
|
||||
};
|
||||
|
|
@ -85,11 +85,10 @@ public:
|
|||
|
||||
virtual String get_filesystem_type() const override;
|
||||
virtual bool is_case_sensitive(const String &p_path) const override;
|
||||
virtual bool is_equivalent(const String &p_path_a, const String &p_path_b) const override;
|
||||
|
||||
DirAccessWindows();
|
||||
~DirAccessWindows();
|
||||
};
|
||||
|
||||
#endif // WINDOWS_ENABLED
|
||||
|
||||
#endif // DIR_ACCESS_WINDOWS_H
|
||||
|
|
|
|||
|
|
@ -87,10 +87,10 @@ String FileAccessWindows::fix_path(const String &p_path) const {
|
|||
size_t str_len = GetCurrentDirectoryW(0, nullptr);
|
||||
current_dir_name.resize(str_len + 1);
|
||||
GetCurrentDirectoryW(current_dir_name.size(), (LPWSTR)current_dir_name.ptrw());
|
||||
r_path = String::utf16((const char16_t *)current_dir_name.get_data()).trim_prefix(R"(\\?\)").replace("\\", "/").path_join(r_path);
|
||||
r_path = String::utf16((const char16_t *)current_dir_name.get_data()).trim_prefix(R"(\\?\)").replace_char('\\', '/').path_join(r_path);
|
||||
}
|
||||
r_path = r_path.simplify_path();
|
||||
r_path = r_path.replace("/", "\\");
|
||||
r_path = r_path.replace_char('/', '\\');
|
||||
if (!r_path.is_network_share_path() && !r_path.begins_with(R"(\\?\)")) {
|
||||
r_path = R"(\\?\)" + r_path;
|
||||
}
|
||||
|
|
@ -282,7 +282,7 @@ String FileAccessWindows::get_path() const {
|
|||
}
|
||||
|
||||
String FileAccessWindows::get_path_absolute() const {
|
||||
return path.trim_prefix(R"(\\?\)").replace("\\", "/");
|
||||
return path.trim_prefix(R"(\\?\)").replace_char('\\', '/');
|
||||
}
|
||||
|
||||
bool FileAccessWindows::is_open() const {
|
||||
|
|
@ -418,7 +418,7 @@ uint64_t FileAccessWindows::_get_modified_time(const String &p_file) {
|
|||
file = file.substr(0, file.length() - 1);
|
||||
}
|
||||
|
||||
HANDLE handle = CreateFileW((LPCWSTR)(file.utf16().get_data()), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
|
||||
HANDLE handle = CreateFileW((LPCWSTR)(file.utf16().get_data()), FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
|
||||
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
FILETIME ft_create, ft_write;
|
||||
|
|
@ -453,6 +453,78 @@ uint64_t FileAccessWindows::_get_modified_time(const String &p_file) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint64_t FileAccessWindows::_get_access_time(const String &p_file) {
|
||||
if (is_path_invalid(p_file)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String file = fix_path(p_file);
|
||||
if (file.ends_with("\\") && file != "\\") {
|
||||
file = file.substr(0, file.length() - 1);
|
||||
}
|
||||
|
||||
HANDLE handle = CreateFileW((LPCWSTR)(file.utf16().get_data()), FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
|
||||
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
FILETIME ft_create, ft_access;
|
||||
|
||||
bool status = GetFileTime(handle, &ft_create, &ft_access, nullptr);
|
||||
|
||||
CloseHandle(handle);
|
||||
|
||||
if (status) {
|
||||
uint64_t ret = 0;
|
||||
|
||||
// If access time is invalid, fallback to creation time.
|
||||
if (ft_access.dwHighDateTime == 0 && ft_access.dwLowDateTime == 0) {
|
||||
ret = ft_create.dwHighDateTime;
|
||||
ret <<= 32;
|
||||
ret |= ft_create.dwLowDateTime;
|
||||
} else {
|
||||
ret = ft_access.dwHighDateTime;
|
||||
ret <<= 32;
|
||||
ret |= ft_access.dwLowDateTime;
|
||||
}
|
||||
|
||||
const uint64_t WINDOWS_TICKS_PER_SECOND = 10000000;
|
||||
const uint64_t TICKS_TO_UNIX_EPOCH = 116444736000000000LL;
|
||||
|
||||
if (ret >= TICKS_TO_UNIX_EPOCH) {
|
||||
return (ret - TICKS_TO_UNIX_EPOCH) / WINDOWS_TICKS_PER_SECOND;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_V_MSG(0, "Failed to get access time for: " + p_file + "");
|
||||
}
|
||||
|
||||
int64_t FileAccessWindows::_get_size(const String &p_file) {
|
||||
if (is_path_invalid(p_file)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String file = fix_path(p_file);
|
||||
if (file.ends_with("\\") && file != "\\") {
|
||||
file = file.substr(0, file.length() - 1);
|
||||
}
|
||||
|
||||
DWORD file_attr = GetFileAttributesW((LPCWSTR)(file.utf16().get_data()));
|
||||
HANDLE handle = CreateFileW((LPCWSTR)(file.utf16().get_data()), FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
|
||||
|
||||
if (handle != INVALID_HANDLE_VALUE && !(file_attr & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
LARGE_INTEGER fsize;
|
||||
|
||||
bool status = GetFileSizeEx(handle, &fsize);
|
||||
|
||||
CloseHandle(handle);
|
||||
|
||||
if (status) {
|
||||
return (int64_t)fsize.QuadPart;
|
||||
}
|
||||
}
|
||||
ERR_FAIL_V_MSG(-1, "Failed to get size for: " + p_file + "");
|
||||
}
|
||||
|
||||
BitField<FileAccess::UnixPermissionFlags> FileAccessWindows::_get_unix_permissions(const String &p_file) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef FILE_ACCESS_WINDOWS_H
|
||||
#define FILE_ACCESS_WINDOWS_H
|
||||
#pragma once
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
|
||||
|
|
@ -39,6 +38,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
class FileAccessWindows : public FileAccess {
|
||||
GDSOFTCLASS(FileAccessWindows, FileAccess);
|
||||
FILE *f = nullptr;
|
||||
int flags = 0;
|
||||
void check_errors(bool p_write = false) const;
|
||||
|
|
@ -80,6 +80,8 @@ public:
|
|||
virtual bool file_exists(const String &p_name) override; ///< return true if a file exists
|
||||
|
||||
uint64_t _get_modified_time(const String &p_file) override;
|
||||
uint64_t _get_access_time(const String &p_file) override;
|
||||
int64_t _get_size(const String &p_file) override;
|
||||
virtual BitField<FileAccess::UnixPermissionFlags> _get_unix_permissions(const String &p_file) override;
|
||||
virtual Error _set_unix_permissions(const String &p_file, BitField<FileAccess::UnixPermissionFlags> p_permissions) override;
|
||||
|
||||
|
|
@ -98,5 +100,3 @@ public:
|
|||
};
|
||||
|
||||
#endif // WINDOWS_ENABLED
|
||||
|
||||
#endif // FILE_ACCESS_WINDOWS_H
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ Error FileAccessWindowsPipe::open_internal(const String &p_path, int p_mode_flag
|
|||
path_src = p_path;
|
||||
ERR_FAIL_COND_V_MSG(fd[0] != nullptr || fd[1] != nullptr, ERR_ALREADY_IN_USE, "Pipe is already in use.");
|
||||
|
||||
path = String("\\\\.\\pipe\\LOCAL\\") + p_path.replace("pipe://", "").replace("/", "_");
|
||||
path = String("\\\\.\\pipe\\LOCAL\\") + p_path.replace("pipe://", "").replace_char('/', '_');
|
||||
|
||||
HANDLE h = CreateFileW((LPCWSTR)path.utf16().get_data(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef FILE_ACCESS_WINDOWS_PIPE_H
|
||||
#define FILE_ACCESS_WINDOWS_PIPE_H
|
||||
#pragma once
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
|
||||
|
|
@ -38,7 +37,9 @@
|
|||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
class FileAccessWindowsPipe : public FileAccess {
|
||||
GDSOFTCLASS(FileAccessWindowsPipe, FileAccess);
|
||||
HANDLE fd[2] = { nullptr, nullptr };
|
||||
|
||||
mutable Error last_error = OK;
|
||||
|
|
@ -75,6 +76,8 @@ public:
|
|||
virtual bool file_exists(const String &p_name) override { return false; }
|
||||
|
||||
uint64_t _get_modified_time(const String &p_file) override { return 0; }
|
||||
virtual uint64_t _get_access_time(const String &p_file) override { return 0; }
|
||||
virtual int64_t _get_size(const String &p_file) override { return -1; }
|
||||
virtual BitField<FileAccess::UnixPermissionFlags> _get_unix_permissions(const String &p_file) override { return 0; }
|
||||
virtual Error _set_unix_permissions(const String &p_file, BitField<FileAccess::UnixPermissionFlags> p_permissions) override { return ERR_UNAVAILABLE; }
|
||||
|
||||
|
|
@ -90,5 +93,3 @@ public:
|
|||
};
|
||||
|
||||
#endif // WINDOWS_ENABLED
|
||||
|
||||
#endif // FILE_ACCESS_WINDOWS_PIPE_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef IP_WINDOWS_H
|
||||
#define IP_WINDOWS_H
|
||||
#pragma once
|
||||
|
||||
#if defined(WINDOWS_ENABLED)
|
||||
|
||||
|
|
@ -50,5 +49,3 @@ public:
|
|||
};
|
||||
|
||||
#endif // WINDOWS_ENABLED
|
||||
|
||||
#endif // IP_WINDOWS_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef NET_SOCKET_WINSOCK_H
|
||||
#define NET_SOCKET_WINSOCK_H
|
||||
#pragma once
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
|
||||
|
|
@ -98,5 +97,3 @@ public:
|
|||
};
|
||||
|
||||
#endif // WINDOWS_ENABLED
|
||||
|
||||
#endif // NET_SOCKET_WINSOCK_H
|
||||
|
|
|
|||
|
|
@ -28,13 +28,10 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef THREAD_WINDOWS_H
|
||||
#define THREAD_WINDOWS_H
|
||||
#pragma once
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
|
||||
void init_thread_win();
|
||||
|
||||
#endif // WINDOWS_ENABLED
|
||||
|
||||
#endif // THREAD_WINDOWS_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue