test: Use g_file_set_contents() to dump file 98/297598/1 accepted/tizen/8.0/unified/20231005.092932 accepted/tizen/unified/20230822.162242
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 21 Aug 2023 10:21:11 +0000 (19:21 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 21 Aug 2023 10:23:01 +0000 (19:23 +0900)
[Version] 0.4.20
[Issue Type] Refactoring

Change-Id: I00411336b80159693394c23089f6bfeab74a8fba
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
test/webrtc_test.c

index 1ec94daf2ccf39edca9e6da3c392cb5845289bf6..aa424059687aeaa83820bd43af8b3e8bee6944b5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.4.19
+Version:    0.4.20
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index feb3a986ff7f34f64e86c5a54e53627186b6f9ef..d1707750f37670075527df78b9bce8addc371495 100644 (file)
@@ -1426,29 +1426,18 @@ static void __data_channel_open_cb(webrtc_data_channel_h channel, void *user_dat
 
 static void __file_dump(const gchar *file_name, void *src_buffer, int size)
 {
-       int fd;
-       gchar *full_path;
+       g_autofree gchar *full_path = NULL;
+       g_autoptr(GError) error = NULL;
 
        RET_IF(!file_name, "file_name is NULL");
        RET_IF(!src_buffer, "src_buffer is NULL");
 
        full_path = g_strdup_printf("/tmp/%s", file_name);
 
-       fd = open(full_path, O_WRONLY | O_CREAT, 0644);
-       if (fd == -1) {
-               g_print("failed to open file[%s]\n", full_path);
-               goto end;
-       }
-
-       if (write(fd, src_buffer, size) == -1)
-               g_print("failed to write file[%s]\n", full_path);
-
-       g_print("[%s, %d bytes] is ready\n", full_path, size);
-
-end:
-       g_free(full_path);
-       if (fd != -1)
-               close(fd);
+       if (!g_file_set_contents((const gchar *)full_path, (const gchar *)src_buffer, (gssize)size, &error))
+               g_print("__file_dump(), failed to g_file_set_contents[%s], error:%s\n", full_path, error ? error->message : "none");
+       else
+               g_print("__file_dump(), [%s, %d bytes] is ready\n", full_path, size);
 }
 
 static int __convert_string_to_gint64(gchar *str, gint64 *result)