1. 重命名
#include <stdio.h>
int rename (const char *oldpath, const char *newpath);
两个文件必在同一文件系统中,目录是不能复制的。
2. 复制
linux系统中并没有提供文件复制的系统调用或C语言函数,这个功能要自己实现,一般步骤为:
In copying a file src to a file named dst, the steps are as follows:
1. Open src.
2. Open dst, creating it if it does not exist, and truncating it to zero length if it does exist.
3. Read a chunk of src into memory.
4. Write the chunk to dst.
5. Continue until all of src has been read and written to dst.
6. Close dst.
7. Close src.
If copying a directory, the individual directory and any subdirectories are created via mkdir(); each file therein is then copied individually.