Skip to content

Commit bb70156

Browse files
committed
Merge branch 'dev' into feature/lfrfid_hid_37_bit
* dev: IR: increase raw timings amount (flipperdevices#1388) Change # to ! for the inverted text example (flipperdevices#1395) [FL-2633] Move files from /int to /ext on SD mount flipperdevices#1384 [FL-2554] Embedded arm-none-eabi toolchain (flipperdevices#1351)
2 parents e4f66ea + 6ac1ed2 commit bb70156

29 files changed

+878
-36
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
* text=auto eol=lf
2+
*.bat eol=crlf
3+
*.ps1 eol=crlf
4+
*.cmd eol=crlf

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ dist
4646
build/
4747

4848
# Toolchain
49-
toolchain*/
49+
/toolchain
50+
51+
# openocd output file
52+
openocd.log

SConstruct

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import os
1010

11+
EnsurePythonVersion(3, 8)
12+
1113
DefaultEnvironment(tools=[])
1214
# Progress(["OwO\r", "owo\r", "uwu\r", "owo\r"], interval=15)
1315

@@ -32,7 +34,7 @@ coreenv["ROOT_DIR"] = Dir(".")
3234
# Create a separate "dist" environment and add construction envs to it
3335
distenv = coreenv.Clone(
3436
tools=["fbt_dist", "openocd", "blackmagic"],
35-
OPENOCD_GDB_PIPE=["|openocd -c 'gdb_port pipe' ${[SINGLEQUOTEFUNC(OPENOCD_OPTS)]}"],
37+
OPENOCD_GDB_PIPE=["|openocd -c 'gdb_port pipe; log_output debug/openocd.log' ${[SINGLEQUOTEFUNC(OPENOCD_OPTS)]}"],
3638
GDBOPTS_BASE=[
3739
"-ex",
3840
"target extended-remote ${GDBREMOTE}",

applications/about/about.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,4 @@ int32_t about_settings_app(void* p) {
206206
furi_record_close("gui");
207207

208208
return 0;
209-
}
209+
}

applications/extapps.scons

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Import("ENV")
33

44
from fbt.appmanifest import FlipperAppType
55

6-
76
appenv = ENV.Clone(tools=["fbt_extapps"])
87

98
appenv.Replace(

applications/gui/elements.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void elements_string_fit_width(Canvas* canvas, string_t string, uint8_t width);
204204
* @param[in] text Formatted text. The following formats are available:
205205
* "\e#Bold text\e#" - bold font is used
206206
* "\e*Monospaced text\e*" - monospaced font is used
207-
* "\e#Inversed text\e#" - white text on black background
207+
* "\e!Inversed text\e!" - white text on black background
208208
* @param strip_to_dots Strip text to ... if does not fit to width
209209
*/
210210
void elements_text_box(

applications/storage/storage.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ FS_Error storage_common_rename(Storage* storage, const char* old_path, const cha
190190
*/
191191
FS_Error storage_common_copy(Storage* storage, const char* old_path, const char* new_path);
192192

193+
/** Copy one folder contents into another with rename of all conflicting files
194+
* @param app pointer to the api
195+
* @param old_path old path
196+
* @param new_path new path
197+
* @return FS_Error operation result
198+
*/
199+
FS_Error storage_common_merge(Storage* storage, const char* old_path, const char* new_path);
200+
193201
/** Creates a directory
194202
* @param app pointer to the api
195203
* @param path directory path

applications/storage/storage_external_api.c

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
#include "furi/log.h"
12
#include <furi/record.h>
23
#include <m-string.h>
34
#include "storage.h"
45
#include "storage_i.h"
56
#include "storage_message.h"
67
#include <toolbox/stream/file_stream.h>
78
#include <toolbox/dir_walk.h>
9+
#include "toolbox/path.h"
810

911
#define MAX_NAME_LENGTH 256
12+
#define MAX_EXT_LEN 16
1013

1114
#define TAG "StorageAPI"
1215

@@ -436,6 +439,131 @@ FS_Error storage_common_copy(Storage* storage, const char* old_path, const char*
436439
return error;
437440
}
438441

442+
static FS_Error
443+
storage_merge_recursive(Storage* storage, const char* old_path, const char* new_path) {
444+
FS_Error error = storage_common_mkdir(storage, new_path);
445+
DirWalk* dir_walk = dir_walk_alloc(storage);
446+
string_t path;
447+
string_t tmp_new_path;
448+
string_t tmp_old_path;
449+
FileInfo fileinfo;
450+
string_init(path);
451+
string_init(tmp_new_path);
452+
string_init(tmp_old_path);
453+
454+
do {
455+
if((error != FSE_OK) && (error != FSE_EXIST)) break;
456+
457+
if(!dir_walk_open(dir_walk, old_path)) {
458+
error = dir_walk_get_error(dir_walk);
459+
break;
460+
}
461+
462+
while(1) {
463+
DirWalkResult res = dir_walk_read(dir_walk, path, &fileinfo);
464+
465+
if(res == DirWalkError) {
466+
error = dir_walk_get_error(dir_walk);
467+
break;
468+
} else if(res == DirWalkLast) {
469+
break;
470+
} else {
471+
string_set(tmp_old_path, path);
472+
string_right(path, strlen(old_path));
473+
string_printf(tmp_new_path, "%s%s", new_path, string_get_cstr(path));
474+
475+
if(fileinfo.flags & FSF_DIRECTORY) {
476+
if(storage_common_stat(storage, string_get_cstr(tmp_new_path), &fileinfo) ==
477+
FSE_OK) {
478+
if(fileinfo.flags & FSF_DIRECTORY) {
479+
error = storage_common_mkdir(storage, string_get_cstr(tmp_new_path));
480+
}
481+
}
482+
} else {
483+
error = storage_common_merge(
484+
storage, string_get_cstr(tmp_old_path), string_get_cstr(tmp_new_path));
485+
}
486+
487+
if(error != FSE_OK) break;
488+
}
489+
}
490+
491+
} while(false);
492+
493+
string_clear(tmp_new_path);
494+
string_clear(tmp_old_path);
495+
string_clear(path);
496+
dir_walk_free(dir_walk);
497+
return error;
498+
}
499+
500+
FS_Error storage_common_merge(Storage* storage, const char* old_path, const char* new_path) {
501+
FS_Error error;
502+
const char* new_path_tmp;
503+
string_t new_path_next;
504+
string_init(new_path_next);
505+
506+
FileInfo fileinfo;
507+
error = storage_common_stat(storage, old_path, &fileinfo);
508+
509+
if(error == FSE_OK) {
510+
if(fileinfo.flags & FSF_DIRECTORY) {
511+
error = storage_merge_recursive(storage, old_path, new_path);
512+
} else {
513+
error = storage_common_stat(storage, new_path, &fileinfo);
514+
if(error == FSE_OK) {
515+
string_set_str(new_path_next, new_path);
516+
string_t dir_path;
517+
string_t filename;
518+
char extension[MAX_EXT_LEN];
519+
520+
string_init(dir_path);
521+
string_init(filename);
522+
523+
path_extract_filename(new_path_next, filename, true);
524+
path_extract_dirname(new_path, dir_path);
525+
path_extract_extension(new_path_next, extension, MAX_EXT_LEN);
526+
527+
storage_get_next_filename(
528+
storage,
529+
string_get_cstr(dir_path),
530+
string_get_cstr(filename),
531+
extension,
532+
new_path_next,
533+
255);
534+
string_cat_printf(dir_path, "/%s%s", string_get_cstr(new_path_next), extension);
535+
string_set(new_path_next, dir_path);
536+
537+
string_clear(dir_path);
538+
string_clear(filename);
539+
new_path_tmp = string_get_cstr(new_path_next);
540+
} else {
541+
new_path_tmp = new_path;
542+
}
543+
Stream* stream_from = file_stream_alloc(storage);
544+
Stream* stream_to = file_stream_alloc(storage);
545+
546+
do {
547+
if(!file_stream_open(stream_from, old_path, FSAM_READ, FSOM_OPEN_EXISTING)) break;
548+
if(!file_stream_open(stream_to, new_path_tmp, FSAM_WRITE, FSOM_CREATE_NEW)) break;
549+
stream_copy_full(stream_from, stream_to);
550+
} while(false);
551+
552+
error = file_stream_get_error(stream_from);
553+
if(error == FSE_OK) {
554+
error = file_stream_get_error(stream_to);
555+
}
556+
557+
stream_free(stream_from);
558+
stream_free(stream_to);
559+
}
560+
}
561+
562+
string_clear(new_path_next);
563+
564+
return error;
565+
}
566+
439567
FS_Error storage_common_mkdir(Storage* storage, const char* path) {
440568
S_API_PROLOGUE;
441569
S_API_DATA_PATH;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
App(
2+
appid="storage_move_to_sd",
3+
name="StorageMoveToSd",
4+
apptype=FlipperAppType.SYSTEM,
5+
entry_point="storage_move_to_sd_app",
6+
requires=["gui","storage"],
7+
provides=["storage_move_to_sd_start"],
8+
stack_size=2 * 1024,
9+
order=30,
10+
)
11+
12+
App(
13+
appid="storage_move_to_sd_start",
14+
apptype=FlipperAppType.STARTUP,
15+
entry_point="storage_move_to_sd_start",
16+
requires=["storage"],
17+
order=120,
18+
)
19+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "storage_move_to_sd_scene.h"
2+
3+
// Generate scene on_enter handlers array
4+
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
5+
void (*const storage_move_to_sd_on_enter_handlers[])(void*) = {
6+
#include "storage_move_to_sd_scene_config.h"
7+
};
8+
#undef ADD_SCENE
9+
10+
// Generate scene on_event handlers array
11+
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
12+
bool (*const storage_move_to_sd_on_event_handlers[])(void* context, SceneManagerEvent event) = {
13+
#include "storage_move_to_sd_scene_config.h"
14+
};
15+
#undef ADD_SCENE
16+
17+
// Generate scene on_exit handlers array
18+
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
19+
void (*const storage_move_to_sd_on_exit_handlers[])(void* context) = {
20+
#include "storage_move_to_sd_scene_config.h"
21+
};
22+
#undef ADD_SCENE
23+
24+
// Initialize scene handlers configuration structure
25+
const SceneManagerHandlers storage_move_to_sd_scene_handlers = {
26+
.on_enter_handlers = storage_move_to_sd_on_enter_handlers,
27+
.on_event_handlers = storage_move_to_sd_on_event_handlers,
28+
.on_exit_handlers = storage_move_to_sd_on_exit_handlers,
29+
.scene_num = StorageMoveToSdSceneNum,
30+
};

0 commit comments

Comments
 (0)