mirror of https://github.com/vitalif/zbackup
Add MacOSX compatability
parent
3e7ae35a7c
commit
5aa754654b
14
file.cc
14
file.cc
|
@ -6,8 +6,11 @@
|
|||
#include <unistd.h>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
#include <sys/sendfile.h>
|
||||
#ifdef __APPLE__
|
||||
#include <sys/socket.h>
|
||||
#else
|
||||
#include <sys/sendfile.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
@ -61,8 +64,13 @@ void File::rename( std::string const & from,
|
|||
source file. */
|
||||
write_fd = ::open( to.c_str(), O_WRONLY | O_CREAT, stat_buf.st_mode );
|
||||
/* Blast the bytes from one file to the other. */
|
||||
#ifdef __APPLE__
|
||||
if ( -1 == sendfile(write_fd, read_fd, offset, &stat_buf.st_size, NULL, 0) )
|
||||
throw exCantRename( from + " to " + to );
|
||||
#else
|
||||
if ( -1 == sendfile(write_fd, read_fd, &offset, stat_buf.st_size) )
|
||||
throw exCantRename( from + " to " + to );
|
||||
throw exCantRename( from + " to " + to );
|
||||
#endif
|
||||
|
||||
/* Close up. */
|
||||
::close( read_fd );
|
||||
|
|
Loading…
Reference in New Issue