mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
Extract config file saving code to a function; Do not write the NUL character to the text config file
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28894 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a69d2c1de7
commit
fb7c0df483
1 changed files with 31 additions and 12 deletions
|
@ -530,6 +530,36 @@ enum tidy_return tidy_lcd_menu(void)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Creates a file and writes information about what files to
|
||||||
|
delete and what to keep to it.
|
||||||
|
Returns true iff the file was successfully created.
|
||||||
|
*/
|
||||||
|
static bool save_config(const char *file_name)
|
||||||
|
{
|
||||||
|
int fd, i;
|
||||||
|
bool result;
|
||||||
|
|
||||||
|
fd = rb->creat(file_name, 0666);
|
||||||
|
result = (fd >= 0);
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
for (i=0; i<tidy_type_count; i++)
|
||||||
|
{
|
||||||
|
rb->fdprintf(fd, "%s%s: %s\n", tidy_types[i].filestring,
|
||||||
|
tidy_types[i].directory ? "/" : "",
|
||||||
|
tidy_types[i].remove ? "yes" : "no");
|
||||||
|
}
|
||||||
|
rb->close(fd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUGF("Could not create file %s\n", file_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* this is the plugin entry point */
|
/* this is the plugin entry point */
|
||||||
enum plugin_status plugin_start(const void* parameter)
|
enum plugin_status plugin_start(const void* parameter)
|
||||||
{
|
{
|
||||||
|
@ -547,18 +577,7 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
status = tidy_lcd_menu();
|
status = tidy_lcd_menu();
|
||||||
if (tidy_loaded_and_changed)
|
if (tidy_loaded_and_changed)
|
||||||
{
|
{
|
||||||
int fd = rb->creat(CUSTOM_FILES, 0666);
|
save_config(CUSTOM_FILES);
|
||||||
int i;
|
|
||||||
if (fd >= 0)
|
|
||||||
{
|
|
||||||
for(i=0;i<tidy_type_count;i++)
|
|
||||||
{
|
|
||||||
rb->fdprintf(fd, "%s%c: %s\n", tidy_types[i].filestring,
|
|
||||||
tidy_types[i].directory?'/':'\0',
|
|
||||||
tidy_types[i].remove?"yes":"no");
|
|
||||||
}
|
|
||||||
rb->close(fd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (status == TIDY_RETURN_ABORT)
|
if (status == TIDY_RETURN_ABORT)
|
||||||
return PLUGIN_OK;
|
return PLUGIN_OK;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue