C
weixin_39566143
这个作者很懒,什么都没留下…
展开
-
远程文件夹同步,涉及 linux c socket inotify等知识
远程文件夹绑定,使用远程文件夹里的内容同步更新原创 2022-04-22 20:12:10 · 1295 阅读 · 0 评论 -
unix/linux 统计某个目录下面的文件类型百分比
//// Created by xia on 2022/4/6.//#define _XOPEN_SOURCE 600#include "common.h"#include "ftw.h"size_t reg_count=0,dir_count=0,chr_count=0,blk_count=0,lnk_count=0,fifo_count=0,sock_count=0,unknown_count=0;static int dirTree(const char *pathName,co原创 2022-04-06 16:37:55 · 303 阅读 · 0 评论 -
linux/unix getcmd pwd 实现源码
//// Created by xia on 2022/4/6.//#include "common.h"#include "fcntl.h"#include "dirent.h"#include "sys/stat.h"char* my_getcwd(char *buf,size_t size){ if(buf == NULL) return NULL; int work_fd = open(".",O_RDONLY); DIR *dp;原创 2022-04-06 16:06:16 · 325 阅读 · 0 评论 -
unix realpath函数实现代码
//// Created by xia on 2022/4/5.//#include <libgen.h>#include "tlpi_hdr.h"#include <fcntl.h>#include <sys/types.h>#include <sys/stat.h>#include <dirent.h>char *my_realpath(const char *path, char *resolved_path){原创 2022-04-06 11:51:18 · 570 阅读 · 0 评论 -
模仿unix tail程序的源代码,只支持 -n 指定行数
//// Created by xia on 2022/3/16.//#include "common.h"int main(int argc,char *argv[]){ if(argc <2 || strcmp(argv[1],"--help")==0) errExit("%s [-n lines] file",argv[0]); int opt,n=10; while ((opt = getopt(argc,argv,"n:")) != -1原创 2022-03-16 20:51:41 · 308 阅读 · 0 评论