strlen optimizations :

- use STRLEN_CONST for constant strings, translates to sizeof
which should be computed at compile-time
- found some places where we are needlessly calling strlen two
times instead of just once
This commit is contained in:
twinaphex 2019-04-27 04:21:10 +02:00
parent 2b401ce13b
commit 3e72c502a8
17 changed files with 265 additions and 150 deletions

View File

@ -319,7 +319,7 @@ static bool command_read_ram(const char *arg)
else
{
strlcpy(reply_at, " -1\n", sizeof(reply) - strlen(reply));
command_reply(reply, reply_at + strlen(" -1\n") - reply);
command_reply(reply, reply_at + STRLEN_CONST(" -1\n") - reply);
}
free(reply);
return true;

View File

@ -55,10 +55,9 @@ static void core_info_list_resolve_all_extensions(
(strlen(core_info_list->list[i].supported_extensions) + 2);
}
all_ext_len += strlen("7z|") + strlen("zip|");
all_ext_len += STRLEN_CONST("7z|") + STRLEN_CONST("zip|");
if (all_ext_len)
all_ext = (char*)calloc(1, all_ext_len);
all_ext = (char*)calloc(1, all_ext_len);
if (!all_ext)
return;

View File

@ -422,7 +422,7 @@ static bool d3d10_gfx_set_shader(void* data,
const char* slang_path = d3d10->shader_preset->pass[i].source.path;
const char* vs_src = d3d10->shader_preset->pass[i].source.string.vertex;
const char* ps_src = d3d10->shader_preset->pass[i].source.string.fragment;
int base_len = strlen(slang_path) - strlen(".slang");
int base_len = strlen(slang_path) - STRLEN_CONST(".slang");
strlcpy(vs_path, slang_path, sizeof(vs_path));
strlcpy(ps_path, slang_path, sizeof(ps_path));

View File

@ -433,7 +433,7 @@ static bool d3d12_gfx_set_shader(void* data, enum rarch_shader_type type, const
const char* slang_path = d3d12->shader_preset->pass[i].source.path;
const char* vs_src = d3d12->shader_preset->pass[i].source.string.vertex;
const char* ps_src = d3d12->shader_preset->pass[i].source.string.fragment;
int base_len = strlen(slang_path) - strlen(".slang");
int base_len = strlen(slang_path) - STRLEN_CONST(".slang");
strlcpy(vs_path, slang_path, sizeof(vs_path));
strlcpy(ps_path, slang_path, sizeof(ps_path));

View File

@ -935,9 +935,11 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, int pass, float *u
continue;
}
if (!strncmp(id, "OriginalHistorySize", strlen("OriginalHistorySize")))
if (!strncmp(id, "OriginalHistorySize",
STRLEN_CONST("OriginalHistorySize")))
{
unsigned index = strtoul(id + strlen("OriginalHistorySize"), NULL, 0);
unsigned index = strtoul(id + STRLEN_CONST("OriginalHistorySize"),
NULL, 0);
if(index > pass)
index = 0;
@ -952,9 +954,10 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, int pass, float *u
continue;
}
if ((pass > 0 ) && !strncmp(id, "PassOutputSize", strlen("PassOutputSize")))
if ((pass > 0 ) && !strncmp(id, "PassOutputSize",
STRLEN_CONST("PassOutputSize")))
{
unsigned index = strtoul(id + strlen("PassOutputSize"), NULL, 0);
unsigned index = strtoul(id + STRLEN_CONST("PassOutputSize"), NULL, 0);
if(index > pass - 1)
index = pass - 1;
GX2Surface *output = &wiiu->pass[index].texture.surface;
@ -966,9 +969,9 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, int pass, float *u
}
/* feedback not supported yet */
if (!strncmp(id, "PassFeedbackSize", strlen("PassFeedbackSize")))
if (!strncmp(id, "PassFeedbackSize", STRLEN_CONST("PassFeedbackSize")))
{
unsigned index = strtoul(id + strlen("PassFeedbackSize"), NULL, 0);
unsigned index = strtoul(id + STRLEN_CONST("PassFeedbackSize"), NULL, 0);
if(index > wiiu->shader_preset->passes - 1)
index = wiiu->shader_preset->passes - 1;
GX2Surface *output = &wiiu->pass[index].texture.surface;
@ -981,8 +984,9 @@ static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu, int pass, float *u
for (int k = 0; k < wiiu->shader_preset->luts; k++)
{
if (!strncmp(id, wiiu->shader_preset->lut[k].id, strlen(wiiu->shader_preset->lut[k].id))
&& !!strcmp(id + strlen(wiiu->shader_preset->lut[k].id), "Size"))
size_t lut_id_size = strlen(wiiu->shader_preset->lut[k].id);
if (!strncmp(id, wiiu->shader_preset->lut[k].id, lut_id_size)
&& !!strcmp(id + lut_id_size, "Size"))
{
GX2Surface *surface = &wiiu->luts[k].surface;
((GX2_vec4 *)dst)->x = surface->width;
@ -1189,9 +1193,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
continue;
}
if (!strncmp(wiiu->pass[i].gfd->ps->samplerVars[j].name, "OriginalHistory", strlen("OriginalHistory")))
if (!strncmp(wiiu->pass[i].gfd->ps->samplerVars[j].name, "OriginalHistory", STRLEN_CONST("OriginalHistory")))
{
unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + strlen("OriginalHistory"), NULL, 0);
unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + STRLEN_CONST("OriginalHistory"), NULL, 0);
if(index > i)
index = 0;
@ -1207,9 +1211,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
continue;
}
if ((i > 0) && !strncmp(wiiu->pass[i].gfd->ps->samplerVars[j].name, "PassOutput", strlen("PassOutput")))
if ((i > 0) && !strncmp(wiiu->pass[i].gfd->ps->samplerVars[j].name, "PassOutput", STRLEN_CONST("PassOutput")))
{
unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + strlen("PassOutput"), NULL, 0);
unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + STRLEN_CONST("PassOutput"), NULL, 0);
if(index > i - 1)
index = i - 1;
GX2SetPixelTexture(&wiiu->pass[index].texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
@ -1221,9 +1225,9 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
}
/* feedback not supported yet */
if (!strncmp(wiiu->pass[i].gfd->ps->samplerVars[j].name, "PassFeedback", strlen("PassFeedback")))
if (!strncmp(wiiu->pass[i].gfd->ps->samplerVars[j].name, "PassFeedback", STRLEN_CONST("PassFeedback")))
{
unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + strlen("PassFeedback"), NULL, 0);
unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + STRLEN_CONST("PassFeedback"), NULL, 0);
if(index > wiiu->shader_preset->passes - 1)
index = wiiu->shader_preset->passes - 1;

