feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -30,9 +30,17 @@
#include "file_access_encrypted.h"
#include "core/crypto/crypto_core.h"
#include "core/variant/variant.h"
CryptoCore::RandomGenerator *FileAccessEncrypted::_fae_static_rng = nullptr;
void FileAccessEncrypted::deinitialize() {
if (_fae_static_rng) {
memdelete(_fae_static_rng);
_fae_static_rng = nullptr;
}
}
Error FileAccessEncrypted::open_and_parse(Ref<FileAccess> p_base, const Vector<uint8_t> &p_key, Mode p_mode, bool p_with_magic, const Vector<uint8_t> &p_iv) {
ERR_FAIL_COND_V_MSG(file.is_valid(), ERR_ALREADY_IN_USE, vformat("Can't open file while another file from path '%s' is open.", file->get_path_absolute()));
ERR_FAIL_COND_V(p_key.size() != 32, ERR_INVALID_PARAMETER);
@ -48,9 +56,15 @@ Error FileAccessEncrypted::open_and_parse(Ref<FileAccess> p_base, const Vector<u
key = p_key;
if (p_iv.is_empty()) {
iv.resize(16);
CryptoCore::RandomGenerator rng;
ERR_FAIL_COND_V_MSG(rng.init(), FAILED, "Failed to initialize random number generator.");
Error err = rng.get_random_bytes(iv.ptrw(), 16);
if (unlikely(!_fae_static_rng)) {
_fae_static_rng = memnew(CryptoCore::RandomGenerator);
if (_fae_static_rng->init() != OK) {
memdelete(_fae_static_rng);
_fae_static_rng = nullptr;
ERR_FAIL_V_MSG(FAILED, "Failed to initialize random number generator.");
}
}
Error err = _fae_static_rng->get_random_bytes(iv.ptrw(), 16);
ERR_FAIL_COND_V(err != OK, err);
} else {
ERR_FAIL_COND_V(p_iv.size() != 16, ERR_INVALID_PARAMETER);
@ -265,7 +279,27 @@ bool FileAccessEncrypted::file_exists(const String &p_name) {
}
uint64_t FileAccessEncrypted::_get_modified_time(const String &p_file) {
return 0;
if (file.is_valid()) {
return file->get_modified_time(p_file);
} else {
return 0;
}
}
uint64_t FileAccessEncrypted::_get_access_time(const String &p_file) {
if (file.is_valid()) {
return file->get_access_time(p_file);
} else {
return 0;
}
}
int64_t FileAccessEncrypted::_get_size(const String &p_file) {
if (file.is_valid()) {
return file->get_size(p_file);
} else {
return -1;
}
}
BitField<FileAccess::UnixPermissionFlags> FileAccessEncrypted::_get_unix_permissions(const String &p_file) {