Skip to content

Conversation

@adamscott
Copy link
Member

@adamscott adamscott commented Jan 25, 2024

Capture d’écran du 2024-01-25 09-45-02_2

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

@adamscott adamscott requested a review from a team as a code owner January 25, 2024 15:43
@adamscott adamscott requested a review from reduz January 25, 2024 15:45
@YuriSizov YuriSizov added this to the 4.x milestone Jan 25, 2024
@arkology
Copy link
Contributor

arkology commented Jan 25, 2024

This is big step (even if not directly) towards global addons 🥳
I like it

@adamscott
Copy link
Member Author

This is big step (even not directly) towards global addons 🥳

That's the goal!

@adamscott adamscott force-pushed the custom-resource-path branch from e203b1d to cd0682f Compare January 25, 2024 17:01
@adamscott adamscott requested a review from a team as a code owner January 25, 2024 17:01
@RedMser
Copy link
Contributor

RedMser commented Jan 25, 2024

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"...

@adamscott
Copy link
Member Author

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.

@adamscott adamscott marked this pull request as draft January 25, 2024 22:47
@adamscott adamscott force-pushed the custom-resource-path branch 2 times, most recently from 23fb612 to 9163707 Compare January 25, 2024 22:52
@adamscott adamscott changed the title Add custom file-based resource paths Add custom resource paths Jan 25, 2024
@adamscott adamscott force-pushed the custom-resource-path branch 4 times, most recently from cd9eb41 to aa56d1c Compare February 2, 2024 17:59
@adamscott adamscott changed the title Add custom resource paths Add custom paths support (custom res:///user://-like paths) Feb 2, 2024
@adamscott adamscott force-pushed the custom-resource-path branch 2 times, most recently from f908b8d to c136ceb Compare February 7, 2024 12:58
@adamscott adamscott force-pushed the custom-resource-path branch from 9f8d1e2 to 10d5197 Compare February 12, 2024 16:28
@adamscott adamscott force-pushed the custom-resource-path branch from 10d5197 to 6545edc Compare February 28, 2024 16:54
@zedrun00
Copy link

the pr is good.
i used the pr, i think will need add prefix_dir options in "EditorFileDialog" and "FileDialog"

@CycloneRing
Copy link
Contributor

@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
Copy link
Member Author

@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.

@nonchip
Copy link

nonchip commented Oct 15, 2024

@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")

@scgm0
Copy link
Contributor

scgm0 commented Oct 22, 2024

@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

@arkology
Copy link
Contributor

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.

@scgm0
Copy link
Contributor

scgm0 commented Mar 12, 2025

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 (godotengine/godot-proposals#6307). This PR is based on the existing FileAccess & DirAccess, while #98544 opts to refactor the I/O system, replacing the current FileAccess & DirAccess.

@markushonok
Copy link

markushonok commented Oct 16, 2025

I think it would be renamed to custom schemes. scheme://path
See also https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement custom resource path support