- int errsv = GetLastError ();
- gchar *emsg = g_win32_error_message (errsv);
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_win32_error (errsv),
- _("Error closing handle: %s"),
- emsg);
- g_free (emsg);
- return FALSE;
+ if (close (win32_stream->priv->fd) < 0)
+ {
+ g_set_error_literal (error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ g_strerror (errno));
+ return FALSE;
+ }
+ }
+ else
+ {
+ res = CloseHandle (win32_stream->priv->handle);
+ if (!res)
+ {
+ int errsv = GetLastError ();
+ gchar *emsg = g_win32_error_message (errsv);
+
+ g_set_error (error, G_IO_ERROR,
+ g_io_error_from_win32_error (errsv),
+ _("Error closing handle: %s"),
+ emsg);
+ g_free (emsg);
+ return FALSE;
+ }