Linux Make in C

modifedTime.h #ifndef MODIFIEDTIME_H #define MODIFIEDTIME_H #include <sys/types.h> #include <sys/stat.h> time_t modifedTime(char *path); #endif /* MODIFIEDTIME_H */ modifiedTime.c modifiedTime以time_t返回文件最后一次修改的时间 #include “modifedTime.h” #include <sys/types.h> #include <sys/stat.h> #include <time.h> time_t modifedTime(char *path) { struct stat attr; if (stat(path, &attr) == 0) { return attr.st_mtime; } exit(1); return 0; } doCommand.c doCommand执行Unix命令,无异常返回true,否则false。 #include <stdlib.h> typedef enum { false, true… Read more Linux Make in C

Linux cp command in C

This is a simple implementation of cp command in linux, if you are student in University of Adelaide who happens to take SPC course, please do not copy this code directly. Code still can be optimized but I’m not gonna fix it since no mark will be given for coding style. CP命令的C实现~ Compile: gcc -o… Read more Linux cp command in C