-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
item.h
66 lines (55 loc) · 1.54 KB
/
item.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once
#include <m-array.h>
// Max length of a filename, final path element only
#define MAX_NAME_LEN 64
#define MAX_EXT_LEN 6
/** Defines an individual item action or item group. Each object contains
* the relevant file and type information needed to both render correctly
* on-screen as well as to perform that action.
*/
typedef enum {
Item_SubGhz,
Item_RFID,
Item_IR,
Item_NFC,
Item_iButton,
Item_Playlist,
Item_Group,
Item_Settings,
Item_Unknown,
Item_count
} ItemType;
typedef struct Item {
ItemType type;
FuriString* name;
FuriString* path;
char ext[MAX_EXT_LEN + 1];
} Item;
ARRAY_DEF(ItemArray, Item, M_POD_OPLIST);
typedef struct ItemsView {
FuriString* name;
FuriString* path;
ItemArray_t items;
} ItemsView;
/** Allocates and returns an ItemsView* which contains the list of
* items to display for the given path. Contains everything needed
* to render a scene_items.
*
* @param context App*
* @param path FuriString*
* @return ItemsView*
*/
ItemsView* item_get_items_view_from_path(void* context, const FuriString* path);
/** Free ItemsView
* @param items_view
*/
void item_items_view_free(ItemsView* items_view);
/** Prettify the name by removing a leading XX_, only if both X are digits,
* as well as replace all '_' with ' '.
* @param name FuriString*
*/
void item_prettify_name(FuriString* name);
/** Return the ItemType enum for the given extension
* @param ext File extension
*/
ItemType item_get_item_type_from_extension(const char* ext);