GLocalFileInputStream: Implement GFileDescriptorBased

This commit is contained in:
Christian Kellner 2010-02-07 17:17:44 +01:00
parent 4536a4adbc
commit 670f6210ce

View File

@ -33,6 +33,7 @@
#include <glib.h>
#include <glib/gstdio.h>
#include "gcancellable.h"
#include "gfiledescriptorbased.h"
#include "gioerror.h"
#include "glocalfileinputstream.h"
#include "glocalfileinfo.h"
@ -44,8 +45,12 @@
#include "gioalias.h"
static void g_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
#define g_local_file_input_stream_get_type _g_local_file_input_stream_get_type
G_DEFINE_TYPE (GLocalFileInputStream, g_local_file_input_stream, G_TYPE_FILE_INPUT_STREAM);
G_DEFINE_TYPE_WITH_CODE (GLocalFileInputStream, g_local_file_input_stream, G_TYPE_FILE_INPUT_STREAM,
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED,
g_file_descriptor_based_iface_init));
struct _GLocalFileInputStreamPrivate {
int fd;
@ -75,6 +80,7 @@ static GFileInfo *g_local_file_input_stream_query_info (GFileInputStream *strea
const char *attributes,
GCancellable *cancellable,
GError **error);
static int g_local_file_input_stream_get_fd (GFileDescriptorBased *stream);
static void
g_local_file_input_stream_finalize (GObject *object)
@ -109,6 +115,12 @@ g_local_file_input_stream_class_init (GLocalFileInputStreamClass *klass)
file_stream_class->query_info = g_local_file_input_stream_query_info;
}
static void
g_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
{
iface->get_fd = g_local_file_input_stream_get_fd;
}
static void
g_local_file_input_stream_init (GLocalFileInputStream *info)
{
@ -336,3 +348,11 @@ g_local_file_input_stream_query_info (GFileInputStream *stream,
attributes,
error);
}
static int
g_local_file_input_stream_get_fd (GFileDescriptorBased *fd_based)
{
GLocalFileInputStream *stream = G_LOCAL_FILE_INPUT_STREAM (fd_based);
return stream->priv->fd;
}