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:
@ -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 */
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user