mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-24 22:07:14 +03:00
fac4391af7
* Toolbox: dir_walk concept (like os.walk) * Storage CLI: tree command * Storage: fix folders copying, stage 1 * UnitTest: proper delays in subghz tests * Toolbox: dir_walk, recursive and filter options * dir_walk: unit tests * Merge: Fix unused param * SubGhz: cleaned up data parsing routine * SubGhz unit test: cleaned up logs, yield data load * SubGhz unit test: naming Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
79 lines
1.5 KiB
C
79 lines
1.5 KiB
C
#pragma once
|
|
#include <storage/storage.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct DirWalk DirWalk;
|
|
|
|
typedef enum {
|
|
DirWalkOK, /**< OK */
|
|
DirWalkError, /**< Error */
|
|
DirWalkLast, /**< Last element */
|
|
} DirWalkResult;
|
|
|
|
typedef bool (*DirWalkFilterCb)(const char* name, FileInfo* fileinfo, void* ctx);
|
|
|
|
/**
|
|
* Allocate DirWalk
|
|
* @param storage
|
|
* @return DirWalk*
|
|
*/
|
|
DirWalk* dir_walk_alloc(Storage* storage);
|
|
|
|
/**
|
|
* Free DirWalk
|
|
* @param dir_walk
|
|
*/
|
|
void dir_walk_free(DirWalk* dir_walk);
|
|
|
|
/**
|
|
* Set recursive mode (true by default)
|
|
* @param dir_walk
|
|
* @param recursive
|
|
*/
|
|
void dir_walk_set_recursive(DirWalk* dir_walk, bool recursive);
|
|
|
|
/**
|
|
* Set filter callback (Should return true if the data is valid)
|
|
* @param dir_walk
|
|
* @param cb
|
|
* @param context
|
|
*/
|
|
void dir_walk_set_filter_cb(DirWalk* dir_walk, DirWalkFilterCb cb, void* context);
|
|
|
|
/**
|
|
* Open directory
|
|
* @param dir_walk
|
|
* @param path
|
|
* @return true
|
|
* @return false
|
|
*/
|
|
bool dir_walk_open(DirWalk* dir_walk, const char* path);
|
|
|
|
/**
|
|
* Get error id
|
|
* @param dir_walk
|
|
* @return FS_Error
|
|
*/
|
|
FS_Error dir_walk_get_error(DirWalk* dir_walk);
|
|
|
|
/**
|
|
* Read next element from directory
|
|
* @param dir_walk
|
|
* @param return_path
|
|
* @param fileinfo
|
|
* @return DirWalkResult
|
|
*/
|
|
DirWalkResult dir_walk_read(DirWalk* dir_walk, string_t return_path, FileInfo* fileinfo);
|
|
|
|
/**
|
|
* Close directory
|
|
* @param dir_walk
|
|
*/
|
|
void dir_walk_close(DirWalk* dir_walk);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif |