diff options
author | Mathias Hasselmann <mathias@openismus.com> | 2012-10-18 23:52:14 +0200 |
---|---|---|
committer | Juan A. Suarez Romero <jasuarez@igalia.com> | 2012-10-22 16:53:42 +0000 |
commit | ac2c27e5796d05c45de1c71fc29f6cbf52f811ff (patch) | |
tree | a4cadb50fb2e88bb65f7168a617cae2c52efae5b /libs | |
parent | c5e6f4457749e2719d3d96c02e7e3fd9b5ace1e3 (diff) | |
download | grilo-ac2c27e5796d05c45de1c71fc29f6cbf52f811ff.tar.gz |
net: Add PID to captured .ini file, as grl-net-mock-data-%PID.ini
Thus, we can run several times the application and
capture the data without loosing previous captures.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/net/grl-net-private.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libs/net/grl-net-private.c b/libs/net/grl-net-private.c index a0c788f..36865c4 100644 --- a/libs/net/grl-net-private.c +++ b/libs/net/grl-net-private.c @@ -130,22 +130,25 @@ dump_data (SoupURI *uri, /* Write request content to file in capture directory. */ char *request_filename = build_request_filename (uri_string); - char *filename = g_build_filename (capture_dir, request_filename, NULL); + char *path = g_build_filename (capture_dir, request_filename, NULL); GError *error = NULL; - if (!g_file_set_contents (filename, buffer, length, &error)) { + if (!g_file_set_contents (path, buffer, length, &error)) { GRL_WARNING ("Could not write contents to disk: %s", error->message); g_error_free (error); } - g_free (filename); + g_free (path); - /* Append record about the just written file to "grl-mock-data.ini" + /* Append record about the just written file to "grl-net-mock-data-%PID.ini" * in the capture directory. */ - filename = g_build_filename (capture_dir, "grl-mock-data.ini", NULL); - FILE *stream = g_fopen (filename, "at"); + char *filename = g_strdup_printf ("grl-net-mock-data-%u.ini", getpid()); + path = g_build_filename (capture_dir, filename, NULL); g_free (filename); + FILE *stream = g_fopen (path, "at"); + g_free (path); + if (!stream) { GRL_WARNING ("Could not write contents to disk: %s", g_strerror (errno)); } else { |