code:which(Module) searches the code path for the first file which contains object code for Module and returns the absolute file name. When used with embedded releases, this returns the name of the sendfile.ez erlang archive which causes erl_ddll:load_driver/2 to fail. Using code:priv_dir/1 fixes the problem.
After Yaws sendfile was converted to use a gen_server and this version of sendfile picked up those changes, some missing bits were restored and dialyzer warnings fixed. Pick up those changes so we keep sendfile and Yaws sendfile in sync.
Combine sendfile and sendfile_drv into the sendfile module, and remove the now-obsolete sendfile_drv module.
Tuncer Ayaz pointed out that OS X sendfile will return bytes sent for the case when EINTR occurs. Make sendfile driver handle this case by treating EINTR the same as EAGAIN for all supported platforms. Also update driver to use ERL_DRV_* flags in driver_select calls if they're defined, rather than the old DO_* flags. This is considered correct practice since R13B.