mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
[ORBIS] Add support to config save for orbis
This commit is contained in:
parent
66ba53c79b
commit
d52de24e79
@ -34,7 +34,10 @@
|
|||||||
#elif defined(_XBOX)
|
#elif defined(_XBOX)
|
||||||
#include <xtl.h>
|
#include <xtl.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ORBIS
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
#include <orbisFile.h>
|
||||||
|
#endif
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
#include <compat/posix_string.h>
|
#include <compat/posix_string.h>
|
||||||
@ -413,10 +416,10 @@ static config_file_t *config_file_new_internal(
|
|||||||
|
|
||||||
if (!path || !*path)
|
if (!path || !*path)
|
||||||
return conf;
|
return conf;
|
||||||
|
#if !defined(ORBIS)
|
||||||
if (path_is_directory(path))
|
if (path_is_directory(path))
|
||||||
goto error;
|
goto error;
|
||||||
|
#endif
|
||||||
conf->path = strdup(path);
|
conf->path = strdup(path);
|
||||||
if (!conf->path)
|
if (!conf->path)
|
||||||
goto error;
|
goto error;
|
||||||
@ -981,6 +984,15 @@ bool config_file_write(config_file_t *conf, const char *path)
|
|||||||
if (!string_is_empty(path))
|
if (!string_is_empty(path))
|
||||||
{
|
{
|
||||||
void* buf = NULL;
|
void* buf = NULL;
|
||||||
|
#ifdef ORBIS
|
||||||
|
int fd = orbisOpen(path,O_RDWR|O_CREAT,0644);
|
||||||
|
RARCH_LOG("[Config]config_file_write orbisOpen path=%s fd=%d\n", path, fd);
|
||||||
|
if (fd<0)
|
||||||
|
return false;
|
||||||
|
config_file_dump_orbis(conf,fd);
|
||||||
|
orbisClose(fd);
|
||||||
|
RARCH_LOG("[Config]config_file_write orbisClose path=%s fd=%d\n", path, fd);
|
||||||
|
#else
|
||||||
FILE *file = (FILE*)fopen_utf8(path, "wb");
|
FILE *file = (FILE*)fopen_utf8(path, "wb");
|
||||||
if (!file)
|
if (!file)
|
||||||
return false;
|
return false;
|
||||||
@ -994,13 +1006,41 @@ bool config_file_write(config_file_t *conf, const char *path)
|
|||||||
if (file != stdout)
|
if (file != stdout)
|
||||||
fclose(file);
|
fclose(file);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
config_file_dump(conf, stdout);
|
config_file_dump(conf, stdout);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#ifdef ORBIS
|
||||||
|
void config_file_dump_orbis(config_file_t *conf, int fd)
|
||||||
|
{
|
||||||
|
struct config_entry_list *list = NULL;
|
||||||
|
struct config_include_list *includes = conf->includes;
|
||||||
|
while (includes)
|
||||||
|
{
|
||||||
|
char cad[256];
|
||||||
|
sprintf(cad,"#include %s\n", includes->path);
|
||||||
|
orbisWrite(fd,cad,strlen(cad));
|
||||||
|
includes = includes->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
list = merge_sort_linked_list((struct config_entry_list*)conf->entries, config_sort_compare_func);
|
||||||
|
conf->entries = list;
|
||||||
|
|
||||||
|
while (list)
|
||||||
|
{
|
||||||
|
if (!list->readonly && list->key)
|
||||||
|
{
|
||||||
|
char newlist[256];
|
||||||
|
sprintf(newlist,"%s = %s\n", list->key, list->value);
|
||||||
|
orbisWrite(fd,newlist,strlen(newlist));
|
||||||
|
}
|
||||||
|
list = list->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
void config_file_dump(config_file_t *conf, FILE *file)
|
void config_file_dump(config_file_t *conf, FILE *file)
|
||||||
{
|
{
|
||||||
struct config_entry_list *list = NULL;
|
struct config_entry_list *list = NULL;
|
||||||
|
@ -186,7 +186,9 @@ bool config_file_write(config_file_t *conf, const char *path);
|
|||||||
/* Dump the current config to an already opened file.
|
/* Dump the current config to an already opened file.
|
||||||
* Does not close the file. */
|
* Does not close the file. */
|
||||||
void config_file_dump(config_file_t *conf, FILE *file);
|
void config_file_dump(config_file_t *conf, FILE *file);
|
||||||
|
#ifdef ORBIS
|
||||||
|
void config_file_dump_orbis(config_file_t *conf, int fd);
|
||||||
|
#endif
|
||||||
bool config_file_exists(const char *path);
|
bool config_file_exists(const char *path);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user