From 1bcb534e16f0559f50b4acb4a07fdf016ee79966 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Sun, 14 May 2023 18:36:29 -0700 Subject: [PATCH] libsysprof-analyze: add api to get size for file --- src/libsysprof-analyze/sysprof-document-file.c | 17 +++++++++++++++++ src/libsysprof-analyze/sysprof-document-file.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/libsysprof-analyze/sysprof-document-file.c b/src/libsysprof-analyze/sysprof-document-file.c index a3f33e8e..fe7fd4cd 100644 --- a/src/libsysprof-analyze/sysprof-document-file.c +++ b/src/libsysprof-analyze/sysprof-document-file.c @@ -195,3 +195,20 @@ sysprof_document_file_read (SysprofDocumentFile *self) return g_steal_pointer (&input); } + +gsize +sysprof_document_file_get_size (SysprofDocumentFile *self) +{ + gsize size = 0; + + g_return_val_if_fail (SYSPROF_IS_DOCUMENT_FILE (self), 0); + + for (guint i = 0; i < self->file_chunks->len; i++) + { + SysprofDocumentFileChunk *file_chunk = g_ptr_array_index (self->file_chunks, i); + + size += sysprof_document_file_chunk_get_size (file_chunk); + } + + return size; +} diff --git a/src/libsysprof-analyze/sysprof-document-file.h b/src/libsysprof-analyze/sysprof-document-file.h index 3ca728dc..4865e469 100644 --- a/src/libsysprof-analyze/sysprof-document-file.h +++ b/src/libsysprof-analyze/sysprof-document-file.h @@ -37,5 +37,7 @@ SYSPROF_AVAILABLE_IN_ALL GBytes *sysprof_document_file_dup_bytes (SysprofDocumentFile *self); SYSPROF_AVAILABLE_IN_ALL GInputStream *sysprof_document_file_read (SysprofDocumentFile *self); +SYSPROF_AVAILABLE_IN_ALL +gsize sysprof_document_file_get_size (SysprofDocumentFile *self); G_END_DECLS