summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2020-02-27 16:56:14 +0100
committerBastien Nocera <hadess@hadess.net>2020-02-27 18:53:16 +0100
commit26b8e7fb6913ea44d0caccb4a6c164aadb5e525c (patch)
tree221b82949d328da3cbefd263ad515a6c82043b15
parent5869e43a16b4fad25e6af3ee86c6bd29abf26be5 (diff)
downloadtotem-pl-parser-26b8e7fb6913ea44d0caccb4a6c164aadb5e525c.tar.gz
plparser: Make totem_pl_parser_write_buffer() cancellable
-rw-r--r--plparse/totem-pl-parser-pla.c4
-rw-r--r--plparse/totem-pl-parser-private.h1
-rw-r--r--plparse/totem-pl-parser.c9
3 files changed, 10 insertions, 4 deletions
diff --git a/plparse/totem-pl-parser-pla.c b/plparse/totem-pl-parser-pla.c
index 56b44b3..e78efae 100644
--- a/plparse/totem-pl-parser-pla.c
+++ b/plparse/totem-pl-parser-pla.c
@@ -72,7 +72,7 @@ totem_pl_parser_save_pla (TotemPlParser *parser,
* the 'quick list' name there.
*/
strncpy (buffer + TITLE_OFFSET, title, TITLE_SIZE);
- if (totem_pl_parser_write_buffer (G_OUTPUT_STREAM (stream), buffer, RECORD_SIZE, error) == FALSE)
+ if (totem_pl_parser_write_buffer (G_OUTPUT_STREAM (stream), buffer, RECORD_SIZE, cancellable, error) == FALSE)
{
DEBUG(output, g_print ("Couldn't write header block for '%s'", uri));
g_free (buffer);
@@ -150,7 +150,7 @@ totem_pl_parser_save_pla (TotemPlParser *parser,
memcpy (buffer + PATH_OFFSET, converted, written);
g_free (converted);
- if (totem_pl_parser_write_buffer (G_OUTPUT_STREAM (stream), buffer, RECORD_SIZE, error) == FALSE)
+ if (totem_pl_parser_write_buffer (G_OUTPUT_STREAM (stream), buffer, RECORD_SIZE, cancellable, error) == FALSE)
{
DEBUG1(g_print ("Couldn't write entry %d to the file\n", i));
ret = FALSE;
diff --git a/plparse/totem-pl-parser-private.h b/plparse/totem-pl-parser-private.h
index 8073ec7..d868e9b 100644
--- a/plparse/totem-pl-parser-private.h
+++ b/plparse/totem-pl-parser-private.h
@@ -135,6 +135,7 @@ gboolean totem_pl_parser_write_string (GOutputStream *stream,
gboolean totem_pl_parser_write_buffer (GOutputStream *stream,
const char *buf,
guint size,
+ GCancellable *cancellable,
GError **error);
char * totem_pl_parser_relative (GFile *output,
const char *filepath);
diff --git a/plparse/totem-pl-parser.c b/plparse/totem-pl-parser.c
index a5a9740..0d7f932 100644
--- a/plparse/totem-pl-parser.c
+++ b/plparse/totem-pl-parser.c
@@ -873,6 +873,7 @@ totem_pl_parser_write_string (GOutputStream *stream, const char *buf, GError **e
* @stream: a #GFileOutputStream to an open file
* @buf: the string buffer to write out
* @len: the length of the string to write out
+ * @cancellable: (allow-none): a #GCancellable, or %NULL
* @error: return location for a #GError, or %NULL
*
* Writes @len bytes of @buf to the file specified by @handle.
@@ -882,14 +883,18 @@ totem_pl_parser_write_string (GOutputStream *stream, const char *buf, GError **e
* Return value: %TRUE on success
**/
gboolean
-totem_pl_parser_write_buffer (GOutputStream *stream, const char *buf, guint len, GError **error)
+totem_pl_parser_write_buffer (GOutputStream *stream,
+ const char *buf,
+ guint len,
+ GCancellable *cancellable,
+ GError **error)
{
gsize bytes_written;
if (g_output_stream_write_all (stream,
buf, len,
&bytes_written,
- NULL, error) == FALSE) {
+ cancellable, error) == FALSE) {
g_object_unref (stream);
return FALSE;
}