#include <stdint.h>
#include <stdlib.h>
#include "littlefs/lfs.h"
Go to the source code of this file.
|
| int32_t | LFS_search_count_occurrences (const char *filename, const uint8_t *needle, size_t needle_len) |
| | Count the number of occurrences of a string/byte pattern in an LFS file.
|
| int32_t | LFS_search_find_nth_occurrence (const char *filename, const uint8_t *needle, size_t needle_len, uint16_t n, lfs_soff_t *out_offset) |
| | Find the byte offset of the nth occurrence of a string/byte pattern in an LFS file.
|
◆ LFS_search_count_occurrences()
| int32_t LFS_search_count_occurrences |
( |
const char * | filename, |
|
|
const uint8_t * | needle, |
|
|
size_t | needle_len ) |
Count the number of occurrences of a string/byte pattern in an LFS file.
- Parameters
-
| filename | File name/path of the "haystack" file to open and search within. |
| needle | Pattern to search for. |
| needle_len | Length of pattern to search for. |
- Returns
- The number of matches. 0 if no matches. Negative LFS error code on error.
◆ LFS_search_find_nth_occurrence()
| int32_t LFS_search_find_nth_occurrence |
( |
const char * | filename, |
|
|
const uint8_t * | needle, |
|
|
size_t | needle_len, |
|
|
uint16_t | n, |
|
|
lfs_soff_t * | out_offset ) |
Find the byte offset of the nth occurrence of a string/byte pattern in an LFS file.
- Parameters
-
| lfs | Filesystem. |
| filename | File name/path of the "haystack" file to open and search within. |
| needle | Pattern to search for. |
| needle_len | Length of pattern to search for. |
| n | Nth occurrence to find. |
| out_offset | Pointer to store the byte offset of the found occurrence. |
- Returns
- 0 on success, or a negative LFS error code, or a positive error code indicating a problem in function. Returns 1 if invalid arguments. Returns 3 if needle not found.