小记——linux复制文件与重命名
两个文件必在同一文件系统中,目录是不能复制的。
- 复制
linux系统中并没有提供文件复制的系统调用或C语言函数,这个功能要自己实现,一般步骤为:
In copying a file src to a file named dst, the steps are as follows:
- Open src.
- Open dst, creating it if it does not exist, and truncating it to zero length if it does exist.
- Read a chunk of src into memory.
- Write the chunk to dst.
- Continue until all of src has been read and written to dst.
- Close dst.
- Close src.
If copying a directory, the individual directory and any subdirectories are created via mkdir(); each file therein is then copied individually.
还没有评论,来说两句吧...