This commit is contained in:
twinaphex 2020-08-24 23:42:13 +02:00
parent 3d86e1c699
commit 72d233a9d9
5 changed files with 49 additions and 16 deletions

View File

@ -64,10 +64,12 @@ static int config_sort_compare_func(struct config_entry_list *a,
{
if (a && b)
{
if (a->key && b->key)
return strcasecmp(a->key, b->key);
else if (a->key)
if (a->key)
{
if (b->key)
return strcasecmp(a->key, b->key);
return 1;
}
else if (b->key)
return -1;
}
@ -1179,12 +1181,14 @@ void config_file_dump_orbis(config_file_t *conf, int fd)
while (includes)
{
char cad[256];
sprintf(cad,"#include %s\n", includes->path);
snprintf(cad, sizeof(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);
list = merge_sort_linked_list((struct config_entry_list*)
conf->entries, config_sort_compare_func);
conf->entries = list;
while (list)
@ -1192,7 +1196,8 @@ void config_file_dump_orbis(config_file_t *conf, int fd)
if (!list->readonly && list->key)
{
char newlist[256];
sprintf(newlist,"%s = %s\n", list->key, list->value);
snprintf(newlist, sizeof(newlist),
"%s = %s\n", list->key, list->value);
orbisWrite(fd, newlist, strlen(newlist));
}
list = list->next;

View File

@ -1280,17 +1280,15 @@ void fill_pathname_home_dir(char *s, size_t len)
bool is_path_accessible_using_standard_io(const char *path)
{
bool result = true;
#ifdef __WINRT__
size_t path_sizeof = PATH_MAX_LENGTH * sizeof(char);
char *relative_path_abbrev = (char*)malloc(path_sizeof);
fill_pathname_abbreviate_special(relative_path_abbrev, path, path_sizeof);
result = (strlen(relative_path_abbrev) >= 2 )
&& (relative_path_abbrev[0] == ':' || relative_path_abbrev[0] == '~')
char relative_path_abbrev[PATH_MAX_LENGTH];
fill_pathname_abbreviate_special(relative_path_abbrev,
path, sizeof(relative_path_abbrev));
return (strlen(relative_path_abbrev) >= 2 )
&& ( relative_path_abbrev[0] == ':'
|| relative_path_abbrev[0] == '~')
&& PATH_CHAR_IS_SLASH(relative_path_abbrev[1]);
free(relative_path_abbrev);
#else
return true;
#endif
return result;
}

View File

@ -105,6 +105,8 @@ config_file_t *config_file_new_from_path_to_string(const char *path);
/* Frees config file. */
void config_file_free(config_file_t *conf);
bool config_file_deinitialize(config_file_t *conf);
/* Loads a new config, and appends its data to conf.
* The key-value pairs of the new config file takes priority over the old. */
bool config_append_file(config_file_t *conf, const char *path);

View File

@ -24,6 +24,7 @@
#define __LIBRETRO_SDK_DIR_LIST_H
#include <retro_common_api.h>
#include <boolean.h>
#include <lists/string_list.h>
@ -63,6 +64,12 @@ bool dir_list_append(struct string_list *list, const char *dir, const char *ext,
struct string_list *dir_list_new(const char *dir, const char *ext,
bool include_dirs, bool include_hidden, bool include_compressed, bool recursive);
bool dir_list_initialize(struct string_list *list,
const char *dir,
const char *ext, bool include_dirs,
bool include_hidden, bool include_compressed,
bool recursive);
/**
* dir_list_sort:
* @list : pointer to the directory listing.
@ -82,6 +89,8 @@ void dir_list_sort(struct string_list *list, bool dir_first);
**/
void dir_list_free(struct string_list *list);
bool dir_list_deinitialize(struct string_list *list);
RETRO_END_DECLS
#endif

View File

@ -86,6 +86,13 @@ void dir_list_free(struct string_list *list)
string_list_free(list);
}
bool dir_list_deinitialize(struct string_list *list)
{
if (!list)
return false;
return string_list_deinitialize(list);
}
/**
* dir_list_read:
* @dir : directory path.
@ -249,3 +256,15 @@ struct string_list *dir_list_new(const char *dir,
return list;
}
bool dir_list_initialize(struct string_list *list,
const char *dir,
const char *ext, bool include_dirs,
bool include_hidden, bool include_compressed,
bool recursive)
{
if (!list)
return NULL;
return dir_list_append(list, dir, ext, include_dirs,
include_hidden, include_compressed, recursive);
}