From 21f17ad27b3e805003e50b0f5fcbe606bfef0f3b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 17 Jul 2021 13:19:27 -0400 Subject: Factor out serd_write_file_uri() --- include/serd/serd.h | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'include/serd/serd.h') diff --git a/include/serd/serd.h b/include/serd/serd.h index cec77649..9ffb16fe 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -521,8 +521,8 @@ serd_uri_string_length(SerdURIView uri); @param sink Sink to write string output to. @param stream Opaque user argument to pass to `sink`. - @return The number of bytes written, which is less than - `serd_uri_string_length(uri)` on error. + @return The length of the written URI string (not including a null + terminator), which may be less than `serd_uri_string_length(uri)` on error. */ SERD_API size_t @@ -530,6 +530,29 @@ serd_write_uri(SerdURIView uri, SerdWriteFunc SERD_NONNULL sink, void* SERD_NONNULL stream); +/** + Write a file URI to `sink` from a path and optional hostname. + + Backslashes in Windows paths will be converted, and other characters will be + percent encoded as necessary. + + If `path` is relative, `hostname` is ignored. + + @param path File system path. + @param hostname Optional hostname. + @param sink Sink to write string output to. + @param stream Opaque user argument to pass to `sink`. + + @return The length of the written URI string (not including a null + terminator). +*/ +SERD_API +size_t +serd_write_file_uri(SerdStringView path, + SerdStringView hostname, + SerdWriteFunc SERD_NONNULL sink, + void* SERD_NONNULL stream); + /** @} @defgroup serd_node Node -- cgit v1.2.1