Closed
Description
What problem does this solve or what need does it fill?
Assets which contain references to other assets should support relative paths. This enables an entire group of linked assets to be moved around the filesystem without breaking the relationship.
To facilitate this, I propose adding a method to AssetPath
which accepts a relative path string, and produces a new absolute path. Asset loaders can then use this method when resolving internal path references.
What solution would you like?
The resolve()
method would take a single argument, which is a relative path string. It produces a new path using self
as the base path, with the following rules:
- If the relative path starts with "#", then the new path consists of the base path with the label portion replaced. This is used for paths that point to other assets within the same file.
- If the relative path starts with "./" or "../", then the new path is computed relative to the directory of the asset path, using the standard path resolution rules. So if the base path is "a/b/c#d", and the relative path is "./x" then the new path is "a/b/x".
- If the relative path starts with any other character, it is treated as an absolute path.
What alternative(s) have you considered?
This can also be done as a standalone function, however it's a pretty handy function to have, and is small, so I thought it would make sense to add this to Bevy.