godot
godot copied to clipboard
Add custom paths support (custom `res://`/`user://`-like paths)
tl;dr
Enables custom resource paths that users can setup and use themselves.
# Maps a path to a custom path
FileAccess.map_path_to_custom_path("home", "/home/myself")
# (with or without the ://, it removes it automatically)
FileAccess.map_path_to_custom_path("home://", "/home/myself")
# Map classes (custom `FileAccess` and `DirAccess`) to custom path
FileAccess.map_classes_to_custom_path("cloud://", "CloudFileAccess", "CloudDirAccess")
# Removes a custom path
FileAccess.remove_custom_path("home")
# Checks if the prefix is supported
FileAccess.is_custom_path("home")
# Returns a dictionary containing the definition of the custom path
FileAccess.get_custom_path_data("home")
# Returns an array containing all the custom path prefixes
FileAccess.get_custom_paths()
Todo
- [ ] Write the documentation
Fixes
- Fix godotengine/godot-proposals#6307
- Closes godotengine/internal-team-priorities#92
This is big step (even if not directly) towards global addons 🥳 I like it
This is big step (even not directly) towards global addons 🥳
That's the goal!
Why do is_resource_path and get_resource_path(s) fail for res and user? I understand that adding/removing them is dangerous, so those erroring makes sense.
But the current handling of the getter methods are just exposing an implementation detail to the user. They should instead be a consistent API for "every virtual path *:// managed by Godot"...
But the current handling of the getter methods are just exposing an implementation detail to the user.
No, user:// and res:// are special cases handled differently. This PR is not about exposing an implementation detail, it's a feature in itself.
the pr is good. i used the pr, i think will need add prefix_dir options in "EditorFileDialog" and "FileDialog"
@adamscott Do you think it's possible to add memory based file system to this PR? A simple VFS so files can be used directly from memory like "memory://my_scene.tscn"
@adamscott Do you think it's possible to add memory based file system to this PR? A simple VFS so files can be used directly from memory like "memory://my_scene.tscn"
This clearly isn't in the scope of my PR.
@adamscott are you sure? it is in the scope of your PR's example usage, so i would say the answer is "already possible, no need to add anything".
FileAccess.map_classes_to_custom_path("cloud://", "CloudFileAccess", "CloudDirAccess")
@adamscott Do you think it's possible to add memory based file system to this PR? A simple VFS so files can be used directly from memory like "memory://my_scene.tscn"
This? #98287
Is there anything we can help with to bring the moment of merge of this PR closer?
Also if I'm correct this PR and https://github.com/godotengine/godot/pull/98544 are related.
Is there anything we can help with to bring the moment of merge of this PR closer?
Also if I'm correct this PR and #98544 are related.
They are not related; they simply implement the same proposal (https://github.com/godotengine/godot-proposals/issues/6307). This PR is based on the existing FileAccess & DirAccess, while #98544 opts to refactor the I/O system, replacing the current FileAccess & DirAccess.
I think it would be renamed to custom schemes. scheme://path
See also https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax