summaryrefslogtreecommitdiff
path: root/init-db.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-11-05 19:07:22 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-11-05 19:07:22 (GMT)
commit32276c8059908874afb7a2db039ccc7bcfd84ec7 (patch)
treef64ac72d93d7c807494446a90bfcd61c8ee3f141 /init-db.c
parente6c64fc1e9b3b9a5ea7101f8a2a499c9e2112da5 (diff)
downloadgit-32276c8059908874afb7a2db039ccc7bcfd84ec7.zip
git-32276c8059908874afb7a2db039ccc7bcfd84ec7.tar.gz
git-32276c8059908874afb7a2db039ccc7bcfd84ec7.tar.bz2
init-db::copy_file() - use copy_fd()
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'init-db.c')
-rw-r--r--init-db.c27
1 files changed, 3 insertions, 24 deletions
diff --git a/init-db.c b/init-db.c
index ca6fa4d..bd88291 100644
--- a/init-db.c
+++ b/init-db.c
@@ -21,7 +21,7 @@ static void safe_create_dir(const char *dir)
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)
@@ -30,30 +30,9 @@ static int copy_file(const char *dst, const char *src, int mode)
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,