From f6e1a2110892096940242ae00acea899d6406a06 Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 24 Oct 2014 03:12:39 +0100 Subject: [PATCH] Fix loading filenames starting with "file://" (used in lv2 presets) --- drmr.c | 8 +++++--- drmr_ui.c | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drmr.c b/drmr.c index 1cc4159..0e63ecc 100644 --- a/drmr.c +++ b/drmr.c @@ -31,7 +31,7 @@ static void* load_thread(void* arg) { DrMr* drmr = (DrMr*)arg; drmr_sample *loaded_samples,*old_samples; int loaded_count, old_scount; - char *request; + char *request, *request_orig; for(;;) { pthread_mutex_lock(&drmr->load_mutex); pthread_cond_wait(&drmr->load_cond, @@ -39,7 +39,9 @@ static void* load_thread(void* arg) { pthread_mutex_unlock(&drmr->load_mutex); old_samples = drmr->samples; old_scount = drmr->num_samples; - request = drmr->request_buf[drmr->curReq]; + request_orig = request = drmr->request_buf[drmr->curReq]; + if (!strncmp(request, "file://", 7)) + request += 7; loaded_samples = load_hydrogen_kit(request,drmr->rate,&loaded_count); if (!loaded_samples) { fprintf(stderr,"Failed to load kit at: %s\n",request); @@ -57,7 +59,7 @@ static void* load_thread(void* arg) { pthread_mutex_unlock(&drmr->load_mutex); } if (old_scount > 0) free_samples(old_samples,old_scount); - drmr->current_path = request; + drmr->current_path = request_orig; current_kit_changed = 1; } return 0; diff --git a/drmr_ui.c b/drmr_ui.c index 71c3a64..342a1be 100644 --- a/drmr_ui.c +++ b/drmr_ui.c @@ -723,6 +723,8 @@ port_event(LV2UI_Handle handle, lv2_atom_object_get(obj, ui->uris.kit_path, &path, 0); if (path) { char *kitpath = LV2_ATOM_BODY(path); + if (!strncmp(kitpath, "file://", 7)) + kitpath += 7; char *realp = realpath(kitpath,NULL); if (!realp) { fprintf(stderr,"Passed a path I can't resolve, bailing out\n");