Copy a file in a sane, safe and efficient way

前端 未结 7 1375
小蘑菇
小蘑菇 2020-11-22 07:11

I search for a good way to copy a file (binary or text). I\'ve written several samples, everyone works. But I want hear the opinion of seasoned programmers.

I missin

7条回答
  •  盖世英雄少女心
    2020-11-22 07:20

    I want to make the very important note that the LINUX method using sendfile() has a major problem in that it can not copy files more than 2GB in size! I had implemented it following this question and was hitting problems because I was using it to copy HDF5 files that were many GB in size.

    http://man7.org/linux/man-pages/man2/sendfile.2.html

    sendfile() will transfer at most 0x7ffff000 (2,147,479,552) bytes, returning the number of bytes actually transferred. (This is true on both 32-bit and 64-bit systems.)

提交回复
热议问题