rename some funcs related to settings, preparing to add commands for reading and writing the ini file.
This commit is contained in:
+3
-3
@@ -199,7 +199,7 @@ static bool detect_conf(const uint8_t *data, uint32_t size)
|
||||
|
||||
static void iniparser_cb(const char *section, const char *key, const char *value, void *userData)
|
||||
{
|
||||
settings_read_ini(section, key, value);
|
||||
settings_load_ini_key(section, key, value);
|
||||
}
|
||||
|
||||
static error_t open_conf(void *state)
|
||||
@@ -208,7 +208,7 @@ static error_t open_conf(void *state)
|
||||
conf->file_pos = 0;
|
||||
vfs_printf("\r\n---- INI OPEN! ----");
|
||||
|
||||
settings_read_ini_begin();
|
||||
settings_load_ini_begin();
|
||||
ini_parse_begin(iniparser_cb, NULL);
|
||||
|
||||
return E_SUCCESS;
|
||||
@@ -236,7 +236,7 @@ static error_t close_conf(void *state)
|
||||
vfs_printf("Close INI, total bytes = %d", conf->file_pos);
|
||||
|
||||
ini_parse_end();
|
||||
settings_read_ini_end();
|
||||
settings_load_ini_end();
|
||||
|
||||
// force a full remount to have the changes be visible
|
||||
vfs_mngr_fs_remount(true);
|
||||
|
||||
+12
-11
@@ -36,21 +36,21 @@ static uint32_t read_file_config_ini(uint32_t sector_offset, uint8_t *data, uint
|
||||
const uint32_t skip = sector_offset*VFS_SECTOR_SIZE;
|
||||
|
||||
IniWriter iw = iw_init((char *)data, skip, avail);
|
||||
settings_write_ini(&iw);
|
||||
settings_build_ini(&iw);
|
||||
|
||||
return avail - iw.count;
|
||||
}
|
||||
|
||||
|
||||
////
|
||||
//static void write_file_config_ini(uint32_t sector_offset, const uint8_t *data, uint32_t num_sectors)
|
||||
//{
|
||||
// vfs_printf("Write CONFIG.INI, so %d, ns %d", sector_offset, num_sectors);
|
||||
//
|
||||
static void write_file_config_ini(uint32_t sector_offset, const uint8_t *data, uint32_t num_sectors)
|
||||
{
|
||||
vfs_printf("Write CONFIG.INI, so %d, ns %d", sector_offset, num_sectors);
|
||||
|
||||
for(uint32_t i=0;i<num_sectors*VFS_SECTOR_SIZE;i++) {
|
||||
PRINTF("%c", data[i]);
|
||||
}
|
||||
}
|
||||
// for(uint32_t i=0;i<num_sectors*VFS_SECTOR_SIZE;i++) {
|
||||
// PRINTF("%c", data[i]);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
void vfs_user_build_filesystem(void)
|
||||
@@ -58,9 +58,10 @@ void vfs_user_build_filesystem(void)
|
||||
dbg("Rebuilding VFS...");
|
||||
|
||||
// Setup the filesystem based on target parameters
|
||||
vfs_init(daplink_drive_name, 0/*unused*/);
|
||||
vfs_init(daplink_drive_name, 0/*unused "disk size"*/);
|
||||
|
||||
vfs_create_file("CONFIG INI", read_file_config_ini, write_file_config_ini, settings_get_ini_len());
|
||||
// Write is done using a stream, this is never called
|
||||
vfs_create_file("CONFIG INI", read_file_config_ini, NULL, settings_get_ini_len());
|
||||
}
|
||||
|
||||
// Callback to handle changes to the root directory. Should be used with vfs_set_file_change_callback
|
||||
|
||||
Reference in New Issue
Block a user