Skip to content

[3.x] File.file_exists and Directory.file_exists returns false under the PackedData filesystem when file exists #65802

@Rubonnek

Description

@Rubonnek

Godot version

3.x at 5600be9

System information

Arch Linux

Issue description

On certain paths where a file exist, File.file_exists and Directory.file_exists return false depending on what filesystem is being accessed.
Even when the file exists, in line 183 below, Map<PathMD5, PackedFile>.find does not seem to work properly since it returns a null value.

FileAccess *PackedData::try_open_path(const String &p_path) {
PathMD5 pmd5(p_path.md5_buffer());
Map<PathMD5, PackedFile>::Element *E = files.find(pmd5);
if (!E) {
return nullptr; //not found
}

The md5 path hashing and finding does not seem to work as expected.

Related Issues:

Steps to reproduce

  1. Decompress file_exists_bug.zip and open with the Editor and run the project. You'll see the following output:
Checking path with res://
Path: res://autoload/singleton_manager/singletons/engine_data_forwarder_manager/forward_engine_data_node.gd
File.file_exists: True
Directory.file_exists: True
load() check: [GDScript:1269]
Checking path without res://
Path: autoload/singleton_manager/singletons/engine_data_forwarder_manager/forward_engine_data_node.gd
File.file_exists: True
Directory.file_exists: True
load() check: [GDScript:1272]
  1. Decompress file_exists_bug_export.pck.zip and open with
godot --main-pack file_exists_bug_export.pck

And you'll get the following output -- note that File.file_exists and Directory.file_exists return false but Godot is still able to load the resource:

Checking path with res://
Path: res://autoload/singleton_manager/singletons/engine_data_forwarder_manager/forward_engine_data_node.gd
File.file_exists: False
Directory.file_exists: False
load() check: [GDScript:1266]
Checking path without res://
Path: autoload/singleton_manager/singletons/engine_data_forwarder_manager/forward_engine_data_node.gd
File.file_exists: False
Directory.file_exists: False
load() check: [GDScript:1269]

Minimal reproduction project

file_exists_bug.zip
file_exists_bug_export.pck.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions