mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-profile: add recording helper to capture file data
We might have the file data from the peer and can specify the data in the capture writer directly. It may be useful to allow compressing these too, but we can deal with that at a later time.
This commit is contained in:
@ -37,5 +37,9 @@ SysprofSpawnable *_sysprof_recording_get_spawnable (SysprofRecording *s
|
||||
DexFuture *_sysprof_recording_add_file (SysprofRecording *self,
|
||||
const char *path,
|
||||
gboolean compress);
|
||||
void _sysprof_recording_add_file_data (SysprofRecording *self,
|
||||
const char *path,
|
||||
const char *contents,
|
||||
gssize length);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@ -454,3 +454,35 @@ _sysprof_recording_add_file (SysprofRecording *self,
|
||||
g_steal_pointer (&add_file),
|
||||
(GDestroyNotify)add_file_free);
|
||||
}
|
||||
|
||||
void
|
||||
_sysprof_recording_add_file_data (SysprofRecording *self,
|
||||
const char *path,
|
||||
const char *contents,
|
||||
gssize length)
|
||||
{
|
||||
g_return_if_fail (SYSPROF_IS_RECORDING (self));
|
||||
g_return_if_fail (path != NULL);
|
||||
g_return_if_fail (contents != NULL);
|
||||
|
||||
if (length < 0)
|
||||
length = strlen (contents);
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
gsize to_write = MIN (length, ((4096*8)-sizeof (SysprofCaptureFileChunk)));
|
||||
|
||||
if (!sysprof_capture_writer_add_file (self->writer,
|
||||
SYSPROF_CAPTURE_CURRENT_TIME,
|
||||
-1,
|
||||
-1,
|
||||
path,
|
||||
to_write == length,
|
||||
(const guint8 *)contents,
|
||||
to_write))
|
||||
break;
|
||||
|
||||
length -= to_write;
|
||||
contents += to_write;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user