Skip to content

Commit

Permalink
fix sendfile failed for linux 2.6.18 rhel 5.10
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Dec 9, 2016
1 parent 2bfad83 commit a9a6c4b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/tbox/platform/posix/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,18 @@ tb_bool_t tb_file_copy(tb_char_t const* path, tb_char_t const* dest)
if (ifile) tb_file_exit(ifile);
if (ofile) tb_file_exit(ofile);

/* attempt to copy file directly if sendfile failed
*
* sendfile() supports regular file only after "since Linux 2.6.33".
*/
if (!ok && ifile && ofile)
ok = tb_transfer_url(path, dest, 0, tb_null, tb_null) >= 0;

// ok?
return ok;
#else
// copy it
return tb_transfer_url(path, dest, 0, tb_null, tb_null) >= 0? tb_true : tb_false;
return tb_transfer_url(path, dest, 0, tb_null, tb_null) >= 0;
#endif
}
tb_bool_t tb_file_create(tb_char_t const* path)
Expand Down

0 comments on commit a9a6c4b

Please sign in to comment.