app: add gimp_data_input_stream_read_line_always()

... which is a drop-in replacement for
g_data_input_stream_read_line(), however, it always returns a non-
NULL value when there's no error.  If the end-of-file is reached,
an empty string is returned.
This commit is contained in:
Ell
2018-06-20 14:24:43 -04:00
parent 669127dbd6
commit e090b910c0
2 changed files with 34 additions and 0 deletions

View File

@ -815,6 +815,35 @@ gimp_file_with_new_extension (GFile *file,
return ret;
}
gchar *
gimp_data_input_stream_read_line_always (GDataInputStream *stream,
gsize *length,
GCancellable *cancellable,
GError **error)
{
GError *temp_error = NULL;
gchar *result;
g_return_val_if_fail (G_IS_DATA_INPUT_STREAM (stream), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (! error)
error = &temp_error;
result = g_data_input_stream_read_line (stream, length, cancellable, error);
if (! result && ! *error)
{
result = g_strdup ("");
if (length) *length = 0;
}
g_clear_error (&temp_error);
return result;
}
/* debug stuff */

View File

@ -83,6 +83,11 @@ gchar * gimp_file_get_extension (GFile *file);
GFile * gimp_file_with_new_extension (GFile *file,
GFile *ext_file);
gchar * gimp_data_input_stream_read_line_always (GDataInputStream *stream,
gsize *length,
GCancellable *cancellable,
GError **error);
GimpImage * gimp_create_image_from_buffer (Gimp *gimp,
GeglBuffer *buffer,
const gchar *image_name);