-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Add FileSystem & FIleSystemProtocol to allow custom path prefixes (custom://) #98544
Draft
TML233
wants to merge
36
commits into
godotengine:master
Choose a base branch
from
TML233:filesystem
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,345
−961
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TML233
changed the title
Add FileSystem & FIleSystemProtocol
Add FileSystem & FIleSystemProtocol to allow custom path prefixes (custom://)
Oct 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes godotengine/godot-proposals#11032
closes godotengine/godot-proposals#6307
This PR is a refactor of the Godot FileAccess system. It adds FileSystem and FileSystemProtocol to manage file path prefixes.
FileAccess access type and create_funcs are removed now. Different FileAccess types only deals with their targeted file source now, which means different platform's OS FileAccess now only handles paths that are in the os filesystem. They don't need to handle res:// user:// anymore, in fact, they don't even know about other protocols now. Platforms now implement their own OS protocol and OS FileAccess and register the os protocol to the FileSystem.
Current-file-unrelated and current-directory-unrelated methods like
file_exists(path)
andget_modified_time(path)
are also moved to FileSystemProtocol. The original implementation instantiates a FileAccess, calls the method and immediately throws it away. This change can theoretically improve the performance with simple file operations.DirAccess can be a simple wrapper of FileSystemProtocol.
By pre-defining some FileAccessProtocols that remaps paths, users can easily register a protocol prefix that remaps file paths.
Issues
(Fixed) gdscript://
Solution
As far as I can tell,
gdscript://object_id.gd
represents a gdscript instance in memory.To prevent stepping in old code, gdscript protocol is reserved. It fails all accesses silently.
Descripton
Introduced by #71197
This is the reason that GDScript test fails. It expects hardcoded console output. During the test, GDScript system requires a resource load for the file path prefixed
gdscript://
, which would silently fail and return false in the old FileAccess implementation. But in FileSystem, an error message ofUnknown filesystem protocol gdscript
generates, thus failing the test.I don't think muting the error message is a good approach, if anyone adds a gdscript protocol, GDScript system would break because of this.
Todo
FileSystem
&FileSystemProtocol
FileAccess
toFileSystemProtocol
globalize_path
DirAccess
toFileSystemProtocol
Move hard-coded protocols to FileSystemProtocol
os://
andpipe://
are implemented and registered by different OS platforms.res://
user://
uid://
mem://
if Cleanup and exposeFileAccessMemory
. #98287 is mergedPlatform supports
Create
FileSystemProtocolOS
andFileSystemProtocolPipe
.Cleanup
FileAccessPlatform
andFileAccessPlatformPipe
.Add
OS_Platform::initialize_filesystem()
.Remove previous
FileAccess::make_default
calls fromOS_Platform::initialize()
Future Tasks
FileAccessProtocolRemap