libsysprof-capture: add sysprof_capture_reader_find_file()

This commit is contained in:
Christian Hergert
2019-05-28 22:46:50 -07:00
parent 716b913347
commit 7743a047b6
2 changed files with 34 additions and 0 deletions

View File

@ -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;
}

View File

@ -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,