[glib: 2/3] glocalfileinputstream: Drop custom skip vfunc implementation
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/3] glocalfileinputstream: Drop custom skip vfunc implementation
- Date: Tue, 16 Feb 2021 08:31:07 +0000 (UTC)
commit 8323997f3f4f7b82d31fd52e6124623ce908571c
Author: Philip Withnall <pwithnall endlessos org>
Date: Mon Feb 15 15:02:29 2021 +0000
glocalfileinputstream: Drop custom skip vfunc implementation
Since the previous commit, the generic `GInputStream` implementation of
`skip()` is now equivalent, and results in the same calls to `lseek()`.
Heavily based on an approach by Dan Winship in
https://bugzilla.gnome.org/show_bug.cgi?id=681374.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #587
gio/glocalfileinputstream.c | 61 ---------------------------------------------
1 file changed, 61 deletions(-)
---
diff --git a/gio/glocalfileinputstream.c b/gio/glocalfileinputstream.c
index 0d72c52e2..07532a242 100644
--- a/gio/glocalfileinputstream.c
+++ b/gio/glocalfileinputstream.c
@@ -68,10 +68,6 @@ static gssize g_local_file_input_stream_read (GInputStream *strea
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);
@@ -104,7 +100,6 @@ g_local_file_input_stream_class_init (GLocalFileInputStreamClass *klass)
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;
@@ -175,62 +170,6 @@ g_local_file_input_stream_read (GInputStream *stream,
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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]