From dd14807c8cdff2f486f5da832490ff958c87ba62 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 26 Apr 2016 11:02:17 +0100 Subject: improve error returns from pdf save API --- desktop/save_pdf.c | 18 +++++++++--------- desktop/save_pdf.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'desktop') diff --git a/desktop/save_pdf.c b/desktop/save_pdf.c index c54421cdc..8fd67959f 100644 --- a/desktop/save_pdf.c +++ b/desktop/save_pdf.c @@ -784,9 +784,9 @@ void pdf_end(void) } /** saves the pdf with optional encryption */ -void save_pdf(const char *path) +nserror save_pdf(const char *path) { - bool success = false; + nserror res = NSERROR_OK; if (option_enable_PDF_password && owner_pass != NULL ) { HPDF_SetPassword(pdf_doc, owner_pass, user_pass); @@ -796,17 +796,16 @@ void save_pdf(const char *path) } if (path != NULL) { - if (HPDF_SaveToFile(pdf_doc, path) != HPDF_OK) + if (HPDF_SaveToFile(pdf_doc, path) != HPDF_OK) { remove(path); - else - success = true; + res = NSERROR_SAVE_FAILED; + } } - if (!success) - warn_user("Unable to save PDF file.", 0); - HPDF_Free(pdf_doc); pdf_doc = NULL; + + return res; } @@ -982,7 +981,8 @@ void pdfw_gs_dash(HPDF_Page page, DashPattern_e dash) } #else -void save_pdf(const char *path) +nserror save_pdf(const char *path) { + return NSERROR_NOT_IMPLEMENTED; } #endif /* WITH_PDF_EXPORT */ diff --git a/desktop/save_pdf.h b/desktop/save_pdf.h index d02c356e8..b90c5a969 100644 --- a/desktop/save_pdf.h +++ b/desktop/save_pdf.h @@ -36,6 +36,6 @@ bool pdf_next_page(void); /**Close pdf document and save changes to file*/ void pdf_end(void); -void save_pdf(const char *path); +nserror save_pdf(const char *path); #endif /*NETSURF_PDF_PLOTTERS_H*/ -- cgit v1.2.3