Skip to content

Commit 3ad981c

Browse files
committed
Fix filename not displayed
1 parent 011a9b9 commit 3ad981c

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

mag_device.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,14 @@ bool mag_device_save(MagDevice* mag_dev, const char* dev_name) {
118118
return mag_device_save_file(mag_dev, dev_name, MAG_APP_FOLDER, MAG_APP_EXTENSION, true);
119119
}
120120

121-
static bool mag_device_load_data(MagDevice* mag_dev, FuriString* path, bool show_dialog) {
121+
bool mag_device_load_data(MagDevice* mag_dev, FuriString* path, bool show_dialog) {
122122
bool parsed = false;
123123

124+
FuriString* filename;
125+
filename = furi_string_alloc();
126+
path_extract_filename(path, filename, true);
127+
strncpy(mag_dev->dev_name, furi_string_get_cstr(filename), MAG_DEV_NAME_MAX_LEN);
128+
124129
FlipperFormat* file = flipper_format_file_alloc(mag_dev->storage);
125130
FuriString* temp_str;
126131
temp_str = furi_string_alloc();
@@ -168,6 +173,7 @@ static bool mag_device_load_data(MagDevice* mag_dev, FuriString* path, bool show
168173
}
169174

170175
furi_string_free(temp_str);
176+
furi_string_free(filename);
171177
flipper_format_free(file);
172178

173179
return parsed;
@@ -189,15 +195,10 @@ bool mag_file_select(MagDevice* mag_dev) {
189195

190196
furi_string_free(mag_app_folder);
191197
if(res) {
192-
FuriString* filename;
193-
filename = furi_string_alloc();
194-
path_extract_filename(mag_dev->load_path, filename, true);
195-
strncpy(mag_dev->dev_name, furi_string_get_cstr(filename), MAG_DEV_NAME_MAX_LEN);
196198
res = mag_device_load_data(mag_dev, mag_dev->load_path, true);
197199
if(res) {
198200
mag_device_set_name(mag_dev, mag_dev->dev_name);
199201
}
200-
furi_string_free(filename);
201202
}
202203

203204
return res;

mag_device.h

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ void mag_device_set_name(MagDevice* mag_dev, const char* name);
4444

4545
bool mag_device_save(MagDevice* mag_dev, const char* dev_name);
4646

47+
bool mag_device_load_data(MagDevice* mag_dev, FuriString* path, bool show_dialog);
48+
4749
bool mag_file_select(MagDevice* mag_dev);
4850

4951
void mag_device_data_clear(MagDeviceData* dev_data);

0 commit comments

Comments
 (0)