gsize count,
GCancellable *cancellable,
GError **error);
-static gssize g_local_file_input_stream_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error);
static gboolean g_local_file_input_stream_close (GInputStream *stream,
GCancellable *cancellable,
GError **error);
GFileInputStreamClass *file_stream_class = G_FILE_INPUT_STREAM_CLASS (klass);
stream_class->read_fn = g_local_file_input_stream_read;
- stream_class->skip = g_local_file_input_stream_skip;
stream_class->close_fn = g_local_file_input_stream_close;
file_stream_class->tell = g_local_file_input_stream_tell;
file_stream_class->can_seek = g_local_file_input_stream_can_seek;
return res;
}
-static gssize
-g_local_file_input_stream_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- off_t start, end;
- GLocalFileInputStream *file;
-
- file = G_LOCAL_FILE_INPUT_STREAM (stream);
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return -1;
-
- start = lseek (file->priv->fd, 0, SEEK_CUR);
- if (start == -1)
- {
- int errsv = errno;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- _("Error seeking in file: %s"),
- g_strerror (errsv));
- return -1;
- }
-
- end = lseek (file->priv->fd, 0, SEEK_END);
- if (end == -1)
- {
- int errsv = errno;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- _("Error seeking in file: %s"),
- g_strerror (errsv));
- return -1;
- }
-
- if (end - start > count)
- {
- end = lseek (file->priv->fd, count - (end - start), SEEK_CUR);
- if (end == -1)
- {
- int errsv = errno;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- _("Error seeking in file: %s"),
- g_strerror (errsv));
- return -1;
- }
- }
-
- return end - start;
-}
-
static gboolean
g_local_file_input_stream_close (GInputStream *stream,
GCancellable *cancellable,