Util

Util

Functions

va_string* va_resolve_file_url(const va_string* path)

Function Documentation

va_string* va_resolve_file_url(const va_string* path)

Converts a resource file URL to an absolute path. Resource file URLs are used as system-independent identifiers for files inside components such as apps and tool libraries. A resource URL starts with a "res://" scheme and is followed by a component's ID, including the major version number.

If the URL cannot be resolved, this function returns NULL. Note that the file may not exist even if its path was successfully resolved.

// Refer to a file in an installed component.
"res://com.example.component/1/data.dat");
int len = va_string_utf8_length(path);
char* fileName = (char*)malloc(len);
va_string_to_utf8(path, fileName, len);
FILE* fp = fopen(fileName, "r");
// Check and use fp ...
fclose(fp);
free(fileName);