Kestrel Interface
Loading...
Searching...
No Matches
kest_files.c File Reference
#include <sys/unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#include "kest_int.h"

Go to the source code of this file.

Macros

#define PRINTLINES_ALLOWED   0
#define IO_BUFFER_SIZE   128
#define write_byte(x)
#define write_short(x)
#define write_int32(x)
#define write_uint32(x)
#define write_float(x)
#define write_string(x)
#define read_byte(x)
#define read_short(x)
#define read_int32(x)
#define read_uint32(x)
#define read_float(x)
#define read_string()
#define read_and_strndup_string(x)
#define FNAME_DIGITS   4

Functions

void dump_file_contents (char *fname)
int file_validity_check (FILE *file, uint8_t magic_byte, uint8_t *byte_out)
int save_profile_as_file (kest_profile *profile, const char *fname)
int save_sequence_as_file (kest_sequence *sequence, const char *fname)
int save_state_to_file (kest_state *state, const char *fname)
int load_state_from_file (kest_state *state, const char *fname)
int read_profile_from_file (kest_profile *profile, const char *fname)
int read_sequence_from_file (kest_sequence *sequence, const char *fname)
int kest_init_directories ()
int safe_file_write (int(*write_func)(void *arg, const char *fname), void *arg, const char *fname)
int save_profile_as_file_safe (kest_profile *profile, const char *fname)
void generate_filename (char *prefix, char *suffix, char *dest)
int save_profile (kest_profile *profile)
int save_sequence (kest_sequence *sequence)
int load_saved_profiles (kest_context *cxt)
int load_saved_sequences (kest_context *cxt)
int load_effects (kest_context *cxt)
string_lllist_files_in_directory (char *dir)
void erase_sd_card_void_cb (void *data)
int erase_folder (const char *dir)
void erase_sd_card ()
int fnames_agree (char *a, char *b)

Macro Definition Documentation

◆ FNAME_DIGITS

#define FNAME_DIGITS   4

Definition at line 831 of file kest_files.c.

Referenced by generate_filename().

◆ IO_BUFFER_SIZE

#define IO_BUFFER_SIZE   128

◆ PRINTLINES_ALLOWED

#define PRINTLINES_ALLOWED   0

Definition at line 8 of file kest_files.c.

◆ read_and_strndup_string

#define read_and_strndup_string ( x)
Value:
do {\
for (int i = 0; i < IO_BUFFER_SIZE; i++)\
{\
string_read_buffer[i] = fgetc(file);\
if (!string_read_buffer[i])\
break;\
}\
x = kest_strndup(string_read_buffer, IO_BUFFER_SIZE);\
} while (0);
char * kest_strndup(const char *str, size_t n)
Definition kest_alloc.c:73
#define IO_BUFFER_SIZE
Definition kest_files.c:13

Definition at line 37 of file kest_files.c.

Referenced by read_profile_from_file(), and read_sequence_from_file().

◆ read_byte

#define read_byte ( x)
Value:
x = fgetc(file);

Definition at line 23 of file kest_files.c.

Referenced by file_validity_check().

◆ read_float

#define read_float ( x)
Value:
fread(&x, sizeof(float), 1, file);

Definition at line 27 of file kest_files.c.

Referenced by read_profile_from_file().

◆ read_int32

#define read_int32 ( x)
Value:
fread(&x, sizeof(int32_t), 1, file);

Definition at line 25 of file kest_files.c.

◆ read_short

#define read_short ( x)
Value:
fread(&x, sizeof(uint16_t), 1, file);

Definition at line 24 of file kest_files.c.

Referenced by read_profile_from_file(), and read_sequence_from_file().

◆ read_string

#define read_string ( )
Value:
do {\
for (int i = 0; i < IO_BUFFER_SIZE; i++)\
{\
string_read_buffer[i] = fgetc(file);\
if (!string_read_buffer[i])\
break;\
}\
} while (0);

Definition at line 28 of file kest_files.c.

Referenced by read_profile_from_file(), and read_sequence_from_file().

◆ read_uint32

#define read_uint32 ( x)
Value:
fread(&x, sizeof(uint32_t), 1, file);

Definition at line 26 of file kest_files.c.

◆ write_byte

#define write_byte ( x)
Value:
fputc(x, file);

Definition at line 15 of file kest_files.c.

Referenced by save_profile_as_file(), save_sequence_as_file(), and save_state_to_file().

◆ write_float

#define write_float ( x)
Value:
fwrite(&x, sizeof(float), 1, file);

Definition at line 19 of file kest_files.c.

Referenced by save_profile_as_file(), and save_state_to_file().

◆ write_int32

#define write_int32 ( x)
Value:
do { arg32 = x; fwrite(&arg32, sizeof( int32_t), 1, file);} while(0)

Definition at line 17 of file kest_files.c.

Referenced by save_profile_as_file(), and save_state_to_file().

◆ write_short

#define write_short ( x)
Value:
do { arg16 = x; fwrite(&arg16, 1, 2, file);} while(0)

