* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include "config.h"
-
#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
#include <gstdio.h>
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
#include <unistd.h>
#endif
strcpy (template, "foobar");
fd = g_mkstemp (template);
if (fd != -1)
- g_warning ("g_mkstemp works even if template doesn't contain XXXXXX");
- close (fd);
+ {
+ g_warning ("g_mkstemp works even if template doesn't contain XXXXXX");
+ close (fd);
+ }
strcpy (template, "foobarXXX");
fd = g_mkstemp (template);
if (fd != -1)
- g_warning ("g_mkstemp works even if template contains less than six X");
- close (fd);
+ {
+ g_warning ("g_mkstemp works even if template contains less than six X");
+ close (fd);
+ }
strcpy (template, "fooXXXXXX");
fd = g_mkstemp (template);
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include "config.h"
-
#undef GLIB_COMPILATION
#include <stdio.h>
#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
#include <unistd.h>
#endif
chars[n] = 0;
if (strcmp (chars, hello) != 0)
g_error ("wrote '%s', but got '%s'\n", hello, chars);
-
- close (fd);
+ if (fd != -1)
+ close (fd);
remove (template);
error = NULL;
else
g_print ("g_file_open_tmp correctly returns error: %s\n", error->message);
}
- close (fd);
+ if (fd != -1)
+ close (fd);
g_clear_error (&error);
g_free (name_used);
#endif
g_error ("g_file_open_tmp didn't work for template '%s': %s\n", template, error->message);
else if (g_test_verbose())
g_print ("g_file_open_tmp for template '%s' used name '%s'\n", template, name_used);
- close (fd);
+ if (fd != -1)
+ close (fd);
g_clear_error (&error);
remove (name_used);
g_free (name_used);
fd = g_file_open_tmp (NULL, &name_used, &error);
if (fd == -1)
g_error ("g_file_open_tmp didn't work for a NULL template: %s\n", error->message);
- close (fd);
+ else
+ close (fd);
g_clear_error (&error);
remove (name_used);
g_free (name_used);