Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
- #include <stdlib.h>
- #include <dirent.h>
- char* formatdate(char* str, time_t val)
- {
- strftime(str, 36, "%m.%d.%Y %H:%M", localtime(&val));
- return str;
- }
- int main(int argc, char **argv){
- DIR *adresar;
- char date[36];
- int size;
- struct stat buffer;
- struct dirent *subor;
- adresar=opendir("."); //Otvorime si adresar
- while ((subor=readdir(adresar))!=NULL){ //Citame kym je co citat
- stat(subor->d_name, &buffer);
- printf("%s ", formatdate(date, buffer.st_mtime));
- size = buffer.st_size;
- printf("%d %s\n",size, subor->d_name); //A vypiseme nazov suboru
- }
- closedir(adresar); //A nakoniec adresar zatvorime
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement