feat(api): add resolveResource API to the path module (#4234)

This commit is contained in:
Lucas Fernandes Nogueira 2022-05-29 10:35:35 -07:00 committed by GitHub
parent 3f998ca294
commit 7bba8db83e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
"api": patch
---
Added the `resolveResource` API to the path module.

File diff suppressed because one or more lines are too long

View File

@ -331,7 +331,8 @@ async function publicDir(): Promise<string> {
}
/**
* Returns the path to the user's resource directory.
* Returns the path to the application's resource directory.
* To resolve a resource path, see the [[resolveResource | `resolveResource API`]].
*
* @returns
*/
@ -346,6 +347,24 @@ async function resourceDir(): Promise<string> {
})
}
/**
* Resolve the path to a resource file.
*
* @param resourcePath The path to the resource.
* Must follow the same syntax as defined in `tauri.conf.json > tauri > bundle > resources`, i.e. keeping subfolders and parent dir components (`../`).
* @returns The full path to the resource.
*/
async function resolveResource(resourcePath: string): Promise<string> {
return invokeTauriCommand<string>({
__tauriModule: 'Path',
message: {
cmd: 'resolvePath',
path: resourcePath,
directory: BaseDirectory.Resource
}
})
}
/**
* Returns the path to the user's runtime directory.
*
@ -559,6 +578,7 @@ export {
pictureDir,
publicDir,
resourceDir,
resolveResource,
runtimeDir,
templateDir,
videoDir,