1
0

Move copy_all_fd from dvm_file_editor.c to ioall.c

It is useful in e.g. qfile-agent-dvm.
Dieser Commit ist enthalten in:
Rafal Wojtczuk 2011-03-11 11:57:16 +01:00
Ursprung dd014e4cab
Commit 9d8e066a7f
3 geänderte Dateien mit 22 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -21,27 +21,6 @@ char *get_filename()
return retname; 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) void copy_file(char *filename)
{ {
int fd = open(filename, O_WRONLY | O_CREAT, 0600); int fd = open(filename, O_WRONLY | O_CREAT, 0600);

Datei anzeigen

@ -59,3 +59,24 @@ int read_all(int fd, void *buf, int size)
// fprintf(stderr, "read %d bytes\n", size); // fprintf(stderr, "read %d bytes\n", size);
return 1; 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;
}

Datei anzeigen

@ -1,2 +1,3 @@
int write_all(int fd, void *buf, int size); int write_all(int fd, void *buf, int size);
int read_all(int fd, void *buf, int size); int read_all(int fd, void *buf, int size);
int copy_fd_all(int fdout, int fdin);