Skip to content

Commit

Permalink
fix #14574, cp on files >2GB (#30989)
Browse files Browse the repository at this point in the history
(cherry picked from commit 05785f9)
  • Loading branch information
JeffBezanson committed Jun 6, 2019
1 parent 9834bfa commit 77162f9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions base/filesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,19 @@ function close(f::File)
return nothing
end

# sendfile is the most efficient way to copy a file (or any file descriptor)
# sendfile is the most efficient way to copy from a file descriptor
function sendfile(dst::File, src::File, src_offset::Int64, bytes::Int)
check_open(dst)
check_open(src)
err = ccall(:jl_fs_sendfile, Int32, (OS_HANDLE, OS_HANDLE, Int64, Csize_t),
src.handle, dst.handle, src_offset, bytes)
uv_error("sendfile", err)
while true
result = ccall(:jl_fs_sendfile, Int32, (OS_HANDLE, OS_HANDLE, Int64, Csize_t),
src.handle, dst.handle, src_offset, bytes)
uv_error("sendfile", result)
nsent = result
bytes -= nsent
src_offset += nsent
bytes <= 0 && break
end
nothing
end

Expand Down

0 comments on commit 77162f9

Please sign in to comment.