PebbleOS
Loading...
Searching...
No Matches
Macros | Functions
App files

Consistent naming of per-app files. More...

Macros

#define APP_FILE_NAME_PREFIX_LENGTH   (10)
 Length of the @XXXXXXXX/ prefix; the suffix starts at this offset.
 

Functions

void app_file_name_make (char *restrict buffer, size_t buffer_len, AppInstallId app_id, const char *restrict suffix, size_t suffix_len)
 Make an app file name.
 
bool is_app_file_name (const char *filename)
 Check whether a file name is an app file name.
 
bool is_app_resource_file_name (const char *filename)
 Check whether a file name is an app resource file name (suffix "res").
 
AppInstallId app_file_parse_app_id (const char *filename)
 Get the app install id from an app file name, without validating it.
 
AppInstallId app_file_get_app_id (const char *filename)
 Get the app install id from a file name.
 

Detailed Description

Consistent naming of per-app files.

Files belonging to an app are named with a fixed-length prefix derived from its AppInstallId, forming a pseudo-directory: printf("@%08x/%s", (uint32_t)app_id, suffix) with lowercase hex digits. The fixed length keeps the prefix simple to generate, parse and identify.

Macro Definition Documentation

◆ APP_FILE_NAME_PREFIX_LENGTH

#define APP_FILE_NAME_PREFIX_LENGTH   (10)

Length of the @XXXXXXXX/ prefix; the suffix starts at this offset.

Function Documentation

◆ app_file_get_app_id()

AppInstallId app_file_get_app_id ( const char *  filename)

Get the app install id from a file name.

Parameters
filenameFile name.
Returns
App install id, or INSTALL_ID_INVALID if filename is not an app file name.

◆ app_file_name_make()

void app_file_name_make ( char *restrict  buffer,
size_t  buffer_len,
AppInstallId  app_id,
const char *restrict  suffix,
size_t  suffix_len 
)

Make an app file name.

Parameters
[out]bufferBuffer to write the NUL-terminated file name into.
buffer_lenSize of buffer in bytes, greater than APP_FILE_NAME_PREFIX_LENGTH + suffix_len (asserted).
app_idApp install id.
suffixSuffix string.
suffix_lenLength of suffix, without the NUL terminator.

◆ app_file_parse_app_id()

AppInstallId app_file_parse_app_id ( const char *  filename)

Get the app install id from an app file name, without validating it.

Parameters
filenameApp file name.
Returns
App install id.

◆ is_app_file_name()

bool is_app_file_name ( const char *  filename)

Check whether a file name is an app file name.

Parameters
filenameFile name.
Returns
true if it has a valid app file prefix followed by a non-empty suffix.

◆ is_app_resource_file_name()

bool is_app_resource_file_name ( const char *  filename)

Check whether a file name is an app resource file name (suffix "res").

Parameters
filenameFile name.
Returns
true for app resource files.