11 #if defined(__APPLE__)
16 #include <sys/sendfile.h>
20 #define COPYFILE_ALL 0
35 size_t copyfile(
const char *src,
const char *dest,
const int unused_1,
const int unused_2) {
38 int read_file = open(src, O_RDONLY);
41 struct stat stat_buffer;
42 fstat(read_file, &stat_buffer);
46 int write_file = open(dest, O_WRONLY | O_CREAT, stat_buffer.st_mode);
49 off_t bytesCopied = 0;
50 size_t error = sendfile(write_file, read_file, &bytesCopied, stat_buffer.st_size);