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

FileAccess get_path contains an empty string when opened with compression. #70712

Closed
asolux opened this issue Dec 29, 2022 · 3 comments · Fixed by #70726
Closed

FileAccess get_path contains an empty string when opened with compression. #70712

asolux opened this issue Dec 29, 2022 · 3 comments · Fixed by #70726
Milestone

Comments

@asolux
Copy link

asolux commented Dec 29, 2022

Godot version

4.0.beta10

System information

Windows 10, 64bit

Issue description

The title says it all.
Opened in compression mode, whether read or write and whether the file already exists or not, get_path contains an empty string. This is also the case in C#.
However, if the file is opened without compression, get_path contains the absolute file path to the file as expected.
It doesn't matter whether an internal res:// path or an external system path is used.

Steps to reproduce

var file = FileAccess.open_compressed("res://file.txt", FileAccess.WRITE")
prints("get_path():", file.get_path())

output: get_path():

var file = FileAccess.open("res://file.txt", FileAccess.WRITE)
prints("get_path():", file.get_path())

output: get_path(): res://file.txt

or under C#:

using var file = FileAccess.OpenCompressed("res://test.txt", FileAccess.ModeFlags.Write);
GD.PrintS("GetPath():", file.GetPath());

output: GetPath():

Minimal reproduction project

N/A

@Calinou
Copy link
Member

Calinou commented Dec 29, 2022

Can you reproduce this in 3.5.1?

@asolux
Copy link
Author

asolux commented Dec 29, 2022

Yes, this also happens with 3.5.1, just tested. But also on Windows 10.

var file = File.new()
file.open_compressed("res://test.txt", File.WRITE)
prints("get_path():", file.get_path())

output get_path():

var file = File.new()
file.open("res://test.txt", File.WRITE)
prints("get_path():", file.get_path())

output: get_path(): res://test.txt

@heppocogne
Copy link
Contributor

heppocogne commented Dec 29, 2022

Here's Godot4 FileAccess::get_path() implementation:

virtual String get_path() const { return ""; } /// returns the path for the current open file

And this function is not overridden in FileAccessCompressed. I think that's why open_compressed always returns empty string.

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

Successfully merging a pull request may close this issue.

4 participants