summaryrefslogtreecommitdiff
path: root/fileutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fileutils.cpp')
-rw-r--r--fileutils.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/fileutils.cpp b/fileutils.cpp
index 62e2c0b..b04a414 100644
--- a/fileutils.cpp
+++ b/fileutils.cpp
@@ -21,8 +21,33 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include "generic.h"
+unsigned long filesize(int f_iso)
+{
+ long curpos, length;
+
+ curpos = lseek(f_iso, 0, SEEK_CUR);
+ length = lseek(f_iso, 0, SEEK_END);
+ lseek(f_iso, curpos, SEEK_SET);
+ return length;
+}
+
+void copy(int s, int d, long size) {
+ long i;
+ unsigned char c;
+ long r;
+
+ for (i = 0; (i < size) || (size < 0); i++) {
+ r = read(s, &c, 1);
+ if (r == 0) {
+ break;
+ }
+ write(d, &c, 1);
+ }
+}
+
unsigned long filesize(FILE * f_iso)
{
long curpos, length;