View File

@ -305,7 +305,7 @@ bool glslang_parse_meta(const vector<string> &lines, glslang_meta *meta)
return false;
}
str = line_c + strlen("#pragma name ");
str = line_c + STRLEN_CONST("#pragma name ");
while (*str == ' ')
str++;
@ -363,7 +363,7 @@ bool glslang_parse_meta(const vector<string> &lines, glslang_meta *meta)
return false;
}
str = line_c + strlen("#pragma format ");
str = line_c + STRLEN_CONST("#pragma format ");
while (*str == ' ')
str++;

View File

@ -341,7 +341,7 @@ static bool parse_line(config_file_t *conf,
comment++;
if (strstr(comment, "include ") == comment)
{
char *line = comment + strlen("include ");
char *line = comment + STRLEN_CONST("include ");
char *path = extract_value(line, false);
if (!path)
@ -1026,7 +1026,7 @@ void config_file_dump_orbis(config_file_t *conf, int fd)
{
char cad[256];
sprintf(cad,"#include %s\n", includes->path);
orbisWrite(fd,cad,strlen(cad));
orbisWrite(fd, cad, strlen(cad));
includes = includes->next;
}
@ -1039,7 +1039,7 @@ void config_file_dump_orbis(config_file_t *conf, int fd)
{
char newlist[256];
sprintf(newlist,"%s = %s\n", list->key, list->value);
orbisWrite(fd,newlist,strlen(newlist));
orbisWrite(fd, newlist, strlen(newlist));
}
list = list->next;
}

View File

@ -308,7 +308,7 @@ static struct rxml_node *rxml_parse_node(const char **ptr_)
}
node->data = strdup_range(cdata_start +
strlen("<![CDATA["), cdata_end);
STRLEN_CONST("<![CDATA["), cdata_end);
}
else if (closing_start && closing_start == child_start) /* Simple Data */
node->data = strdup_range(closing + 1, closing_start);
@ -404,7 +404,7 @@ static char *purge_xml_comments(const char *str)
memcpy(copy_dest, copy_src, copy_len);
copy_dest += copy_len;
copy_src = comment_end + strlen("-->");
copy_src = comment_end + STRLEN_CONST("-->");
}
/* Avoid strcpy() as OpenBSD is anal and hates you

View File

@ -45,6 +45,8 @@ static INLINE bool string_is_equal(const char *a, const char *b)
return (a && b) ? !strcmp(a, b) : false;
}
#define STRLEN_CONST(x) ((sizeof((x))-1))
#define string_is_not_equal(a, b) !string_is_equal((a), (b))
#define string_add_pair_open(s, size) strlcat((s), " (", (size))

View File

@ -106,9 +106,9 @@ void urlencode_lut_init(void)
caller is responsible for deleting the destination buffer */
void net_http_urlencode(char **dest, const char *source)
{
char *enc = NULL;
char *enc = NULL;
/* Assume every character will be encoded, so we need 3 times the space. */
size_t len = strlen(source) * 3 + 1;
size_t len = strlen(source) * 3 + 1;
size_t count = len;
if (!urlencode_lut_inited)
@ -189,7 +189,8 @@ static int net_http_new_socket(struct http_connection_t *conn)
#ifdef HAVE_SSL
if (conn->sock_state.ssl)
{
ret = ssl_socket_connect(conn->sock_state.ssl_ctx, (void*)next_addr, true, true);
ret = ssl_socket_connect(conn->sock_state.ssl_ctx,
(void*)next_addr, true, true);
if (ret >= 0)
break;
@ -218,20 +219,25 @@ static int net_http_new_socket(struct http_connection_t *conn)
return fd;
}
static void net_http_send_str(struct http_socket_state_t *sock_state, bool *error, const char *text)
static void net_http_send_str(
struct http_socket_state_t *sock_state, bool *error, const char *text)
{
size_t text_size;
if (*error)
return;
text_size = strlen(text);
#ifdef HAVE_SSL
if (sock_state->ssl)
{
if (!ssl_socket_send_all_blocking(sock_state->ssl_ctx, text, strlen(text), true))
if (!ssl_socket_send_all_blocking(
sock_state->ssl_ctx, text, text_size, true))
*error = true;
}
else
#endif
{
if (!socket_send_all_blocking(sock_state->fd, text, strlen(text), true))
if (!socket_send_all_blocking(
sock_state->fd, text, text_size, true))
*error = true;
}
}
@ -239,10 +245,10 @@ static void net_http_send_str(struct http_socket_state_t *sock_state, bool *erro
struct http_connection_t *net_http_connection_new(const char *url,
const char *method, const char *data)
{
char **domain = NULL;
bool error = false;
char **domain = NULL;
struct http_connection_t *conn = (struct http_connection_t*)calloc(1,
sizeof(*conn));
bool error = false;
if (!conn)
return NULL;
@ -261,11 +267,11 @@ struct http_connection_t *net_http_connection_new(const char *url,
if (!conn->urlcopy)
goto error;
if (!strncmp(url, "http://", strlen("http://")))
conn->scan = conn->urlcopy + strlen("http://");
else if (!strncmp(url, "https://", strlen("https://")))
if (!strncmp(url, "http://", STRLEN_CONST("http://")))
conn->scan = conn->urlcopy + STRLEN_CONST("http://");
else if (!strncmp(url, "https://", STRLEN_CONST("https://")))
{
conn->scan = conn->urlcopy + strlen("https://");
conn->scan = conn->urlcopy + STRLEN_CONST("https://");
conn->sock_state.ssl = true;
}
else
@ -566,19 +572,20 @@ bool net_http_update(struct http_t *state, size_t* progress, size_t* total)
if (state->part == P_HEADER_TOP)
{
if (strncmp(state->data, "HTTP/1.", strlen("HTTP/1."))!=0)
if (strncmp(state->data, "HTTP/1.", STRLEN_CONST("HTTP/1."))!=0)
goto fail;
state->status = (int)strtoul(state->data + strlen("HTTP/1.1 "), NULL, 10);
state->status = (int)strtoul(state->data
+ STRLEN_CONST("HTTP/1.1 "), NULL, 10);
state->part = P_HEADER;
}
else
{
if (!strncmp(state->data, "Content-Length: ",
strlen("Content-Length: ")))
STRLEN_CONST("Content-Length: ")))
{
state->bodytype = T_LEN;
state->len = strtol(state->data +
strlen("Content-Length: "), NULL, 10);
STRLEN_CONST("Content-Length: "), NULL, 10);
}
if (string_is_equal(state->data, "Transfer-Encoding: chunked"))
state->bodytype = T_CHUNK;

View File

@ -98,7 +98,7 @@ static int libretrodb_read_metadata(RFILE *fd, libretrodb_metadata_t *md)
static int libretrodb_write_metadata(RFILE *fd, libretrodb_metadata_t *md)
{
rmsgpack_write_map_header(fd, 1);
rmsgpack_write_string(fd, "count", strlen("count"));
rmsgpack_write_string(fd, "count", STRLEN_CONST("count"));
return rmsgpack_write_uint(fd, md->count);
}
@ -196,11 +196,11 @@ static int libretrodb_read_index_header(RFILE *fd, libretrodb_index_t *idx)
static void libretrodb_write_index_header(RFILE *fd, libretrodb_index_t *idx)
{
rmsgpack_write_map_header(fd, 3);
rmsgpack_write_string(fd, "name", strlen("name"));
rmsgpack_write_string(fd, "name", STRLEN_CONST("name"));
rmsgpack_write_string(fd, idx->name, (uint32_t)strlen(idx->name));
rmsgpack_write_string(fd, "key_size", (uint32_t)strlen("key_size"));
rmsgpack_write_string(fd, "key_size", (uint32_t)STRLEN_CONST("key_size"));
rmsgpack_write_uint(fd, idx->key_size);
rmsgpack_write_string(fd, "next", strlen("next"));
rmsgpack_write_string(fd, "next", STRLEN_CONST("next"));
rmsgpack_write_uint(fd, idx->next);
}

View File

@ -32,6 +32,7 @@
#include <compat/fnmatch.h>
#include <compat/strl.h>
#include <string/stdstring.h>
#include "libretrodb.h"
#include "query.h"
@ -408,13 +409,14 @@ static struct buffer query_expect_eof(struct buffer buff, const char ** error)
static int query_peek(struct buffer buff, const char * data)
{
size_t remain = buff.len - buff.offset;
size_t remain = buff.len - buff.offset;
size_t size_data = strlen(data);
if (remain < strlen(data))
if (remain < size_data)
return 0;
return (strncmp(buff.data + buff.offset,
data, strlen(data)) == 0);
data, size_data) == 0);
}
static int query_is_eot(struct buffer buff)
@ -526,20 +528,20 @@ static struct buffer query_parse_value(struct buffer buff,
if (query_peek(buff, "nil"))
{
buff.offset += strlen("nil");
value->type = RDT_NULL;
buff.offset += STRLEN_CONST("nil");
value->type = RDT_NULL;
}
else if (query_peek(buff, "true"))
{
buff.offset += strlen("true");
value->type = RDT_BOOL;
value->val.bool_ = 1;
buff.offset += STRLEN_CONST("true");
value->type = RDT_BOOL;
value->val.bool_ = 1;
}
else if (query_peek(buff, "false"))
{
buff.offset += strlen("false");
value->type = RDT_BOOL;
value->val.bool_ = 0;
buff.offset += STRLEN_CONST("false");
value->type = RDT_BOOL;
value->val.bool_ = 0;
}
else if (query_peek(buff, "b") || query_peek(buff, "\"") || query_peek(buff, "'"))
buff = query_parse_string(buff, value, error);

View File

@ -1006,13 +1006,9 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_
if (msg->task_finished)
{
if (msg->task_error)
{
snprintf(task_percentage, sizeof(task_percentage), "Task failed");
}
else
{
snprintf(task_percentage, sizeof(task_percentage), " ");
}
}
else if (msg->task_progress >= 0 && msg->task_progress <= 100)
{

View File

@ -746,14 +746,17 @@ void playlist_write_runtime_file(playlist_t *playlist)
JSON_Writer_WriteStartObject(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 2);
JSON_Writer_WriteString(context.writer, "version", strlen("version"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "version",
STRLEN_CONST("version"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, "1.0", strlen("1.0"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "1.0",
STRLEN_CONST("1.0"), JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 2);
JSON_Writer_WriteString(context.writer, "items", strlen("items"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "items",
STRLEN_CONST("items"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteStartArray(context.writer);
@ -766,18 +769,28 @@ void playlist_write_runtime_file(playlist_t *playlist)
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "path", strlen("path"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "path",
STRLEN_CONST("path"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, playlist->entries[i].path ? playlist->entries[i].path : "", playlist->entries[i].path ? strlen(playlist->entries[i].path) : 0, JSON_UTF8);
JSON_Writer_WriteString(context.writer,
playlist->entries[i].path
? playlist->entries[i].path
: "",
playlist->entries[i].path
? strlen(playlist->entries[i].path)
: 0,
JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "core_path", strlen("core_path"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "core_path",
STRLEN_CONST("core_path"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, playlist->entries[i].core_path, strlen(playlist->entries[i].core_path), JSON_UTF8);
JSON_Writer_WriteString(context.writer, playlist->entries[i].core_path,
strlen(playlist->entries[i].core_path), JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
@ -787,7 +800,8 @@ void playlist_write_runtime_file(playlist_t *playlist)
snprintf(tmp, sizeof(tmp), "%u", playlist->entries[i].runtime_hours);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "runtime_hours", strlen("runtime_hours"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "runtime_hours",
STRLEN_CONST("runtime_hours"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteNumber(context.writer, tmp, strlen(tmp), JSON_UTF8);
@ -799,7 +813,8 @@ void playlist_write_runtime_file(playlist_t *playlist)
snprintf(tmp, sizeof(tmp), "%u", playlist->entries[i].runtime_minutes);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "runtime_minutes", strlen("runtime_minutes"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "runtime_minutes",
STRLEN_CONST("runtime_minutes"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteNumber(context.writer, tmp, strlen(tmp), JSON_UTF8);
@ -811,7 +826,8 @@ void playlist_write_runtime_file(playlist_t *playlist)
snprintf(tmp, sizeof(tmp), "%u", playlist->entries[i].runtime_seconds);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "runtime_seconds", strlen("runtime_seconds"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "runtime_seconds",
STRLEN_CONST("runtime_seconds"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteNumber(context.writer, tmp, strlen(tmp), JSON_UTF8);
@ -823,7 +839,8 @@ void playlist_write_runtime_file(playlist_t *playlist)
snprintf(tmp, sizeof(tmp), "%u", playlist->entries[i].last_played_year);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "last_played_year", strlen("last_played_year"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "last_played_year",
STRLEN_CONST("last_played_year"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteNumber(context.writer, tmp, strlen(tmp), JSON_UTF8);
@ -835,7 +852,8 @@ void playlist_write_runtime_file(playlist_t *playlist)
snprintf(tmp, sizeof(tmp), "%u", playlist->entries[i].last_played_month);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "last_played_month", strlen("last_played_month"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "last_played_month",
STRLEN_CONST("last_played_month"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteNumber(context.writer, tmp, strlen(tmp), JSON_UTF8);
@ -847,10 +865,12 @@ void playlist_write_runtime_file(playlist_t *playlist)
snprintf(tmp, sizeof(tmp), "%u", playlist->entries[i].last_played_day);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "last_played_day", strlen("last_played_day"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "last_played_day",
STRLEN_CONST("last_played_day"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteNumber(context.writer, tmp, strlen(tmp), JSON_UTF8);
JSON_Writer_WriteNumber(context.writer, tmp,
strlen(tmp), JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
@ -859,7 +879,8 @@ void playlist_write_runtime_file(playlist_t *playlist)
snprintf(tmp, sizeof(tmp), "%u", playlist->entries[i].last_played_hour);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "last_played_hour", strlen("last_played_hour"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "last_played_hour",
STRLEN_CONST("last_played_hour"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteNumber(context.writer, tmp, strlen(tmp), JSON_UTF8);
@ -871,7 +892,8 @@ void playlist_write_runtime_file(playlist_t *playlist)
snprintf(tmp, sizeof(tmp), "%u", playlist->entries[i].last_played_minute);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "last_played_minute", strlen("last_played_minute"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "last_played_minute",
STRLEN_CONST("last_played_minute"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteNumber(context.writer, tmp, strlen(tmp), JSON_UTF8);
@ -883,10 +905,12 @@ void playlist_write_runtime_file(playlist_t *playlist)
snprintf(tmp, sizeof(tmp), "%u", playlist->entries[i].last_played_second);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "last_played_second", strlen("last_played_second"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "last_played_second",
STRLEN_CONST("last_played_second"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteNumber(context.writer, tmp, strlen(tmp), JSON_UTF8);
JSON_Writer_WriteNumber(context.writer, tmp,
strlen(tmp), JSON_UTF8);
JSON_Writer_WriteNewLine(context.writer);
}
@ -962,14 +986,17 @@ void playlist_write_file(playlist_t *playlist)
JSON_Writer_WriteStartObject(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 2);
JSON_Writer_WriteString(context.writer, "version", strlen("version"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "version",
STRLEN_CONST("version"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, "1.0", strlen("1.0"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "1.0",
STRLEN_CONST("1.0"), JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 2);
JSON_Writer_WriteString(context.writer, "items", strlen("items"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "items",
STRLEN_CONST("items"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteStartArray(context.writer);
@ -982,60 +1009,97 @@ void playlist_write_file(playlist_t *playlist)
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "path", strlen("path"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "path",
STRLEN_CONST("path"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, playlist->entries[i].path ? playlist->entries[i].path : "", playlist->entries[i].path ? strlen(playlist->entries[i].path) : 0, JSON_UTF8);
JSON_Writer_WriteString(context.writer,
playlist->entries[i].path
? playlist->entries[i].path
: "",
playlist->entries[i].path
? strlen(playlist->entries[i].path)
: 0,
JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "label", strlen("label"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "label",
STRLEN_CONST("label"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, playlist->entries[i].label ? playlist->entries[i].label : "", playlist->entries[i].label ? strlen(playlist->entries[i].label) : 0, JSON_UTF8);
JSON_Writer_WriteString(context.writer,
playlist->entries[i].label
? playlist->entries[i].label
: "",
playlist->entries[i].label
? strlen(playlist->entries[i].label)
: 0,
JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "core_path", strlen("core_path"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "core_path",
STRLEN_CONST("core_path"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, playlist->entries[i].core_path, strlen(playlist->entries[i].core_path), JSON_UTF8);
JSON_Writer_WriteString(context.writer,
playlist->entries[i].core_path,
strlen(playlist->entries[i].core_path), JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "core_name", strlen("core_name"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "core_name",
STRLEN_CONST("core_name"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, playlist->entries[i].core_name, strlen(playlist->entries[i].core_name), JSON_UTF8);
JSON_Writer_WriteString(context.writer,
playlist->entries[i].core_name,
strlen(playlist->entries[i].core_name), JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "crc32", strlen("crc32"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "crc32",
STRLEN_CONST("crc32"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, playlist->entries[i].crc32 ? playlist->entries[i].crc32 : "", playlist->entries[i].crc32 ? strlen(playlist->entries[i].crc32) : 0, JSON_UTF8);
JSON_Writer_WriteString(context.writer, playlist->entries[i].crc32 ? playlist->entries[i].crc32 : "",
playlist->entries[i].crc32
? strlen(playlist->entries[i].crc32)
: 0,
JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "db_name", strlen("db_name"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "db_name",
STRLEN_CONST("db_name"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, playlist->entries[i].db_name ? playlist->entries[i].db_name : "", playlist->entries[i].db_name ? strlen(playlist->entries[i].db_name) : 0, JSON_UTF8);
JSON_Writer_WriteString(context.writer, playlist->entries[i].db_name ? playlist->entries[i].db_name : "",
playlist->entries[i].db_name
? strlen(playlist->entries[i].db_name)
: 0,
JSON_UTF8);
if (!string_is_empty(playlist->entries[i].subsystem_ident))
{
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "subsystem_ident", strlen("subsystem_ident"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "subsystem_ident",
STRLEN_CONST("subsystem_ident"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, playlist->entries[i].subsystem_ident ? playlist->entries[i].subsystem_ident : "", playlist->entries[i].subsystem_ident ? strlen(playlist->entries[i].subsystem_ident) : 0, JSON_UTF8);
JSON_Writer_WriteString(context.writer, playlist->entries[i].subsystem_ident ? playlist->entries[i].subsystem_ident : "",
playlist->entries[i].subsystem_ident
? strlen(playlist->entries[i].subsystem_ident)
: 0,
JSON_UTF8);
}
if (!string_is_empty(playlist->entries[i].subsystem_name))
@ -1043,20 +1107,29 @@ void playlist_write_file(playlist_t *playlist)
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "subsystem_name", strlen("subsystem_name"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "subsystem_name",
STRLEN_CONST("subsystem_name"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, playlist->entries[i].subsystem_name ? playlist->entries[i].subsystem_name : "", playlist->entries[i].subsystem_name ? strlen(playlist->entries[i].subsystem_name) : 0, JSON_UTF8);
JSON_Writer_WriteString(context.writer,
playlist->entries[i].subsystem_name
? playlist->entries[i].subsystem_name
: "",
playlist->entries[i].subsystem_name
? strlen(playlist->entries[i].subsystem_name)
: 0, JSON_UTF8);
}
if (playlist->entries[i].subsystem_roms && playlist->entries[i].subsystem_roms->size > 0)
if ( playlist->entries[i].subsystem_roms &&
playlist->entries[i].subsystem_roms->size > 0)
{
unsigned j;
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 6);
JSON_Writer_WriteString(context.writer, "subsystem_roms", strlen("subsystem_roms"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "subsystem_roms",
STRLEN_CONST("subsystem_roms"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteStartArray(context.writer);
@ -1066,7 +1139,14 @@ void playlist_write_file(playlist_t *playlist)
{
const struct string_list *roms = playlist->entries[i].subsystem_roms;
JSON_Writer_WriteSpace(context.writer, 8);
JSON_Writer_WriteString(context.writer, !string_is_empty(roms->elems[j].data) ? roms->elems[j].data : "", !string_is_empty(roms->elems[j].data) ? strlen(roms->elems[j].data) : 0, JSON_UTF8);
JSON_Writer_WriteString(context.writer,
!string_is_empty(roms->elems[j].data)
? roms->elems[j].data
: "",
!string_is_empty(roms->elems[j].data)
? strlen(roms->elems[j].data)
: 0,
JSON_UTF8);
if (j < playlist->entries[i].subsystem_roms->size - 1)
{

View File

@ -29,6 +29,7 @@
#include <gfx/video_frame.h>
#include <file/config_file.h>
#include <audio/audio_resampler.h>
#include <string/stdstring.h>
#include <audio/conversion/float_to_s16.h>
#include <audio/conversion/s16_to_float.h>
@ -814,12 +815,12 @@ static bool ffmpeg_init_config(struct ff_config_param *params,
{
if (strstr(entry.key, "video_") == entry.key)
{
const char *key = entry.key + strlen("video_");
const char *key = entry.key + STRLEN_CONST("video_");
av_dict_set(&params->video_opts, key, entry.value, 0);
}
else if (strstr(entry.key, "audio_") == entry.key)
{
const char *key = entry.key + strlen("audio_");
const char *key = entry.key + STRLEN_CONST("audio_");
av_dict_set(&params->audio_opts, key, entry.value, 0);
}
} while (config_get_entry_list_next(&entry));

View File

@ -261,7 +261,8 @@ end:
/* Initialise runtime log, loading current parameters
* if log file exists. Returned object must be free()'d.
* Returns NULL if content_path and/or core_path are invalid */
runtime_log_t *runtime_log_init(const char *content_path, const char *core_path, bool log_per_core)
runtime_log_t *runtime_log_init(const char *content_path,
const char *core_path, bool log_per_core)
{
unsigned i;
char content_name[PATH_MAX_LENGTH];
@ -272,7 +273,7 @@ runtime_log_t *runtime_log_init(const char *content_path, const char *core_path,
settings_t *settings = config_get_ptr();
core_info_list_t *core_info = NULL;
runtime_log_t *runtime_log = NULL;
const char *core_path_basename = path_basename(core_path);
const char *core_path_basename = NULL;
content_name[0] = '\0';
core_name[0] = '\0';
@ -284,16 +285,22 @@ runtime_log_t *runtime_log_init(const char *content_path, const char *core_path,
if (!settings)
return NULL;
if (string_is_empty(settings->paths.directory_runtime_log) && string_is_empty(settings->paths.directory_playlist))
if ( string_is_empty(settings->paths.directory_runtime_log) &&
string_is_empty(settings->paths.directory_playlist))
{
RARCH_ERR("Runtime log directory is undefined - cannot save runtime log files.\n");
RARCH_ERR("Runtime log directory is undefined - cannot save"
" runtime log files.\n");
return NULL;
}
core_path_basename = path_basename(core_path);
if (string_is_empty(content_path) || string_is_empty(core_path_basename))
if ( string_is_empty(content_path) ||
string_is_empty(core_path_basename))
return NULL;
if (string_is_equal(core_path, "builtin") || string_is_equal(core_path, file_path_str(FILE_PATH_DETECT)))
if ( string_is_equal(core_path, "builtin") ||
string_is_equal(core_path, file_path_str(FILE_PATH_DETECT)))
return NULL;
/* Get core name
@ -308,13 +315,15 @@ runtime_log_t *runtime_log_init(const char *content_path, const char *core_path,
for (i = 0; i < core_info->count; i++)
{
if (!string_is_equal(path_basename(core_info->list[i].path), core_path_basename))
const char *entry_core_name = core_info->list[i].core_name;
if (!string_is_equal(
path_basename(core_info->list[i].path), core_path_basename))
continue;
if (string_is_empty(core_info->list[i].core_name))
if (string_is_empty(entry_core_name))
return NULL;
strlcpy(core_name, core_info->list[i].core_name, sizeof(core_name));
strlcpy(core_name, entry_core_name, sizeof(core_name));
break;
}
@ -333,7 +342,8 @@ runtime_log_t *runtime_log_init(const char *content_path, const char *core_path,
sizeof(tmp_buf));
}
else
strlcpy(tmp_buf, settings->paths.directory_runtime_log, sizeof(tmp_buf));
strlcpy(tmp_buf,
settings->paths.directory_runtime_log, sizeof(tmp_buf));
if (string_is_empty(tmp_buf))
return NULL;
@ -355,7 +365,8 @@ runtime_log_t *runtime_log_init(const char *content_path, const char *core_path,
{
if (!path_mkdir(log_file_dir))
{
RARCH_ERR("[runtime] failed to create directory for runtime log: %s.\n", log_file_dir);
RARCH_ERR("[runtime] failed to create directory for"
" runtime log: %s.\n", log_file_dir);
return NULL;
}
}
@ -565,7 +576,8 @@ void runtime_log_reset(runtime_log_t *runtime_log)
/* Getters */
/* Gets runtime in hours, minutes, seconds */
void runtime_log_get_runtime_hms(runtime_log_t *runtime_log, unsigned *hours, unsigned *minutes, unsigned *seconds)
void runtime_log_get_runtime_hms(runtime_log_t *runtime_log,
unsigned *hours, unsigned *minutes, unsigned *seconds)
{
if (!runtime_log)
return;
@ -576,14 +588,13 @@ void runtime_log_get_runtime_hms(runtime_log_t *runtime_log, unsigned *hours, un
}
/* Gets runtime in microseconds */
void runtime_log_get_runtime_usec(runtime_log_t *runtime_log, retro_time_t *usec)
void runtime_log_get_runtime_usec(
runtime_log_t *runtime_log, retro_time_t *usec)
{
if (!runtime_log)
return;
runtime_log_convert_hms2usec(
runtime_log->runtime.hours, runtime_log->runtime.minutes, runtime_log->runtime.seconds,
usec);
if (runtime_log)
runtime_log_convert_hms2usec( runtime_log->runtime.hours,
runtime_log->runtime.minutes, runtime_log->runtime.seconds,
usec);
}
/* Gets last played entry values */
@ -657,7 +668,8 @@ bool runtime_log_has_last_played(runtime_log_t *runtime_log)
void runtime_log_save(runtime_log_t *runtime_log)
{
int n;
char value_string[64]; /* 64 characters should be enough for a very long runtime... :) */
char value_string[64]; /* 64 characters should be
enough for a very long runtime... :) */
RtlJSONContext context = {0};
RFILE *file = NULL;
@ -667,7 +679,8 @@ void runtime_log_save(runtime_log_t *runtime_log)
RARCH_LOG("Saving runtime log file: %s\n", runtime_log->path);
/* Attempt to open log file */
file = filestream_open(runtime_log->path, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE);
file = filestream_open(runtime_log->path,
RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE);
if (!file)
{
@ -696,41 +709,52 @@ void runtime_log_save(runtime_log_t *runtime_log)
/* > Version entry */
JSON_Writer_WriteSpace(context.writer, 2);
JSON_Writer_WriteString(context.writer, "version", strlen("version"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "version",
STRLEN_CONST("version"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, "1.0", strlen("1.0"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "1.0",
STRLEN_CONST("1.0"), JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
/* > Runtime entry */
value_string[0] = '\0';
n = snprintf(value_string, sizeof(value_string), LOG_FILE_RUNTIME_FORMAT_STR,
runtime_log->runtime.hours, runtime_log->runtime.minutes, runtime_log->runtime.seconds);
n = snprintf(value_string,
sizeof(value_string), LOG_FILE_RUNTIME_FORMAT_STR,
runtime_log->runtime.hours, runtime_log->runtime.minutes,
runtime_log->runtime.seconds);
if ((n < 0) || (n >= 64))
n = 0; /* Silence GCC warnings... */
JSON_Writer_WriteSpace(context.writer, 2);
JSON_Writer_WriteString(context.writer, "runtime", strlen("runtime"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "runtime",
STRLEN_CONST("runtime"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, value_string, strlen(value_string), JSON_UTF8);
JSON_Writer_WriteString(context.writer, value_string,
strlen(value_string), JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
/* > Last played entry */
value_string[0] = '\0';
n = snprintf(value_string, sizeof(value_string), LOG_FILE_LAST_PLAYED_FORMAT_STR,
runtime_log->last_played.year, runtime_log->last_played.month, runtime_log->last_played.day,
runtime_log->last_played.hour, runtime_log->last_played.minute, runtime_log->last_played.second);
n = snprintf(value_string, sizeof(value_string),
LOG_FILE_LAST_PLAYED_FORMAT_STR,
runtime_log->last_played.year, runtime_log->last_played.month,
runtime_log->last_played.day,
runtime_log->last_played.hour, runtime_log->last_played.minute,
runtime_log->last_played.second);
if ((n < 0) || (n >= 64))
n = 0; /* Silence GCC warnings... */
JSON_Writer_WriteSpace(context.writer, 2);
JSON_Writer_WriteString(context.writer, "last_played", strlen("last_played"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "last_played",
STRLEN_CONST("last_played"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, value_string, strlen(value_string), JSON_UTF8);
JSON_Writer_WriteString(context.writer, value_string,
strlen(value_string), JSON_UTF8);
JSON_Writer_WriteNewLine(context.writer);
/* > Finalise */
@ -748,7 +772,8 @@ end:
/* Utility functions */
/* Convert from hours, minutes, seconds to microseconds */
void runtime_log_convert_hms2usec(unsigned hours, unsigned minutes, unsigned seconds, retro_time_t *usec)
void runtime_log_convert_hms2usec(unsigned hours,
unsigned minutes, unsigned seconds, retro_time_t *usec)
{
*usec = ((retro_time_t)hours * 60 * 60 * 1000000) +
((retro_time_t)minutes * 60 * 1000000) +
@ -756,7 +781,8 @@ void runtime_log_convert_hms2usec(unsigned hours, unsigned minutes, unsigned sec
}
/* Convert from microseconds to hours, minutes, seconds */
void runtime_log_convert_usec2hms(retro_time_t usec, unsigned *hours, unsigned *minutes, unsigned *seconds)
void runtime_log_convert_usec2hms(retro_time_t usec,
unsigned *hours, unsigned *minutes, unsigned *seconds)
{
*seconds = (unsigned)(usec / 1000000);
*minutes = *seconds / 60;

View File

@ -47,14 +47,14 @@ static int file_decompressed_subdir(const char *name,
{
char path_dir[PATH_MAX_LENGTH];
char path[PATH_MAX_LENGTH];
size_t name_len = strlen(name);
char last_char = name[name_len - 1];
path_dir[0] = path[0] = '\0';
/* Ignore directories. */
if (
name[strlen(name) - 1] == '/' ||
name[strlen(name) - 1] == '\\')
goto next_file;
/* Ignore directories, go to next file. */
if (last_char == '/' || last_char == '\\')
return 1;
if (strstr(name, userdata->dec->subdir) != name)
return 1;
@ -77,7 +77,6 @@ static int file_decompressed_subdir(const char *name,
RARCH_LOG("[deflate subdir] Path: %s, CRC32: 0x%x\n", name, crc32);
#endif
next_file:
return 1;
error:
@ -94,13 +93,14 @@ static int file_decompressed(const char *name, const char *valid_exts,
{
char path[PATH_MAX_LENGTH];
decompress_state_t *dec = userdata->dec;
size_t name_len = strlen(name);
char last_char = name[name_len - 1];
path[0] = '\0';
/* Ignore directories. */
if ( name[strlen(name) - 1] == '/' ||
name[strlen(name) - 1] == '\\')
goto next_file;
/* Ignore directories, go to next file. */
if (last_char == '/' || last_char == '\\')
return 1;
/* Make directory */
fill_pathname_join(path, dec->target_dir, name, sizeof(path));
@ -118,8 +118,6 @@ static int file_decompressed(const char *name, const char *valid_exts,
#if 0
RARCH_LOG("[deflate] Path: %s, CRC32: 0x%x\n", name, crc32);
#endif
next_file:
return 1;
error: