-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Fix get_base_dir windows top level directory logic #52049
Conversation
I think this pull request at the time of writing introduces a new bug: |
e744b13
to
62c9a82
Compare
This is a fix for godotengine#52048
The new tests cover: - A file with empty extension. - A file with only extension (a "hidden" file, unix style). - A file directly at the windows top level directory. - A file directly at the unix root directory. - A file directly at the res:// base directory.
Added new test cases. They pass on my machine. |
Thanks! And congrats for your first merged Godot contribution 🎉 |
I opened a pull request for the 3.x branch (I had not noticed the file ustring.cpp was in a different path, which prevent cherrypicking it). |
FYI, Git can handle file renames fine when cherry-picking, as long as the files are still sensibly similar:
But now that you made a PR, let's use that. |
This is a fix for #52048
If we look at the diff for cddff04 we observe that before it was looking for a
3
character string ("://"
), and now it is looking for a2
character string (either":/"
or":\\"
).Edit: Updating the use of
substr
accordingly fixes windows top level directories (e.g."C:\\puff"
) but breaks Godot paths (e.g."res://puff"
). Also, it is worth noting that the code already has an special case for the unix root directory ("/"
). Thus, we need to handle:"://"
(3
characters).":\
(2
characters).":/"
(2
characters)."/"
at the start (1
character).And we need to be careful with order in which we check because
"://"
contains":/"
.This code demonstrate the change:
Before cddff04 (tested in Godot 3.2.3) the output is:
After cddff04 (tested in Godot 3.3.3) the output is:
With this PR (tested in custom build of Godot 4.0) the output is:
Bugsquad edit: Fixes #52048.