mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-25 21:46:14 +01:00
gio: add GUnixFDList on win32
FDs are not specific to Unix. win32 has APIs to map CRT fd to/from HANDLE. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
5eaa13f573
commit
5efb84f24a
@ -169,6 +169,7 @@
|
|||||||
#include <gio/gtlsserverconnection.h>
|
#include <gio/gtlsserverconnection.h>
|
||||||
#include <gio/gunixconnection.h>
|
#include <gio/gunixconnection.h>
|
||||||
#include <gio/gunixcredentialsmessage.h>
|
#include <gio/gunixcredentialsmessage.h>
|
||||||
|
#include <gio/gunixfdlist.h>
|
||||||
#include <gio/gunixsocketaddress.h>
|
#include <gio/gunixsocketaddress.h>
|
||||||
#include <gio/gvfs.h>
|
#include <gio/gvfs.h>
|
||||||
#include <gio/gvolume.h>
|
#include <gio/gvolume.h>
|
||||||
|
@ -26,9 +26,11 @@
|
|||||||
* the %G_SOCKET_FAMILY_UNIX family by using g_socket_send_message()
|
* the %G_SOCKET_FAMILY_UNIX family by using g_socket_send_message()
|
||||||
* and received using g_socket_receive_message().
|
* and received using g_socket_receive_message().
|
||||||
*
|
*
|
||||||
* Note that `<gio/gunixfdlist.h>` belongs to the UNIX-specific GIO
|
* Before 2.74, `<gio/gunixfdlist.h>` belonged to the UNIX-specific GIO
|
||||||
* interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config
|
* interfaces, thus you had to use the `gio-unix-2.0.pc` pkg-config file when
|
||||||
* file when using it.
|
* using it.
|
||||||
|
*
|
||||||
|
* Since 2.74, the API is available for Windows.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +42,6 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -48,6 +49,12 @@
|
|||||||
#include "gunixfdlist.h"
|
#include "gunixfdlist.h"
|
||||||
#include "gnetworking.h"
|
#include "gnetworking.h"
|
||||||
#include "gioerror.h"
|
#include "gioerror.h"
|
||||||
|
#include "glib/glib-private.h"
|
||||||
|
#include "glib/gstdio.h"
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct _GUnixFDListPrivate
|
struct _GUnixFDListPrivate
|
||||||
{
|
{
|
||||||
@ -70,7 +77,7 @@ g_unix_fd_list_finalize (GObject *object)
|
|||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < list->priv->nfd; i++)
|
for (i = 0; i < list->priv->nfd; i++)
|
||||||
close (list->priv->fds[i]);
|
g_close (list->priv->fds[i], NULL);
|
||||||
g_free (list->priv->fds);
|
g_free (list->priv->fds);
|
||||||
|
|
||||||
G_OBJECT_CLASS (g_unix_fd_list_parent_class)
|
G_OBJECT_CLASS (g_unix_fd_list_parent_class)
|
||||||
@ -90,7 +97,9 @@ dup_close_on_exec_fd (gint fd,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gint new_fd;
|
gint new_fd;
|
||||||
|
#ifndef G_OS_WIN32
|
||||||
gint s;
|
gint s;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef F_DUPFD_CLOEXEC
|
#ifdef F_DUPFD_CLOEXEC
|
||||||
do
|
do
|
||||||
@ -118,6 +127,9 @@ dup_close_on_exec_fd (gint fd,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
new_fd = GLIB_PRIVATE_CALL (g_win32_reopen_noninherited) (new_fd, 0, error);
|
||||||
|
#else
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
s = fcntl (new_fd, F_GETFD);
|
s = fcntl (new_fd, F_GETFD);
|
||||||
@ -134,10 +146,11 @@ dup_close_on_exec_fd (gint fd,
|
|||||||
g_set_error (error, G_IO_ERROR,
|
g_set_error (error, G_IO_ERROR,
|
||||||
g_io_error_from_errno (saved_errno),
|
g_io_error_from_errno (saved_errno),
|
||||||
"fcntl: %s", g_strerror (saved_errno));
|
"fcntl: %s", g_strerror (saved_errno));
|
||||||
close (new_fd);
|
g_close (new_fd, NULL);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return new_fd;
|
return new_fd;
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,6 @@ if host_system != 'windows'
|
|||||||
unix_sources = files(
|
unix_sources = files(
|
||||||
'gfiledescriptorbased.c',
|
'gfiledescriptorbased.c',
|
||||||
'giounix-private.c',
|
'giounix-private.c',
|
||||||
'gunixfdlist.c',
|
|
||||||
'gunixfdmessage.c',
|
'gunixfdmessage.c',
|
||||||
'gunixmount.c',
|
'gunixmount.c',
|
||||||
'gunixmounts.c',
|
'gunixmounts.c',
|
||||||
@ -574,6 +573,7 @@ gio_sources = files(
|
|||||||
'gdtlsserverconnection.c',
|
'gdtlsserverconnection.c',
|
||||||
'gunionvolumemonitor.c',
|
'gunionvolumemonitor.c',
|
||||||
'gunixconnection.c',
|
'gunixconnection.c',
|
||||||
|
'gunixfdlist.c',
|
||||||
'gunixcredentialsmessage.c',
|
'gunixcredentialsmessage.c',
|
||||||
'gunixsocketaddress.c',
|
'gunixsocketaddress.c',
|
||||||
'gvfs.c',
|
'gvfs.c',
|
||||||
|
Loading…
Reference in New Issue
Block a user