mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-20 04:54:45 -07:00
Update WifI marauder app
https://github.com/0xchocolate/flipperzero-firmware-with-wifi-marauder-companion/pull/11
This commit is contained in:
46
applications/external/wifi_marauder_companion/file/sequential_file.c
vendored
Normal file
46
applications/external/wifi_marauder_companion/file/sequential_file.c
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "sequential_file.h"
|
||||
|
||||
char* sequential_file_resolve_path(
|
||||
Storage* storage,
|
||||
const char* dir,
|
||||
const char* prefix,
|
||||
const char* extension) {
|
||||
if(storage == NULL || dir == NULL || prefix == NULL || extension == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char file_path[256];
|
||||
int file_index = 0;
|
||||
|
||||
do {
|
||||
if(snprintf(
|
||||
file_path, sizeof(file_path), "%s/%s_%d.%s", dir, prefix, file_index, extension) <
|
||||
0) {
|
||||
return NULL;
|
||||
}
|
||||
file_index++;
|
||||
} while(storage_file_exists(storage, file_path));
|
||||
|
||||
return strdup(file_path);
|
||||
}
|
||||
|
||||
bool sequential_file_open(
|
||||
Storage* storage,
|
||||
File* file,
|
||||
const char* dir,
|
||||
const char* prefix,
|
||||
const char* extension) {
|
||||
if(storage == NULL || file == NULL || dir == NULL || prefix == NULL || extension == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char* file_path = sequential_file_resolve_path(storage, dir, prefix, extension);
|
||||
if(file_path == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool success = storage_file_open(file, file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS);
|
||||
free(file_path);
|
||||
|
||||
return success;
|
||||
}
|
||||
Reference in New Issue
Block a user