copy_file_range() function of os module in Python

The copy_file_range() function copies a specified range of bytes from a source file to a destination file wherein both the files reside in the same filesystem.

Os Updated 13 May 2023 1 min read

Overview

  • The function copy_file_range() copies a byte range from one file to another.
  • Byte range in the source file is specified using the offset_src and count parameters.
  • The starting position from where the byte range is to be copied into the destination file is specified by the offset_dst.

The copy_file_range() function of os module in Python

Parameters

src – The file descriptor of the source file

dst – The file descriptor of the destination file

count – No of bytes to be copied

offset_src – Starting of the byte range in the source file

offset_dst – Starting of the byte range in the destination file

Return Value

Number of bytes copied