Still a nightmare, but better ig

This commit is contained in:
ClaraCrazy
2023-07-18 01:55:23 +02:00
parent 0ad2ab7dde
commit 0dbe874533
5 changed files with 12 additions and 59 deletions

View File

@@ -8,31 +8,15 @@ static void evil_portal_close_storage() {
furi_record_close(RECORD_STORAGE);
}
bool evil_portal_read_index_html(void* context) {
FuriString* file_path = furi_string_alloc();
DialogsFileBrowserOptions browser_options;
dialog_file_browser_set_basic_options(
&browser_options,
EVIL_PORTAL_INDEX_EXTENSION,
NULL); // TODO configure icon
browser_options.base_path = EVIL_PORTAL_BASE_FOLDER;
void evil_portal_read_index_html(void* context) {
Evil_PortalApp* app = context;
bool res = dialog_file_browser_show(app->dialogs, file_path, file_path, &browser_options);
if(!res) {
furi_string_free(file_path);
return false;
}
Storage* storage = evil_portal_open_storage();
FileInfo fi;
if(storage_common_stat(storage, furi_string_get_cstr(file_path), &fi) == FSE_OK) {
if(storage_common_stat(storage, EVIL_PORTAL_INDEX_SAVE_PATH, &fi) == FSE_OK) {
File* index_html = storage_file_alloc(storage);
if(storage_file_open(
index_html, furi_string_get_cstr(file_path), FSAM_READ, FSOM_OPEN_EXISTING)) {
index_html, EVIL_PORTAL_INDEX_SAVE_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
app->index_html = malloc((size_t)fi.size);
uint8_t* buf_ptr = app->index_html;
size_t read = 0;
@@ -45,7 +29,6 @@ bool evil_portal_read_index_html(void* context) {
}
free(buf_ptr);
}
furi_string_free(file_path);
storage_file_close(index_html);
storage_file_free(index_html);
} else {
@@ -57,7 +40,6 @@ bool evil_portal_read_index_html(void* context) {
}
evil_portal_close_storage();
return true;
}
void evil_portal_read_ap_name(void* context) {

View File

@@ -1,5 +1,4 @@
#include "../evil_portal_app_i.h"
#include <dialogs/dialogs.h>
#include <flipper_format/flipper_format_i.h>
#include <lib/toolbox/stream/file_stream.h>
#include <stdlib.h>
@@ -11,7 +10,7 @@
#define EVIL_PORTAL_AP_SAVE_PATH PORTAL_FILE_DIRECTORY_PATH "/ap.config.txt"
#define EVIL_PORTAL_LOG_SAVE_PATH PORTAL_FILE_DIRECTORY_PATH "/logs"
bool evil_portal_read_index_html(void* context);
void evil_portal_read_index_html(void* context);
void evil_portal_read_ap_name(void* context);
void write_logs(FuriString* portal_logs);
char* sequential_file_resolve_path(