#include "glibintl.h"
#include "gioerror.h"
#include "gcancellable.h"
+#include "gfiledescriptorbased.h"
#include "glocalfileiostream.h"
#include "glocalfileinputstream.h"
#include "glocalfileinfo.h"
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);
+ fd = g_file_descriptor_based_get_fd (G_FILE_DESCRIPTOR_BASED (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);
#include "glibintl.h"
#include "gioerror.h"
#include "gcancellable.h"
+#include "gfiledescriptorbased.h"
#include "glocalfileoutputstream.h"
#include "glocalfileinfo.h"
#include "gioalias.h"
+static void g_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
#define g_local_file_output_stream_get_type _g_local_file_output_stream_get_type
-G_DEFINE_TYPE (GLocalFileOutputStream, g_local_file_output_stream, G_TYPE_FILE_OUTPUT_STREAM);
+G_DEFINE_TYPE_WITH_CODE (GLocalFileOutputStream, g_local_file_output_stream, G_TYPE_FILE_OUTPUT_STREAM,
+ G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED,
+ g_file_descriptor_based_iface_init));
+
/* Some of the file replacement code was based on the code from gedit,
* relicenced to LGPL with permissions from the authors.
goffset size,
GCancellable *cancellable,
GError **error);
+static int g_local_file_output_stream_get_fd (GFileDescriptorBased *stream);
static void
g_local_file_output_stream_finalize (GObject *object)
G_OBJECT_CLASS (g_local_file_output_stream_parent_class)->finalize (object);
}
+
static void
g_local_file_output_stream_class_init (GLocalFileOutputStreamClass *klass)
{
}
static void
+g_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
+{
+ iface->get_fd = g_local_file_output_stream_get_fd;
+}
+
+static void
g_local_file_output_stream_init (GLocalFileOutputStream *stream)
{
stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
stream->priv->do_close = TRUE;
}
-int
-_g_local_file_output_stream_get_fd (GLocalFileOutputStream *out)
-{
- return out->priv->fd;
-}
-
static gssize
g_local_file_output_stream_write (GOutputStream *stream,
const void *buffer,
return G_FILE_OUTPUT_STREAM (stream);
}
+
+static int
+g_local_file_output_stream_get_fd (GFileDescriptorBased *fd_based)
+{
+ GLocalFileOutputStream *stream = G_LOCAL_FILE_OUTPUT_STREAM (fd_based);
+
+ return stream->priv->fd;
+}
+