add llfs_get_filename_ext
This commit is contained in:
2023-12-02 23:01:06 +01:00
parent d0fb9c5856
commit 0cc34bfd6b
3 changed files with 38 additions and 0 deletions

View File

@@ -83,4 +83,11 @@ llfs_file_t* llfs_next_file(void** mem, char* filter);
*/
size_t llfs_file_count(void);
/**
* @brief This function returns the extension of a file
* @param[in] filename The filename to get the extension from
* @return char* The extension of the file
*/
char* llfs_get_filename_ext(char* filename);
#endif // LLFS_H

View File

@@ -141,6 +141,13 @@ size_t llfs_file_count(void) {
return file_count;
}
char* llfs_get_filename_ext(char* filename) {
char* dot = strrchr(filename, '.');
if (dot == NULL || dot == filename)
return NULL;
return dot + 1;
}
#ifndef TESTING
/**
* @brief Newlib open implementation