linux编程创建文件
struct timeval log_time; gettimeofday(&log_time, NULL); sprintf(file_name, "rover_%ld.rtcm3", log_time.tv_sec); while(-1 != access(file_name, F_OK)) { sprintf(file_name, "rover_%ld.rtcm3", ++(log_time.tv_sec)); } umask(0000); rover_file = creat(file_name, 0666);
access函数判断文件是否存在
umask(0000)清除权限
creat(file_name, 0666)创建文件并设置权限为 0666