| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | #include <glib/glib.h>
 | 
					
						
							|  |  |  | #include <glib/gstdio.h>
 | 
					
						
							|  |  |  | #include <gio/gio.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-04 16:32:01 +08:00
										 |  |  | #ifdef G_OS_UNIX
 | 
					
						
							|  |  |  | #include <unistd.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-09-09 12:46:33 +00:00
										 |  |  | #ifdef G_OS_WIN32
 | 
					
						
							|  |  |  | #include <io.h> /* for close() */
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2013-11-04 16:32:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  | static const char *original_data = "This is some test data that we can put in a file..."; | 
					
						
							|  |  |  | static const char *new_data = "new data.."; | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | verify_pos (GIOStream *iostream, goffset expected_pos) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   goffset pos; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   pos = g_seekable_tell (G_SEEKABLE (iostream)); | 
					
						
							|  |  |  |   g_assert_cmpint (pos, ==, expected_pos); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   pos = g_seekable_tell (G_SEEKABLE (g_io_stream_get_input_stream (iostream))); | 
					
						
							|  |  |  |   g_assert_cmpint (pos, ==, expected_pos); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   pos = g_seekable_tell (G_SEEKABLE (g_io_stream_get_output_stream (iostream))); | 
					
						
							|  |  |  |   g_assert_cmpint (pos, ==, expected_pos); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | verify_iostream (GFileIOStream *file_iostream) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   gboolean res; | 
					
						
							| 
									
										
										
										
											2020-11-20 20:29:28 +01:00
										 |  |  |   gssize skipped; | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   GIOStream *iostream; | 
					
						
							|  |  |  |   GError *error; | 
					
						
							|  |  |  |   GInputStream *in; | 
					
						
							|  |  |  |   GOutputStream *out; | 
					
						
							|  |  |  |   char buffer[1024]; | 
					
						
							|  |  |  |   gsize n_bytes; | 
					
						
							|  |  |  |   char *modified_data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   iostream = G_IO_STREAM (file_iostream); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   verify_pos (iostream, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   in = g_io_stream_get_input_stream (iostream); | 
					
						
							|  |  |  |   out = g_io_stream_get_output_stream (iostream); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   res = g_input_stream_read_all (in, buffer, 20, &n_bytes, NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							| 
									
										
										
										
											2014-12-03 05:57:29 -05:00
										 |  |  |   g_assert_cmpmem (buffer, n_bytes, original_data, 20); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   verify_pos (iostream, 20); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   res = g_seekable_seek (G_SEEKABLE (iostream), | 
					
						
							|  |  |  | 			 -10, G_SEEK_END, | 
					
						
							|  |  |  | 			 NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  |   verify_pos (iostream, strlen (original_data) - 10); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   res = g_input_stream_read_all (in, buffer, 20, &n_bytes, NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							| 
									
										
										
										
											2014-12-03 05:57:29 -05:00
										 |  |  |   g_assert_cmpmem (buffer, n_bytes, original_data + strlen (original_data) - 10, 10); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   verify_pos (iostream, strlen (original_data)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-29 06:02:59 +02:00
										 |  |  |   res = g_seekable_seek (G_SEEKABLE (iostream), | 
					
						
							|  |  |  | 			 10, G_SEEK_SET, | 
					
						
							|  |  |  | 			 NULL, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   res = g_input_stream_skip (in, 5, NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res == 5); | 
					
						
							|  |  |  |   verify_pos (iostream, 15); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-20 20:29:28 +01:00
										 |  |  |   skipped = g_input_stream_skip (in, 10000, NULL, NULL); | 
					
						
							|  |  |  |   g_assert_cmpint (skipped, >=, 0); | 
					
						
							|  |  |  |   g_assert ((gsize) skipped == strlen (original_data) - 15); | 
					
						
							| 
									
										
										
										
											2013-10-29 06:02:59 +02:00
										 |  |  |   verify_pos (iostream, strlen (original_data)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   res = g_seekable_seek (G_SEEKABLE (iostream), | 
					
						
							|  |  |  | 			 10, G_SEEK_SET, | 
					
						
							|  |  |  | 			 NULL, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   verify_pos (iostream, 10); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   res = g_output_stream_write_all (out, new_data, strlen (new_data), | 
					
						
							|  |  |  | 				   &n_bytes, NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  |   g_assert_cmpint (n_bytes, ==, strlen (new_data)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   verify_pos (iostream, 10 + strlen (new_data)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   res = g_seekable_seek (G_SEEKABLE (iostream), | 
					
						
							|  |  |  | 			 0, G_SEEK_SET, | 
					
						
							|  |  |  | 			 NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  |   verify_pos (iostream, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   res = g_input_stream_read_all (in, buffer, strlen (original_data), &n_bytes, NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  |   g_assert_cmpint ((int)n_bytes, ==, strlen (original_data)); | 
					
						
							|  |  |  |   buffer[n_bytes] = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   modified_data = g_strdup (original_data); | 
					
						
							|  |  |  |   memcpy (modified_data + 10, new_data, strlen (new_data)); | 
					
						
							|  |  |  |   g_assert_cmpstr (buffer, ==, modified_data); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   verify_pos (iostream, strlen (original_data)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   res = g_seekable_seek (G_SEEKABLE (iostream), | 
					
						
							|  |  |  | 			 0, G_SEEK_SET, | 
					
						
							|  |  |  | 			 NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  |   verify_pos (iostream, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   res = g_output_stream_close (out, NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   res = g_input_stream_read_all (in, buffer, 15, &n_bytes, NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							| 
									
										
										
										
											2014-12-03 05:57:29 -05:00
										 |  |  |   g_assert_cmpmem (buffer, n_bytes, modified_data, 15); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   error = NULL; | 
					
						
							|  |  |  |   res = g_output_stream_write_all (out, new_data, strlen (new_data), | 
					
						
							|  |  |  | 				   &n_bytes, NULL, &error); | 
					
						
							|  |  |  |   g_assert (!res); | 
					
						
							| 
									
										
										
										
											2010-09-03 15:35:44 -04:00
										 |  |  |   g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED); | 
					
						
							|  |  |  |   g_error_free (error); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   error = NULL; | 
					
						
							|  |  |  |   res = g_io_stream_close (iostream, NULL, &error); | 
					
						
							| 
									
										
										
										
											2010-09-03 15:35:44 -04:00
										 |  |  |   g_assert (res); | 
					
						
							|  |  |  |   g_assert_no_error (error); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   g_free (modified_data); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | test_g_file_open_readwrite (void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   char *tmp_file; | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   int fd; | 
					
						
							|  |  |  |   gboolean res; | 
					
						
							|  |  |  |   GFileIOStream *file_iostream; | 
					
						
							|  |  |  |   char *path; | 
					
						
							|  |  |  |   GFile *file; | 
					
						
							|  |  |  |   GError *error; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   fd = g_file_open_tmp ("readwrite_XXXXXX", | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  | 			&tmp_file, NULL); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   g_assert (fd != -1); | 
					
						
							|  |  |  |   close (fd); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   res = g_file_set_contents (tmp_file, | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | 			     original_data, -1, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-23 18:19:16 +01:00
										 |  |  |   path = g_build_filename (g_get_tmp_dir (), "g-a-nonexisting-file", NULL); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   file = g_file_new_for_path (path); | 
					
						
							|  |  |  |   g_free (path); | 
					
						
							|  |  |  |   error = NULL; | 
					
						
							|  |  |  |   file_iostream = g_file_open_readwrite (file, NULL, &error); | 
					
						
							|  |  |  |   g_assert (file_iostream == NULL); | 
					
						
							|  |  |  |   g_assert (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)); | 
					
						
							|  |  |  |   g_error_free (error); | 
					
						
							|  |  |  |   g_object_unref (file); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   file = g_file_new_for_path (tmp_file); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   error = NULL; | 
					
						
							|  |  |  |   file_iostream = g_file_open_readwrite (file, NULL, &error); | 
					
						
							|  |  |  |   g_assert (file_iostream != NULL); | 
					
						
							| 
									
										
										
										
											2010-09-03 15:32:32 -04:00
										 |  |  |   g_object_unref (file); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   verify_iostream (file_iostream); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_object_unref (file_iostream); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   g_unlink (tmp_file); | 
					
						
							| 
									
										
										
										
											2009-06-30 19:08:46 +02:00
										 |  |  |   g_free (tmp_file); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | test_g_file_create_readwrite (void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   char *tmp_file; | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   int fd; | 
					
						
							|  |  |  |   gboolean res; | 
					
						
							|  |  |  |   GFileIOStream *file_iostream; | 
					
						
							|  |  |  |   GOutputStream *out; | 
					
						
							|  |  |  |   GFile *file; | 
					
						
							|  |  |  |   GError *error; | 
					
						
							|  |  |  |   gsize n_bytes; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   fd = g_file_open_tmp ("readwrite_XXXXXX", | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  | 			&tmp_file, NULL); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   g_assert (fd != -1); | 
					
						
							|  |  |  |   close (fd); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   file = g_file_new_for_path (tmp_file); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   error = NULL; | 
					
						
							|  |  |  |   file_iostream = g_file_create_readwrite (file, 0, NULL, &error); | 
					
						
							|  |  |  |   g_assert (file_iostream == NULL); | 
					
						
							| 
									
										
										
										
											2010-09-03 15:44:28 -04:00
										 |  |  |   g_assert_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS); | 
					
						
							|  |  |  |   g_error_free (error); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   g_unlink (tmp_file); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   file_iostream = g_file_create_readwrite (file, 0, NULL, &error); | 
					
						
							|  |  |  |   g_assert (file_iostream != NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   out = g_io_stream_get_output_stream (G_IO_STREAM (file_iostream)); | 
					
						
							|  |  |  |   res = g_output_stream_write_all (out, original_data, strlen (original_data), | 
					
						
							|  |  |  | 				   &n_bytes, NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  |   g_assert_cmpint (n_bytes, ==, strlen (original_data)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   res = g_seekable_seek (G_SEEKABLE (file_iostream), | 
					
						
							|  |  |  | 			 0, G_SEEK_SET, | 
					
						
							|  |  |  | 			 NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   verify_iostream (file_iostream); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_object_unref (file_iostream); | 
					
						
							| 
									
										
										
										
											2010-09-03 15:33:28 -04:00
										 |  |  |   g_object_unref (file); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   g_unlink (tmp_file); | 
					
						
							|  |  |  |   g_free (tmp_file); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | test_g_file_replace_readwrite (void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   char *tmp_file, *backup, *data; | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   int fd; | 
					
						
							|  |  |  |   gboolean res; | 
					
						
							|  |  |  |   GFileIOStream *file_iostream; | 
					
						
							|  |  |  |   GInputStream *in; | 
					
						
							|  |  |  |   GOutputStream *out; | 
					
						
							|  |  |  |   GFile *file; | 
					
						
							|  |  |  |   GError *error; | 
					
						
							|  |  |  |   char buffer[1024]; | 
					
						
							|  |  |  |   gsize n_bytes; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   fd = g_file_open_tmp ("readwrite_XXXXXX", | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  | 			&tmp_file, NULL); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   g_assert (fd != -1); | 
					
						
							|  |  |  |   close (fd); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   res = g_file_set_contents (tmp_file, | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | 			     new_data, -1, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   file = g_file_new_for_path (tmp_file); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   error = NULL; | 
					
						
							|  |  |  |   file_iostream = g_file_replace_readwrite (file, NULL, | 
					
						
							|  |  |  | 					    TRUE, 0, NULL, &error); | 
					
						
							|  |  |  |   g_assert (file_iostream != NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   in = g_io_stream_get_input_stream (G_IO_STREAM (file_iostream)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* Ensure its empty */ | 
					
						
							|  |  |  |   res = g_input_stream_read_all (in, buffer, sizeof buffer, &n_bytes, NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  |   g_assert_cmpint ((int)n_bytes, ==, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   out = g_io_stream_get_output_stream (G_IO_STREAM (file_iostream)); | 
					
						
							|  |  |  |   res = g_output_stream_write_all (out, original_data, strlen (original_data), | 
					
						
							|  |  |  | 				   &n_bytes, NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  |   g_assert_cmpint (n_bytes, ==, strlen (original_data)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   res = g_seekable_seek (G_SEEKABLE (file_iostream), | 
					
						
							|  |  |  | 			 0, G_SEEK_SET, | 
					
						
							|  |  |  | 			 NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   verify_iostream (file_iostream); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_object_unref (file_iostream); | 
					
						
							| 
									
										
										
										
											2010-09-03 15:34:12 -04:00
										 |  |  |   g_object_unref (file); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   backup = g_strconcat (tmp_file, "~", NULL); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  |   res = g_file_get_contents (backup, | 
					
						
							|  |  |  | 			     &data, | 
					
						
							|  |  |  | 			     NULL, NULL); | 
					
						
							|  |  |  |   g_assert (res); | 
					
						
							|  |  |  |   g_assert_cmpstr (data, ==, new_data); | 
					
						
							|  |  |  |   g_free (data); | 
					
						
							|  |  |  |   g_unlink (backup); | 
					
						
							|  |  |  |   g_free (backup); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-29 18:24:08 +02:00
										 |  |  |   g_unlink (tmp_file); | 
					
						
							|  |  |  |   g_free (tmp_file); | 
					
						
							| 
									
										
										
										
											2009-05-13 13:06:58 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int | 
					
						
							|  |  |  | main (int   argc, | 
					
						
							|  |  |  |       char *argv[]) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_test_init (&argc, &argv, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_test_add_func ("/readwrite/test_g_file_open_readwrite", | 
					
						
							|  |  |  | 		   test_g_file_open_readwrite); | 
					
						
							|  |  |  |   g_test_add_func ("/readwrite/test_g_file_create_readwrite", | 
					
						
							|  |  |  | 		   test_g_file_create_readwrite); | 
					
						
							|  |  |  |   g_test_add_func ("/readwrite/test_g_file_replace_readwrite", | 
					
						
							|  |  |  | 		   test_g_file_replace_readwrite); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return g_test_run(); | 
					
						
							|  |  |  | } |