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.

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:22 天前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