Skip to content

Instantly share code, notes, and snippets.

@jabedude
Created March 25, 2016 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jabedude/7ec5b33bb39d5320964f to your computer and use it in GitHub Desktop.
Save jabedude/7ec5b33bb39d5320964f to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <time.h>
int main(int argc, char* argv[])
{
if (argc < 2)
{
printf("Usage: must supply at least one file\n");
return 1;
}
struct dirent* dir_element;
struct stat file_info;
time_t c;
time_t m;
time_t cr;
for (int i = 1; i < argc; i++)
{
//lstat(dir_element->d_name, &file_info);
printf("%s\n", argv[i]);
lstat( argv[i], &file_info );
c = (long long)file_info.st_atim.tv_sec;
m = (long long)file_info.st_mtim.tv_sec;
cr = (long long)file_info.st_ctim.tv_sec;
printf("Create time: %s", ctime( &cr ) );
printf("Access time: %s", ctime( &c ) );
printf("Modification time: %s", ctime( &m ) );
//printf("%lld.%.9ld\n", (long long)file_info.st_atim.tv_sec, file_info.st_atim.tv_nsec);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment