glib/gio/glocalfileiostream.c
David Zeuthen 366b3ffcde Bug 619142 – Build fixes
- Fix various #include issues

 - Change #error to #warning for the EXTERNAL authentication mechanism.
   It is not clear if this should work on Win32 at all.

 - Call close() before unlink() for the SHA1 keyring

 - Change #error to #warning so we don't forget to do
   permission checking of the .dbus-keyrings directory

 - Use Win32 SID for the SHA1 auth mech

 - Apparently we can't use word 'interface' as an identifier

 - Implement a _g_dbus_win32_get_user_sid() function. For now it's
   private. Don't know if it should be public somewhere. Maybe in
   a future GCredentials support for Win32? I don't know.

 - GFileDescriptorBased is not available on Win32. So avoid using
   it in GLocalFile stuff. Now, Win32 still uses GLocalFile + friends
   (which works with file descriptors) so expose a private function
   to get the fd for an OutputStream so things still work.

 - Fixup gio.symbols

 - Fixup tests/gdbus-peer.c so it builds

With this, at least things compile and the gdbus-peer.exe test case
passes. Which is a great start. I've tested this by cross-compiling on
a x86_64 Fedora 13 host using mingw32 and running the code on a 32-bit
Windows 7 box.

https://bugzilla.gnome.org/show_bug.cgi?id=619142

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-05-20 10:53:08 -04:00

120 lines
3.5 KiB
C

/* GIO - GLib Input, IO and Streaming Library
*
* Copyright (C) 2006-2007 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Alexander Larsson <alexl@redhat.com>
*/
#include "config.h"
#include <glib.h>
#include <glib/gstdio.h>
#include "glibintl.h"
#include "gioerror.h"
#include "gcancellable.h"
#include "glocalfileiostream.h"
#include "glocalfileinputstream.h"
#include "glocalfileinfo.h"
#ifdef G_OS_UNIX
#include "gfiledescriptorbased.h"
#endif
#include "gioalias.h"
#define g_local_file_io_stream_get_type _g_local_file_io_stream_get_type
G_DEFINE_TYPE (GLocalFileIOStream, g_local_file_io_stream, G_TYPE_FILE_IO_STREAM);
static void
g_local_file_io_stream_finalize (GObject *object)
{
GLocalFileIOStream *file;
file = G_LOCAL_FILE_IO_STREAM (object);
g_object_unref (file->input_stream);
g_object_unref (file->output_stream);
G_OBJECT_CLASS (g_local_file_io_stream_parent_class)->finalize (object);
}
GFileIOStream *
_g_local_file_io_stream_new (GLocalFileOutputStream *output_stream)
{
GLocalFileIOStream *stream;
int fd;
stream = g_object_new (G_TYPE_LOCAL_FILE_IO_STREAM, NULL);
stream->output_stream = g_object_ref (output_stream);
_g_local_file_output_stream_set_do_close (output_stream, FALSE);
fd = _g_local_file_output_stream_get_fd (output_stream);
stream->input_stream = (GInputStream *)_g_local_file_input_stream_new (fd);
_g_local_file_input_stream_set_do_close (G_LOCAL_FILE_INPUT_STREAM (stream->input_stream),
FALSE);
return G_FILE_IO_STREAM (stream);
}
static GInputStream *
g_local_file_io_stream_get_input_stream (GIOStream *stream)
{
return G_LOCAL_FILE_IO_STREAM (stream)->input_stream;
}
static GOutputStream *
g_local_file_io_stream_get_output_stream (GIOStream *stream)
{
return G_LOCAL_FILE_IO_STREAM (stream)->output_stream;
}
static gboolean
g_local_file_io_stream_close (GIOStream *stream,
GCancellable *cancellable,
GError **error)
{
GLocalFileIOStream *file = G_LOCAL_FILE_IO_STREAM (stream);
/* There are shortcutted and can't fail */
g_output_stream_close (file->output_stream, cancellable, NULL);
g_input_stream_close (file->input_stream, cancellable, NULL);
return
_g_local_file_output_stream_really_close (G_LOCAL_FILE_OUTPUT_STREAM (file->output_stream),
cancellable, error);
}
static void
g_local_file_io_stream_class_init (GLocalFileIOStreamClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GIOStreamClass *stream_class = G_IO_STREAM_CLASS (klass);
gobject_class->finalize = g_local_file_io_stream_finalize;
stream_class->get_input_stream = g_local_file_io_stream_get_input_stream;
stream_class->get_output_stream = g_local_file_io_stream_get_output_stream;
stream_class->close_fn = g_local_file_io_stream_close;
}
static void
g_local_file_io_stream_init (GLocalFileIOStream *stream)
{
}