mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:23:25 +00:00
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 <dirk@hohndel.org>
This commit is contained in:
parent
31fbc16785
commit
174cb1ffb1
3 changed files with 7 additions and 7 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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, "],");
|
||||
|
|
Loading…
Add table
Reference in a new issue