Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directory dir_exists fails on exported projects on subpaths & paths with more than 2 slashes in res` #37646

Open
Mantarri opened this issue Apr 7, 2020 · 6 comments

Comments

@Mantarri
Copy link

Mantarri commented Apr 7, 2020

Godot version:
3.2.1

OS/device including version:
Arch Linux, up to date as of April 6th, 2020

Issue description:
Directory, and File classes fail to find directories, or files, using dir_exists, file_exists on exported projects.

Steps to reproduce:

Create Directory object, and attempt to check whether directory/file exists, note that it shows the file/directory exists when the project is run from the editor, but shows that the file/directory does not export when project is exported, and the resulting binary is run.

Note: dir.open does work with the same path, so it seems to be exclusive to how dir_exists work.

Minimal reproduction project:

Sorry for the OneDrive link
There are similar issues (including 26009), but was directed to create my own, so here it is.

@dankan1890
Copy link
Contributor

It seems that in the export settings miss the inclusion of the file *.txt.

@Mantarri
Copy link
Author

Mantarri commented Apr 7, 2020

It seems that in the export settings miss the inclusion of the file *.txt.

My bad, I fixed that, but it still seems to have problems with finding directories at concatenated paths, everything else works as intended though.

@Mantarri Mantarri changed the title Directory dir_exists, file_exists & File file_exists fail on exported projects Directory dir_exists, fail on exported projects with concatenated folder paths Apr 7, 2020
@Mantarri Mantarri changed the title Directory dir_exists, fail on exported projects with concatenated folder paths Directory dir_exists` fails on exported projects with concatenated folder paths Apr 7, 2020
@Mantarri
Copy link
Author

Mantarri commented Apr 7, 2020

After more testing, it appears to work if I remove res:// for checking for directories in res://, but works if I start with user:// to check for directories in user://.

@Mantarri
Copy link
Author

Mantarri commented Apr 8, 2020

After even more testing, it appears that dir_exists is only working for directories directly inside res://, and as a nice tidbit, it will find res://aFolderIsHere, but fails if you add / to the end like this res://aFolderIsHere/

@Mantarri Mantarri changed the title Directory dir_exists` fails on exported projects with concatenated folder paths Directory dir_exists fails on exported projects on subpaths & paths with more than 2 slashes in res` Apr 10, 2020
@rburing
Copy link
Member

rburing commented Nov 5, 2020

Here are the bugs:

bool DirAccessPack::file_exists(String p_file) {
p_file = fix_path(p_file);
return current->files.has(p_file);
}
bool DirAccessPack::dir_exists(String p_dir) {
p_dir = fix_path(p_dir);
return current->subdirs.has(p_dir);
}

The only thing that is done when dir_exists is passed an absolute res://... path which points into a PCK file (i.e. in exported projects) is removing the res:// prefix and checking whether that path (including slashes, if any) is a direct subdirectory. Of course, this will be false for any path containing more slashes than those those two in res://. We need to go deeper...

@akien-mga
Copy link
Member

akien-mga commented Jan 13, 2022

See #56737 (comment) where @timvisee found that a similar bug is fixed in master, and proposed a potential fix or workaround.

CC @RandomShaper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants