系统编程中的文件链接
来源:互联网 发布:经传软件智能辅助线 编辑:程序博客网 时间:2024/06/01 12:29
系统编程中的文件链接
思维导图
示例代码
- link函数
#include <stdio.h>#include <stdlib.h>#include <unistd.h>int main(int argc, char* argv[]){ if(argc < 3) { printf("a.out oldpath newpath\n"); exit(0); } int ret = link(argv[1], argv[2]); if(ret == -1) { perror("link"); exit(1); } return 0;}
- symlink函数
#include <unistd.h>#include <stdio.h>#include <stdlib.h>int main(int argc, char* argv[]){ if(argc < 3) { printf("a.out oldpath newpath\n"); exit(1); } int ret = symlink(argv[1], argv[2]); if(ret == -1) { perror("symlink"); exit(1); } return 0;}
- readlink函数
#include <stdio.h>#include <stdlib.h>#include <unistd.h>int main(int argc, char* argv[]){ if(argc < 2) { printf("a.out softlink\n"); exit(1); } char buf[512]; int ret = readlink(argv[1], buf, sizeof(buf)); if(ret == -1) { perror("readlink"); exit(1); } buf[ret] = 0; printf("buf = %s\n", buf); return 0;}
- unlink函数
unlink函数用作处理缓存文件最为合适不过,比如视频软件(优酷app)或者下载软件(迅雷)
#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>int main(void){ int fd = open("tempfile", O_CREAT | O_RDWR, 0755); if(fd == -1) { perror("open"); exit(1); } int ret = unlink("tempfile"); if(ret == -1) { perror("unlink"); exit(1); } char buf[512]; write(fd, "hello", 5); lseek(fd, 0, SEEK_SET); int len = read(fd, buf, sizeof(buf)); write(STDOUT_FILENO, buf, len); close(fd); return 0;}
0 0
- 系统编程中的文件链接
- 系统编程中的基础文件操作
- linux中的链接文件
- linux中的链接文件
- Win10 中的文件链接
- 系统编程中的文件状态获取--stat函数
- 系统编程中的文件权限相关--access/chmod/chown函数
- Linux系统文件编程
- Qt中的动态链接库编程
- Qt中的动态链接库编程
- Qt中的动态链接库编程
- 认识Linux系统中的inode,硬链接和软链接
- Linux 系统中的硬链接与软链接
- 编程中的文件流
- 教学管理系统-链接文件的发布问题
- 点击UltraWebGrid单元格中的链接,下载文件
- uboot中的.lds链接文件解析
- g++编译链接文件基础中的基础
- 即将推出如何通过迈思德网关开发MQTT教程
- jQuery的基本知识
- TCP协议的三次握手和四次挥手
- 探秘:人在濒死前会看到什么
- 性能优化二之内存泄漏
- 系统编程中的文件链接
- 二、Math3D向量的计算
- android---- java.lang.NoClassDefFoundError:android.support.v7.widget.TintManager
- Android Studio配置Genymotion 模拟器
- 在图片相册中复用性程序
- android AsyncTask分析
- ubuntu 由于没有公钥 ,无法验证签名
- [jQuery知识]jQuery之知识七-事件初级
- int、long、long long取值范围