background image

LINUX 系统 C 语言实现指定目录下文件去重

给定目录的绝对路径,程序自动扫描该目录下的全部文件(忽略子目录),并召出

…… 

内容相同的文件,由用户确定是否删除重复文件

int main()函数:主函数

void List()函数:对指定目录进行遍历,并依次创建文件描述符

int find()函数:进行文件比对

int compare()函数:比对两个文件的内容是否相同

#include<dirent.h>

#include<string.h>

#include<stdio.h>

#include<sys/stat.h>

#include<fcntl.h>

#include<unistd.h>

#include<stdlib.h>

 

struct F   //结构体 F,保存有文件描述符,文件名,文件的绝对位置

{

int id;

char name[512];

char path[512];

};