You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Improve/fix packed data API
- Enhance directory API - Fix `FileAccess::exists()` not checking for PackedData being disabled - Fix moving to the parent directory (`..`) - Allow absolute paths in existence checks
This commit is contained in:
@@ -53,7 +53,7 @@ FileAccess *FileAccess::create(AccessType p_access) {
|
||||
|
||||
bool FileAccess::exists(const String &p_name) {
|
||||
|
||||
if (PackedData::get_singleton() && PackedData::get_singleton()->has_path(p_name))
|
||||
if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_name))
|
||||
return true;
|
||||
|
||||
FileAccess *f = open(p_name, READ);
|
||||
@@ -494,7 +494,7 @@ void FileAccess::store_double(double p_dest) {
|
||||
|
||||
uint64_t FileAccess::get_modified_time(const String &p_file) {
|
||||
|
||||
if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_file))
|
||||
if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && (PackedData::get_singleton()->has_path(p_file) || PackedData::get_singleton()->has_directory(p_file)))
|
||||
return 0;
|
||||
|
||||
FileAccess *fa = create_for_path(p_file);
|
||||
@@ -507,7 +507,7 @@ uint64_t FileAccess::get_modified_time(const String &p_file) {
|
||||
|
||||
uint32_t FileAccess::get_unix_permissions(const String &p_file) {
|
||||
|
||||
if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_file))
|
||||
if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && (PackedData::get_singleton()->has_path(p_file) || PackedData::get_singleton()->has_directory(p_file)))
|
||||
return 0;
|
||||
|
||||
FileAccess *fa = create_for_path(p_file);
|
||||
@@ -520,6 +520,9 @@ uint32_t FileAccess::get_unix_permissions(const String &p_file) {
|
||||
|
||||
Error FileAccess::set_unix_permissions(const String &p_file, uint32_t p_permissions) {
|
||||
|
||||
if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && (PackedData::get_singleton()->has_path(p_file) || PackedData::get_singleton()->has_directory(p_file)))
|
||||
return ERR_UNAVAILABLE;
|
||||
|
||||
FileAccess *fa = create_for_path(p_file);
|
||||
ERR_FAIL_COND_V_MSG(!fa, ERR_CANT_CREATE, "Cannot create FileAccess for path '" + p_file + "'.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user