summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e6c64fc)
raw | patch | inline | side by side (parent: e6c64fc)
author | Junio C Hamano <junkio@cox.net> | |
Sat, 5 Nov 2005 19:07:22 +0000 (11:07 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 5 Nov 2005 19:07:22 +0000 (11:07 -0800) |
Signed-off-by: Junio C Hamano <junkio@cox.net>
init-db.c | patch | blob | history |
diff --git a/init-db.c b/init-db.c
index ca6fa4d4200faaf208e5c6c5af5f009cc4432a09..bd88291b0efd3eb9c46195d413db1aba820db2dd 100644 (file)
--- a/init-db.c
+++ b/init-db.c
static int copy_file(const char *dst, const char *src, int mode)
{
- int fdi, fdo;
+ int fdi, fdo, status;
mode = (mode & 0111) ? 0777 : 0666;
if ((fdi = open(src, O_RDONLY)) < 0)
close(fdi);
return fdo;
}
- while (1) {
- char buf[BUFSIZ];
- ssize_t leni, leno, ofs;
- leni = read(fdi, buf, sizeof(buf));
- if (leni < 0) {
- error_return:
- close(fdo);
- close(fdi);
- return -1;
- }
- if (!leni)
- break;
- ofs = 0;
- do {
- leno = write(fdo, buf+ofs, leni);
- if (leno < 0)
- goto error_return;
- leni -= leno;
- ofs += leno;
- } while (0 < leni);
- }
+ status = copy_fd(fdi, fdo);
close(fdo);
- close(fdi);
- return 0;
+ return status;
}
static void copy_templates_1(char *path, int baselen,