@@ -6,17 +6,32 @@ static Storage *evil_portal_open_storage() {
6
6
7
7
static void evil_portal_close_storage () { furi_record_close (RECORD_STORAGE ); }
8
8
9
- void evil_portal_read_index_html (void * context ) {
9
+ bool evil_portal_read_index_html (void * context ) {
10
+ FuriString * file_path = furi_string_alloc ();
11
+
12
+ DialogsFileBrowserOptions browser_options ;
13
+ dialog_file_browser_set_basic_options (& browser_options ,
14
+ EVIL_PORTAL_INDEX_EXTENSION ,
15
+ NULL ); // TODO configure icon
16
+ browser_options .base_path = EVIL_PORTAL_BASE_FOLDER ;
10
17
11
18
Evil_PortalApp * app = context ;
19
+ bool res = dialog_file_browser_show (app -> dialogs , file_path , file_path ,
20
+ & browser_options );
21
+
22
+ if (!res ) {
23
+ furi_string_free (file_path );
24
+ return false;
25
+ }
26
+
12
27
Storage * storage = evil_portal_open_storage ();
13
28
FileInfo fi ;
14
29
15
- if (storage_common_stat (storage , EVIL_PORTAL_INDEX_SAVE_PATH , & fi ) ==
30
+ if (storage_common_stat (storage , furi_string_get_cstr ( file_path ) , & fi ) ==
16
31
FSE_OK ) {
17
32
File * index_html = storage_file_alloc (storage );
18
- if (storage_file_open (index_html , EVIL_PORTAL_INDEX_SAVE_PATH , FSAM_READ ,
19
- FSOM_OPEN_EXISTING )) {
33
+ if (storage_file_open (index_html , furi_string_get_cstr ( file_path ) ,
34
+ FSAM_READ , FSOM_OPEN_EXISTING )) {
20
35
app -> index_html = malloc ((size_t )fi .size );
21
36
uint8_t * buf_ptr = app -> index_html ;
22
37
size_t read = 0 ;
@@ -31,6 +46,7 @@ void evil_portal_read_index_html(void *context) {
31
46
}
32
47
free (buf_ptr );
33
48
}
49
+ furi_string_free (file_path );
34
50
storage_file_close (index_html );
35
51
storage_file_free (index_html );
36
52
} else {
@@ -43,6 +59,7 @@ void evil_portal_read_index_html(void *context) {
43
59
}
44
60
45
61
evil_portal_close_storage ();
62
+ return true;
46
63
}
47
64
48
65
void evil_portal_read_ap_name (void * context ) {
@@ -110,7 +127,8 @@ void write_logs(FuriString *portal_logs) {
110
127
File * file = storage_file_alloc (storage );
111
128
112
129
if (storage_file_open (file , seq_file_path , FSAM_WRITE , FSOM_CREATE_ALWAYS )) {
113
- storage_file_write (file , furi_string_get_cstr (portal_logs ), furi_string_utf8_length (portal_logs ));
130
+ storage_file_write (file , furi_string_get_cstr (portal_logs ),
131
+ furi_string_utf8_length (portal_logs ));
114
132
}
115
133
storage_file_close (file );
116
134
storage_file_free (file );
0 commit comments