Definition at line 16 of file kest_files.c.

Referenced by save_profile_as_file(), and save_sequence_as_file().

◆ write_string

#define write_string ( x)
Value:
do {if (x) {for (int a = 0; x[a] != 0; a++) {fputc(x[a], file);}} fputc(0, file);} while (0)

Definition at line 20 of file kest_files.c.

Referenced by save_profile_as_file(), save_sequence_as_file(), and save_state_to_file().

◆ write_uint32

#define write_uint32 ( x)
Value:
do {uarg32 = x; fwrite(&uarg32, sizeof(uint32_t), 1, file);} while(0)

Definition at line 18 of file kest_files.c.

Function Documentation

◆ dump_file_contents()

void dump_file_contents ( char * fname)

Definition at line 48 of file kest_files.c.

Referenced by load_state_from_file(), read_profile_from_file(), read_sequence_from_file(), save_profile(), save_sequence(), save_sequence_as_file(), and save_state_to_file().

Here is the caller graph for this function:

◆ erase_folder()

int erase_folder ( const char * dir)

Definition at line 1192 of file kest_files.c.

Referenced by erase_folder(), and erase_sd_card().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erase_sd_card()

void erase_sd_card ( )

Definition at line 1242 of file kest_files.c.

Referenced by erase_sd_card_void_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erase_sd_card_void_cb()

void erase_sd_card_void_cb ( void * data)

Definition at line 1185 of file kest_files.c.

Referenced by configure_main_menu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_validity_check()

int file_validity_check ( FILE * file,
uint8_t magic_byte,
uint8_t * byte_out )

Definition at line 73 of file kest_files.c.

Referenced by read_sequence_from_file().

Here is the caller graph for this function:

◆ fnames_agree()

int fnames_agree ( char * a,
char * b )

Definition at line 1247 of file kest_files.c.

Referenced by cxt_get_profile_by_fname(), and cxt_get_sequence_by_fname().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_filename()

void generate_filename ( char * prefix,
char * suffix,
char * dest )

Definition at line 833 of file kest_files.c.

Referenced by save_profile(), and save_sequence().

Here is the caller graph for this function:

◆ kest_init_directories()

int kest_init_directories ( )

Definition at line 697 of file kest_files.c.

Referenced by app_main(), and main_task().

Here is the caller graph for this function:

◆ list_files_in_directory()

string_ll * list_files_in_directory ( char * dir)

Definition at line 1121 of file kest_files.c.

Referenced by load_effects(), load_saved_profiles(), and load_saved_sequences().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_effects()

int load_effects ( kest_context * cxt)

Definition at line 1072 of file kest_files.c.

Referenced by app_main(), and main_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_saved_profiles()

int load_saved_profiles ( kest_context * cxt)

Definition at line 960 of file kest_files.c.

Referenced by app_main(), and main_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_saved_sequences()

int load_saved_sequences ( kest_context * cxt)

Definition at line 1024 of file kest_files.c.

Referenced by app_main(), and main_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_state_from_file()

int load_state_from_file ( kest_state * state,
const char * fname )

Definition at line 298 of file kest_files.c.

Referenced by app_main(), and main_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_profile_from_file()

int read_profile_from_file ( kest_profile * profile,
const char * fname )

Definition at line 434 of file kest_files.c.

Referenced by load_saved_profiles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_sequence_from_file()

int read_sequence_from_file ( kest_sequence * sequence,
const char * fname )

Definition at line 590 of file kest_files.c.

Referenced by load_saved_sequences().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ safe_file_write()

int safe_file_write ( int(* write_func )(void *arg, const char *fname),
void * arg,
const char * fname )

Definition at line 738 of file kest_files.c.

Referenced by kest_state_representation_update().

Here is the caller graph for this function:

◆ save_profile()

int save_profile ( kest_profile * profile)

Definition at line 883 of file kest_files.c.

Referenced by kest_effect_profile_rep_update(), kest_profile_file_rep_update(), kest_profile_save(), profile_settings_save_button_cb(), and save_sequence_as_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_profile_as_file()

int save_profile_as_file ( kest_profile * profile,
const char * fname )

Definition at line 96 of file kest_files.c.

Referenced by save_profile(), and save_profile_as_file_safe().

Here is the caller graph for this function:

◆ save_profile_as_file_safe()

int save_profile_as_file_safe ( kest_profile * profile,
const char * fname )

Definition at line 786 of file kest_files.c.

Here is the call graph for this function:

◆ save_sequence()

int save_sequence ( kest_sequence * sequence)

Definition at line 921 of file kest_files.c.

Referenced by kest_sequence_file_rep_update(), and seq_save_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_sequence_as_file()

int save_sequence_as_file ( kest_sequence * sequence,
const char * fname )

Definition at line 194 of file kest_files.c.

Referenced by save_sequence().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_state_to_file()

int save_state_to_file ( kest_state * state,
const char * fname )

Definition at line 258 of file kest_files.c.

Referenced by kest_state_representation_update().

Here is the call graph for this function:
Here is the caller graph for this function: