From b1adfb379ca9f2e4e5515cbae19a3f827fe52b22 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 3 Jul 2011 18:00:11 +0200 Subject: [PATCH] Web update: ensure that the patch pool directory exists --- src/flash.c | 2 +- src/keyboard.c | 3 +-- src/midi.c | 7 +++++-- src/oscsettings.c | 3 +-- src/performance.c | 2 +- src/performance.h | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/flash.c b/src/flash.c index 4372163..ba73dfb 100644 --- a/src/flash.c +++ b/src/flash.c @@ -472,7 +472,7 @@ static void download_patches(struct patchpool *pp) encoded = curl_author_needs_to_take_a_dump(pp->names[i]); snprintf(url, sizeof(url), BASE_URL "patches/%s", encoded); free(encoded); - snprintf(target, sizeof(target), SIMPLE_PATCHES_FOLDER "%s", pp->names[i]); + snprintf(target, sizeof(target), SIMPLE_PATCHES_FOLDER "/%s", pp->names[i]); download(url, target, 0); done++; } diff --git a/src/keyboard.c b/src/keyboard.c index f434996..fc16ba8 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -193,8 +193,7 @@ static void autobuild(int sk, char *folder) n_files = 0; while((entry = readdir(d))) { if(entry->d_name[0] == '.') continue; - strncpy(fullname, folder, sizeof(fullname)); - strncat(fullname, entry->d_name, sizeof(fullname)); + snprintf(fullname, sizeof(fullname), "%s/%s", folder, entry->d_name); lstat(fullname, &s); if(!S_ISDIR(s.st_mode)) { c = strrchr(entry->d_name, '.'); diff --git a/src/midi.c b/src/midi.c index 7deaa4c..d5b708c 100644 --- a/src/midi.c +++ b/src/midi.c @@ -372,8 +372,7 @@ static void autobuild(int sn, char *folder) n_files = 0; while((entry = readdir(d))) { if(entry->d_name[0] == '.') continue; - strncpy(fullname, folder, sizeof(fullname)); - strncat(fullname, entry->d_name, sizeof(fullname)); + snprintf(fullname, sizeof(fullname), "%s/%s", folder, entry->d_name); lstat(fullname, &s); if(!S_ISDIR(s.st_mode)) { c = strrchr(entry->d_name, '.'); @@ -400,6 +399,7 @@ static void autobuild_callback(mtk_event *e, void *arg) char note[8]; int notecode; char filename[384]; + int i; mtk_req(appid, note, sizeof(note), "e_note.text"); mtk_req(appid, filename, sizeof(filename), "e_filename.text"); @@ -412,6 +412,9 @@ static void autobuild_callback(mtk_event *e, void *arg) messagebox("Auto build failed", "Invalid starting note"); return; } + i = strlen(filename); + if(filename[i-1] == '/') + filename[i-1] = 0x00; autobuild(notecode, filename); update_list(); } diff --git a/src/oscsettings.c b/src/oscsettings.c index 351427d..e968ea9 100644 --- a/src/oscsettings.c +++ b/src/oscsettings.c @@ -196,8 +196,7 @@ static void autobuild(int si, char *folder) n_files = 0; while((entry = readdir(d))) { if(entry->d_name[0] == '.') continue; - strncpy(fullname, folder, sizeof(fullname)); - strncat(fullname, entry->d_name, sizeof(fullname)); + snprintf(fullname, sizeof(fullname), "%s/%s", folder, entry->d_name); lstat(fullname, &s); if(!S_ISDIR(s.st_mode)) { c = strrchr(entry->d_name, '.'); diff --git a/src/performance.c b/src/performance.c index c989ef1..aaa0e05 100644 --- a/src/performance.c +++ b/src/performance.c @@ -159,7 +159,7 @@ static void add_simple_patches() return; while((entry = readdir(d))) { if(entry->d_name[0] == '.') continue; - strncpy(fullname, SIMPLE_PATCHES_FOLDER, sizeof(fullname)); + strncpy(fullname, SIMPLE_PATCHES_FOLDER"/", sizeof(fullname)); strncat(fullname, entry->d_name, sizeof(fullname)); lstat(fullname, &s); if(!S_ISDIR(s.st_mode)) { diff --git a/src/performance.h b/src/performance.h index 5d72358..82e2a66 100644 --- a/src/performance.h +++ b/src/performance.h @@ -18,7 +18,7 @@ #ifndef __PERFORMANCE_H #define __PERFORMANCE_H -#define SIMPLE_PATCHES_FOLDER "/ssd/patchpool/" +#define SIMPLE_PATCHES_FOLDER "/ssd/patchpool" void init_performance(); void open_performance_window();