Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2007-09-18 04:06:46 +0400
committerJunio C Hamano <gitster@pobox.com>2007-09-27 11:33:29 +0400
commita9390b9fcefb18c4ccdb521086a051bc9112e03d (patch)
treef34be08d5e61f04d3d8cf876628dcf08597097c5 /strbuf.c
parentb4833a2c62578bdbfd300e296702214cb1b9a601 (diff)
Add strbuf_read_file().
Signed-off-by: Kristian Høgsberg <krh@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/strbuf.c b/strbuf.c
index d5e92ee172..d1e338bfb6 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -177,3 +177,18 @@ int strbuf_getline(struct strbuf *sb, FILE *fp, int term)
sb->buf[sb->len] = '\0';
return 0;
}
+
+int strbuf_read_file(struct strbuf *sb, const char *path)
+{
+ int fd, len;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
+ len = strbuf_read(sb, fd, 0);
+ close(fd);
+ if (len < 0)
+ return -1;
+
+ return len;
+}