Commit 7f2d175c authored by Zara Saldanha's avatar Zara Saldanha

Update traverse.c

parent 8dc69800
......@@ -58,11 +58,14 @@ void process(char *root)
enqueue(root,&nameq);
time_t latest = 0;
char* dName;
struct stat dStat;
while (true != queue_empty(nameq)) {
peek_front(dname,nameq);
dequeue(&nameq);
dirp = opendir(dname);
memset(&dStat, 0, sizeof(dStat));
stat(dp->d_name, &dStat)
if (dirp != NULL) { // it is a directory
num_dir=num_dir+1;
printf("directory : %s\n",dname);
......@@ -80,6 +83,10 @@ void process(char *root)
strncat(cname, dp->d_name, MAXLENGTH);
enqueue(cname,&nameq);
}
if (dStat.st_mtime > latest) {
strcpy(dName, dp->d_name);
latest = file_info.st_mtime;
}
}
closedir (dirp);
} else {
......@@ -99,10 +106,7 @@ void process(char *root)
if(min>file_info.st_size){
min = file_info.st_size;
}
if (file_info.st_mtime > latest) {
strcpy(dName, fd->d_name);
latest = file_info.st_mtime;
}
sum = sum + file_info.st_size;
}
} // while
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment