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
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue