Rev | Line | |
---|
[202] | 1 | //file.c: |
---|
| 2 | |
---|
| 3 | #include "libroar.h" |
---|
| 4 | |
---|
[208] | 5 | #define BUFSIZE 8192 |
---|
| 6 | #define BUFMAX 65536 |
---|
| 7 | |
---|
| 8 | ssize_t roar_file_send_raw (int out, int in) { |
---|
| 9 | ssize_t r = 0; |
---|
| 10 | ssize_t ret; |
---|
| 11 | int len; |
---|
| 12 | char buf[BUFSIZE]; |
---|
| 13 | |
---|
| 14 | #ifdef ROAR_HAVE_LINUX_SENDFILE |
---|
| 15 | while ((ret = sendfile(out, in, NULL, BUFMAX)) > 0) |
---|
| 16 | r += ret; |
---|
| 17 | #endif |
---|
| 18 | |
---|
| 19 | // TODO: try mmap here! |
---|
| 20 | |
---|
| 21 | while ((len = read(in, buf, BUFSIZE)) > 0) |
---|
| 22 | r += write(out, buf, len); |
---|
| 23 | |
---|
| 24 | return r; |
---|
| 25 | } |
---|
| 26 | |
---|
[202] | 27 | //ll |
---|
Note: See
TracBrowser
for help on using the repository browser.