From 174cb1ffb10d846834fdfd1538d128744dffd65c Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 21 Jun 2015 11:55:40 -0700 Subject: HTML export: need to work harder to find the pictures Simply looking at the filename in the picture structure isn't enough (now, arguably one might say that it should be and that that data structure should be updated, but that's not how other parts of Subsurface have implemented things so I don't want to break that assumption here). So instead we look up where the pictures actually was loaded from and then copy that file into the right location. Signed-off-by: Dirk Hohndel --- qthelper.cpp | 8 ++++---- qthelperfromc.h | 2 +- save-html.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/qthelper.cpp b/qthelper.cpp index abf8641ae..09d383bc8 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -369,11 +369,11 @@ extern "C" char *get_file_name(const char *fileName) return strdup(fileInfo.fileName().toUtf8()); } -extern "C" void copy_image_and_overwrite(const char *cfileName, const char *cnewName) +extern "C" void copy_image_and_overwrite(const char *cfileName, const char *path, const char *cnewName) { - QString fileName = QString::fromUtf8(cfileName); - QString newName = QString::fromUtf8(cnewName); - newName += QFileInfo(cfileName).fileName(); + QString fileName(cfileName); + QString newName(path); + newName += cnewName; QFile file(newName); if (file.exists()) file.remove(); diff --git a/qthelperfromc.h b/qthelperfromc.h index 9a5e9551a..e48e3b1c4 100644 --- a/qthelperfromc.h +++ b/qthelperfromc.h @@ -7,7 +7,7 @@ void updateWindowTitle(); bool isCloudUrl(const char *filename); void subsurface_mkdir(const char *dir); char *get_file_name(const char *fileName); -void copy_image_and_overwrite(const char *cfileName, const char *cnewName); +void copy_image_and_overwrite(const char *cfileName, const char *path, const char *cnewName); char *hashstring(char *filename); bool picture_exists(struct picture *picture); const char *local_file_path(struct picture *picture); diff --git a/save-html.c b/save-html.c index c50968e81..64ce94f66 100644 --- a/save-html.c +++ b/save-html.c @@ -23,10 +23,10 @@ void save_photos(struct membuffer *b, const char *photos_dir, struct dive *dive) do { put_string(b, separator); separator = ", "; - char *fname = get_file_name(pic->filename); + char *fname = get_file_name(local_file_path(pic)); put_format(b, "{\"filename\":\"%s\"}", fname); + copy_image_and_overwrite(local_file_path(pic), photos_dir, fname); free(fname); - copy_image_and_overwrite(pic->filename, photos_dir); pic = pic->next; } while (pic); put_string(b, "],"); -- cgit v1.2.3-70-g09d2