[grilo] net: Add PID to captured .ini file, as grl-net-mock-data-%PID.ini



commit ac2c27e5796d05c45de1c71fc29f6cbf52f811ff
Author: Mathias Hasselmann <mathias openismus com>
Date:   Thu Oct 18 23:52:14 2012 +0200

    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.

 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 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]