Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <sys/types.h>
  3. #include <sys/stat.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <time.h>
  7. #include <stdlib.h>
  8. #include <dirent.h>
  9. char* formatdate(char* str, time_t val)
  10. {
  11.         strftime(str, 36, "%m.%d.%Y %H:%M", localtime(&val));
  12.         return str;
  13. }
  14. int main(int argc, char **argv){
  15.     DIR *adresar;
  16.     char date[36];
  17.     int size;
  18.    
  19.     struct stat buffer;
  20.     struct dirent *subor;
  21.     adresar=opendir("."); //Otvorime si adresar
  22.     while ((subor=readdir(adresar))!=NULL){ //Citame kym je co citat
  23.        stat(subor->d_name, &buffer);
  24.        printf("%s ", formatdate(date, buffer.st_mtime));
  25.        size = buffer.st_size;
  26.        printf("%d %s\n",size, subor->d_name); //A vypiseme nazov suboru
  27.     }
  28.     closedir(adresar); //A nakoniec adresar zatvorime
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement