From 7743a047b6cfcdbf1f2fe45987f9672da4eb2c2c Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 28 May 2019 22:46:50 -0700 Subject: [PATCH] libsysprof-capture: add sysprof_capture_reader_find_file() --- .../sysprof-capture-reader.c | 31 +++++++++++++++++++ .../sysprof-capture-reader.h | 3 ++ 2 files changed, 34 insertions(+) diff --git a/src/libsysprof-capture/sysprof-capture-reader.c b/src/libsysprof-capture/sysprof-capture-reader.c index 567db710..1a1fa7ac 100644 --- a/src/libsysprof-capture/sysprof-capture-reader.c +++ b/src/libsysprof-capture/sysprof-capture-reader.c @@ -1285,3 +1285,34 @@ sysprof_capture_reader_get_byte_order (SysprofCaptureReader *self) return self->endian; } + +const SysprofCaptureFileChunk * +sysprof_capture_reader_find_file (SysprofCaptureReader *self, + const gchar *path) +{ + SysprofCaptureFrameType type; + + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (path != NULL, NULL); + + while (sysprof_capture_reader_peek_type (self, &type)) + { + if (type == SYSPROF_CAPTURE_FRAME_FILE_CHUNK) + { + const SysprofCaptureFileChunk *fc; + + if (!(fc = sysprof_capture_reader_read_file (self))) + break; + + if (g_strcmp0 (path, fc->path) == 0) + return fc; + + continue; + } + + if (!sysprof_capture_reader_skip (self)) + break; + } + + return NULL; +} diff --git a/src/libsysprof-capture/sysprof-capture-reader.h b/src/libsysprof-capture/sysprof-capture-reader.h index 49b30717..c963b6fe 100644 --- a/src/libsysprof-capture/sysprof-capture-reader.h +++ b/src/libsysprof-capture/sysprof-capture-reader.h @@ -100,6 +100,9 @@ SYSPROF_AVAILABLE_IN_ALL void sysprof_capture_reader_set_stat (SysprofCaptureReader *self, const SysprofCaptureStat *st_buf); SYSPROF_AVAILABLE_IN_ALL +const SysprofCaptureFileChunk *sysprof_capture_reader_find_file (SysprofCaptureReader *self, + const gchar *path); +SYSPROF_AVAILABLE_IN_ALL gchar **sysprof_capture_reader_list_files (SysprofCaptureReader *self); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_reader_read_file_fd (SysprofCaptureReader *self,