From bd89fa06311c603451ca31f8c2554225b387d8be Mon Sep 17 00:00:00 2001 From: Rafal Wojtczuk Date: Fri, 11 Mar 2011 11:57:16 +0100 Subject: [PATCH] Move copy_all_fd from dvm_file_editor.c to ioall.c It is useful in e.g. qfile-agent-dvm. --- appvm/dvm_file_editor.c | 21 --------------------- common/ioall.c | 21 +++++++++++++++++++++ common/ioall.h | 1 + 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/appvm/dvm_file_editor.c b/appvm/dvm_file_editor.c index 3cc8818f..4eed30ba 100644 --- a/appvm/dvm_file_editor.c +++ b/appvm/dvm_file_editor.c @@ -21,27 +21,6 @@ char *get_filename() return retname; } -int copy_fd_all(int fdout, int fdin) -{ - int ret; - char buf[4096]; - for (;;) { - ret = read(fdin, buf, sizeof(buf)); - if (!ret) - break; - if (ret < 0) { - perror("read"); - return 0; - } - if (!write_all(fdout, buf, ret)) { - perror("write"); - return 0; - } - } - return 1; -} - - void copy_file(char *filename) { int fd = open(filename, O_WRONLY | O_CREAT, 0600); diff --git a/common/ioall.c b/common/ioall.c index ce550c7e..1fca6f12 100644 --- a/common/ioall.c +++ b/common/ioall.c @@ -59,3 +59,24 @@ int read_all(int fd, void *buf, int size) // fprintf(stderr, "read %d bytes\n", size); return 1; } + +int copy_fd_all(int fdout, int fdin) +{ + int ret; + char buf[4096]; + for (;;) { + ret = read(fdin, buf, sizeof(buf)); + if (!ret) + break; + if (ret < 0) { + perror("read"); + return 0; + } + if (!write_all(fdout, buf, ret)) { + perror("write"); + return 0; + } + } + return 1; +} + diff --git a/common/ioall.h b/common/ioall.h index 1e76353e..1a700c6c 100644 --- a/common/ioall.h +++ b/common/ioall.h @@ -1,2 +1,3 @@ int write_all(int fd, void *buf, int size); int read_all(int fd, void *buf, int size); +int copy_fd_all(int fdout, int fdin);