[evince/wip/chpe/load-fd: 845/845] tiff: Implement loading from file descriptor
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/chpe/load-fd: 845/845] tiff: Implement loading from file descriptor
- Date: Wed, 17 Nov 2021 23:04:32 +0000 (UTC)
commit 498ed6166a72fb2be621e76f1a3c2a524ce20ce0
Author: Christian Persch <chpe src gnome org>
Date: Thu Nov 18 00:03:14 2021 +0100
tiff: Implement loading from file descriptor
FIXME: Implement save when source is FD.
backend/tiff/tiff-document.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
---
diff --git a/backend/tiff/tiff-document.c b/backend/tiff/tiff-document.c
index 6dd6d88b0..c6a817e4a 100644
--- a/backend/tiff/tiff-document.c
+++ b/backend/tiff/tiff-document.c
@@ -135,6 +135,35 @@ tiff_document_load (EvDocument *document,
return TRUE;
}
+static gboolean
+tiff_document_load_fd (EvDocument *document,
+ int fd,
+ EvDocumentLoadFlags flags,
+ GCancellable *cancellable,
+ GError **error)
+{
+ TiffDocument *tiff_document = TIFF_DOCUMENT (document);
+ TIFF *tiff;
+
+ push_handlers ();
+ tiff = TIFFFdOpen (fd, "document.tiff" /* fake filename */, "r");
+ pop_handlers ();
+
+ if (!tiff) {
+ g_set_error_literal (error,
+ EV_DOCUMENT_ERROR,
+ EV_DOCUMENT_ERROR_INVALID,
+ _("Invalid document"));
+ return FALSE;
+ }
+
+
+ tiff_document->tiff = tiff;
+ g_clear_pointer (&tiff_document->uri, g_free);
+
+ return TRUE;
+}
+
static gboolean
tiff_document_save (EvDocument *document,
const char *uri,
@@ -142,6 +171,13 @@ tiff_document_save (EvDocument *document,
{
TiffDocument *tiff_document = TIFF_DOCUMENT (document);
+ /* FIXME: create an output stream for the uri, then splice the source fd to it */
+ if (tiff_document->uri == NULL) {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ "Cannot save document from FD");
+ return FALSE;
+ }
+
return ev_xfer_uri_simple (tiff_document->uri, uri, error);
}
@@ -451,6 +487,7 @@ tiff_document_class_init (TiffDocumentClass *klass)
gobject_class->finalize = tiff_document_finalize;
ev_document_class->load = tiff_document_load;
+ ev_document_class->load_fd = tiff_document_load_fd;
ev_document_class->save = tiff_document_save;
ev_document_class->get_n_pages = tiff_document_get_n_pages;
ev_document_class->get_page_size = tiff_document_get_page_size;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]