mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 07:56:17 +01:00
gio/tests/file: use g_file_new_tmp()
Rather than misusing g_file_open_tmp(), misuse g_file_new_tmp() instead. Progress! (Also, gets rid of a compile warning about close() on win32.)
This commit is contained in:
parent
cc4c1e89f4
commit
f43565c822
@ -394,7 +394,7 @@ test_create_delete (gconstpointer d)
|
|||||||
{
|
{
|
||||||
GError *error;
|
GError *error;
|
||||||
CreateDeleteData *data;
|
CreateDeleteData *data;
|
||||||
int tmpfd;
|
GFileIOStream *iostream;
|
||||||
|
|
||||||
data = g_new0 (CreateDeleteData, 1);
|
data = g_new0 (CreateDeleteData, 1);
|
||||||
|
|
||||||
@ -402,14 +402,14 @@ test_create_delete (gconstpointer d)
|
|||||||
data->data = "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ0123456789";
|
data->data = "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ0123456789";
|
||||||
data->pos = 0;
|
data->pos = 0;
|
||||||
|
|
||||||
/* Using tempnam() would be easier here, but causes a compile warning */
|
data->file = g_file_new_tmp ("g_file_create_delete_XXXXXX",
|
||||||
tmpfd = g_file_open_tmp ("g_file_create_delete_XXXXXX",
|
&iostream, NULL);
|
||||||
&data->monitor_path, NULL);
|
g_assert (data->file != NULL);
|
||||||
g_assert_cmpint (tmpfd, !=, -1);
|
g_object_unref (iostream);
|
||||||
close (tmpfd);
|
|
||||||
|
data->monitor_path = g_file_get_path (data->file);
|
||||||
remove (data->monitor_path);
|
remove (data->monitor_path);
|
||||||
|
|
||||||
data->file = g_file_new_for_path (data->monitor_path);
|
|
||||||
g_assert (!g_file_query_exists (data->file, NULL));
|
g_assert (!g_file_query_exists (data->file, NULL));
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
@ -524,7 +524,7 @@ test_replace_load (void)
|
|||||||
{
|
{
|
||||||
ReplaceLoadData *data;
|
ReplaceLoadData *data;
|
||||||
gchar *path;
|
gchar *path;
|
||||||
int tmpfd;
|
GFileIOStream *iostream;
|
||||||
|
|
||||||
data = g_new0 (ReplaceLoadData, 1);
|
data = g_new0 (ReplaceLoadData, 1);
|
||||||
data->again = TRUE;
|
data->again = TRUE;
|
||||||
@ -557,14 +557,14 @@ test_replace_load (void)
|
|||||||
" * make a backup of @file.\n"
|
" * make a backup of @file.\n"
|
||||||
" **/\n";
|
" **/\n";
|
||||||
|
|
||||||
/* Using tempnam() would be easier here, but causes a compile warning */
|
data->file = g_file_new_tmp ("g_file_replace_load_XXXXXX",
|
||||||
tmpfd = g_file_open_tmp ("g_file_replace_load_XXXXXX",
|
&iostream, NULL);
|
||||||
&path, NULL);
|
g_assert (data->file != NULL);
|
||||||
g_assert_cmpint (tmpfd, !=, -1);
|
g_object_unref (iostream);
|
||||||
close (tmpfd);
|
|
||||||
|
path = g_file_get_path (data->file);
|
||||||
remove (path);
|
remove (path);
|
||||||
|
|
||||||
data->file = g_file_new_for_path (path);
|
|
||||||
g_assert (!g_file_query_exists (data->file, NULL));
|
g_assert (!g_file_query_exists (data->file, NULL));
|
||||||
|
|
||||||
data->loop = g_main_loop_new (NULL, FALSE);
|
data->loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
Loading…
Reference in New Issue
Block a user