From 406a77d1bd10e09e448a2ef80b88e59669794b11 Mon Sep 17 00:00:00 2001 From: waker Date: Wed, 10 Oct 2012 22:28:54 +0200 Subject: converter: fixed file-exists check --- plugins/converter/convgui.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'plugins/converter') diff --git a/plugins/converter/convgui.c b/plugins/converter/convgui.c index e225c74d..89a341f1 100644 --- a/plugins/converter/convgui.c +++ b/plugins/converter/convgui.c @@ -181,8 +181,22 @@ converter_worker (void *ctx) { converter_plugin->get_output_path (conv->convert_items[n], conv->outfolder, conv->outfile, conv->encoder_preset, conv->preserve_folder_structure, root, conv->write_to_source_folder, outpath, sizeof (outpath)); int skip = 0; + + // need to unescape path before passing to stat + char unesc_path[2000]; + char invalid[] = "$\"`\\"; + const char *p = outpath; + char *o = unesc_path; + while (*p) { + if (*p == '\\') { + p++; + } + *o++ = *p++; + } + *o = 0; + struct stat st; - int res = stat(outpath, &st); + int res = stat(unesc_path, &st); if (res == 0) { if (conv->overwrite_action > 1 || conv->overwrite_action < 0) { conv->overwrite_action = 0; @@ -192,7 +206,7 @@ converter_worker (void *ctx) { struct overwrite_prompt_ctx ctl; ctl.mutex = deadbeef->mutex_create (); ctl.cond = deadbeef->cond_create (); - ctl.fname = outpath; + ctl.fname = unesc_path; ctl.result = 0; gdk_threads_add_idle (overwrite_prompt_cb, &ctl); deadbeef->cond_wait (ctl.cond, ctl.mutex); -- cgit v1.2.3