aboutsummaryrefslogtreecommitdiff
path: root/strbuf.h
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2015-12-15 16:04:08 -0800
committerJunio C Hamano <gitster@pobox.com>2015-12-16 12:06:08 -0800
commitb4e04fb66e87a027c5f9c96bcbbba50719400169 (patch)
tree3a5eee3f453bf76dc8c3e0da0eaefba3817b76c2 /strbuf.h
parent1079c4be0b72003668df647f8a520fa137c7e158 (diff)
downloadgit-b4e04fb66e87a027c5f9c96bcbbba50719400169.tar.gz
git-b4e04fb66e87a027c5f9c96bcbbba50719400169.tar.xz
strbuf: add strbuf_read_once to read without blocking
The new call will read from a file descriptor into a strbuf once. The underlying call xread is just run once. xread only reattempts reading in case of EINTR, which makes it suitable to use for a nonblocking read. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.h')
-rw-r--r--strbuf.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/strbuf.h b/strbuf.h
index 7123fca7a..2bf90e70f 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -367,6 +367,14 @@ extern size_t strbuf_fread(struct strbuf *, size_t, FILE *);
extern ssize_t strbuf_read(struct strbuf *, int fd, size_t hint);
/**
+ * Read the contents of a given file descriptor partially by using only one
+ * attempt of xread. The third argument can be used to give a hint about the
+ * file size, to avoid reallocs. Returns the number of new bytes appended to
+ * the sb.
+ */
+extern ssize_t strbuf_read_once(struct strbuf *, int fd, size_t hint);
+
+/**
* Read the contents of a file, specified by its path. The third argument
* can be used to give a hint about the file size, to avoid reallocs.
*/