Skip to content

Commit

Permalink
Merge pull request adrianlopezroche#125 from jakem72360/compare-times
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianlopezroche committed Sep 17, 2019
2 parents 0f195bb + f1b7ac6 commit 0b63af8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions fdupes.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <dirent.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
Expand Down Expand Up @@ -160,6 +161,14 @@ time_t getctime(char *filename) {
return s.st_ctime;
}

char *fmtmtime(char *filename) {
static char buf[64];
time_t t = getmtime(filename);

strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M", localtime(&t));
return buf;
}

char **cloneargs(int argc, char **argv)
{
int x;
Expand Down Expand Up @@ -916,13 +925,13 @@ void deletefiles(file_t *files, int prompt, FILE *tty, char *logfile)
counter = 1;
dupelist[counter] = files;

if (prompt) printf("[%d] %s\n", counter, files->d_name);
if (prompt) printf("[%d] [%s] %s\n", counter, fmtmtime(files->d_name), files->d_name);

tmpfile = files->duplicates;

while (tmpfile) {
dupelist[++counter] = tmpfile;
if (prompt) printf("[%d] %s\n", counter, tmpfile->d_name);
if (prompt) printf("[%d] [%s] %s\n", counter, fmtmtime(tmpfile->d_name), tmpfile->d_name);
tmpfile = tmpfile->duplicates;
}

Expand Down

0 comments on commit 0b63af8

Please sign in to comment.