From e6f692d2ca3c95d0b86253a473c0acf21ce69bcb Mon Sep 17 00:00:00 2001 From: Erik Troan Date: Sat, 18 Sep 1999 16:11:13 +0000 Subject: *** empty log message *** --- loader/misc.c | 29 +++++++++++++++++++++++++++++ loader/misc.h | 6 ++++++ 2 files changed, 35 insertions(+) create mode 100644 loader/misc.c create mode 100644 loader/misc.h (limited to 'loader') diff --git a/loader/misc.c b/loader/misc.c new file mode 100644 index 000000000..c811e669e --- /dev/null +++ b/loader/misc.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +#include "log.h" + +int copyFile(char * source, char * dest) { + int infd = -1, outfd = -1; + char buf[4096]; + int i; + + outfd = open(dest, O_CREAT | O_RDWR, 0666); + infd = open(source, O_RDONLY); + + if (infd < 0) { + logMessage("failed to open %s: %s", source, strerror(errno)); + } + + while ((i = read(infd, buf, sizeof(buf))) > 0) { + if (write(outfd, buf, i) != i) break; + } + + close(infd); + close(outfd); + + return 0; +} + diff --git a/loader/misc.h b/loader/misc.h new file mode 100644 index 000000000..2d29534d6 --- /dev/null +++ b/loader/misc.h @@ -0,0 +1,6 @@ +#ifndef H_LOADER_MISC_H +#define H_LOADER_MISC_H + +int copyFile(char * source, char * dest); + +#endif -- cgit