Merge pull request #2491 from heuripedes/master

Logging improvements
This commit is contained in:
Twinaphex 2015-11-28 20:12:24 +01:00
commit cd8ce72f29
5 changed files with 39 additions and 14 deletions

View File

@ -30,6 +30,9 @@
#ifndef snprintf
#define snprintf _snprintf
#endif
#ifndef vsnprintf
#define vsnprintf _vsnprintf
#endif
#endif
#undef UNICODE /* Do not bother with UNICODE at this time. */

View File

@ -354,8 +354,6 @@ static void cb_decompressed(void *task_data, void *user_data, const char *err)
if (path_file_exists(dec->source_file))
remove(dec->source_file);
free(dec->source_file);
free(dec);
}
@ -367,7 +365,6 @@ void cb_generic_download(void *task_data, void *user_data, const char *err)
(void *data, size_t len, const char *dir_path)
#endif
{
char msg[PATH_MAX_LENGTH];
char output_path[PATH_MAX_LENGTH];
char shaderdir[PATH_MAX_LENGTH];
const char *file_ext = NULL;
@ -432,13 +429,13 @@ void cb_generic_download(void *task_data, void *user_data, const char *err)
transf->path, sizeof(output_path));
if (!retro_write_file(output_path, data->data, data->len))
{
err = "Write failed.";
goto finish;
}
snprintf(msg, sizeof(msg), "%s: %s.",
msg_hash_to_str(MSG_DOWNLOAD_COMPLETE),
transf->path);
rarch_main_msg_queue_push(msg, 1, 90, true);
rarch_main_msg_queue_pushf(1, 90, true, "%s: %s",
msg_hash_to_str(MSG_DOWNLOAD_COMPLETE), transf->path);
#ifdef HAVE_ZLIB
file_ext = path_get_extension(output_path);
@ -448,13 +445,15 @@ void cb_generic_download(void *task_data, void *user_data, const char *err)
if (!strcasecmp(file_ext, "zip"))
{
snprintf(msg, sizeof(msg), "Decompressing %s...",
path_basename(output_path));
rarch_main_msg_queue_pushf(1, 90, true,
"Decompressing %s...", path_basename(output_path));
rarch_main_msg_queue_push(msg, 1, 90, true);
rarch_task_push_decompress(output_path, dir_path, NULL,
cb_decompressed, (void*)(uintptr_t)CB_CORE_UPDATER_DOWNLOAD);
if (!rarch_task_push_decompress(output_path, dir_path, NULL,
cb_decompressed, (void*)(uintptr_t)CB_CORE_UPDATER_DOWNLOAD))
{
rarch_main_msg_queue_pushf(1, 90, true,
"Decompression of %s failed.", path_basename(output_path));
}
}
#else
if (transf->type_hash == CB_CORE_UPDATER_DOWNLOAD)
@ -464,6 +463,8 @@ void cb_generic_download(void *task_data, void *user_data, const char *err)
finish:
if (err)
{
rarch_main_msg_queue_pushf(1, 90, true, "Download failed.");
RARCH_ERR("Download of '%s' failed: %s\n",
(transf ? transf->path: "unknown"), err);
}

View File

@ -344,6 +344,9 @@ int rarch_main_iterate(unsigned *sleep_ms);
void rarch_main_msg_queue_push(const char *msg, unsigned prio,
unsigned duration, bool flush);
void rarch_main_msg_queue_pushf(unsigned prio, unsigned duration,
bool flush, const char *fmt, ...);
void rarch_main_msg_queue_push_new(uint32_t hash, unsigned prio,
unsigned duration, bool flush);

View File

@ -89,6 +89,17 @@ void rarch_main_msg_queue_push(const char *msg, unsigned prio, unsigned duration
}
}
void rarch_main_msg_queue_pushf(unsigned prio, unsigned duration,
bool flush, const char *fmt, ...)
{
char buf[1024];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
rarch_main_msg_queue_push(buf, prio, duration, flush);
}
void rarch_main_msg_queue_free(void)
{
if (!g_msg_queue)

View File

@ -127,11 +127,18 @@ bool rarch_task_push_decompress(const char *source_file, const char *target_dir,
rarch_task_t *t;
if (!target_dir || !target_dir[0] || !source_file || !source_file[0])
{
RARCH_WARN("[decompress] Empty or null source file or target directory arguments.\n");
return false;
}
/* zip only */
if (!path_file_exists(source_file) || strcmp("zip", path_get_extension(source_file)) != 0)
{
RARCH_WARN("[decompress] File '%s' does not exist or is not a compressed file.\n",
source_file);
return false;
}
if (!valid_ext || !valid_ext[0])
valid_ext = NULL;