Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <stdint.h>
- #include <time.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/sysmacros.h>
- #include <dirent.h>
- int main(int argc, char *argv[])
- {
- DIR* d;
- char* nume_fisere = (char*)malloc(100*sizeof(char));
- struct dirent *dir;
- struct stat sb;
- struct tm dt;
- if (argc != 2) {
- printf("nu sunt suficiente argumente\n");
- exit(EXIT_FAILURE);
- }
- int contor = 0;
- d = opendir(argv[1]);
- if (d) { //Verifica daca s-a deschis cu succes folderul
- while ((dir = readdir(d)) != NULL)
- {
- printf("%s\n", dir->d_name);
- nume_fisere[contor] = *dir->d_name;
- contor++;
- }
- }
- for (int i = 0; i < contor; i++) {
- if(lstat(argv[1], &sb) == -1){
- printf("Eroare fisiere\n");
- exit(EXIT_FAILURE);
- }
- //lstat(nume_fisere[i], &sb);
- dt = *(gmtime(&sb.st_ctime));
- printf("File type: ");
- printf("I-node number: %ju\n", (uintmax_t) sb.st_ino);
- printf("Mode: %jo (octal)\n", (uintmax_t) sb.st_mode);
- printf("Link count: %ju\n", (uintmax_t) sb.st_nlink);
- printf("Ownership: UID=%ju GID=%ju\n", (uintmax_t) sb.st_uid, (uintmax_t) sb.st_gid);
- printf("Preferred I/O block size: %jd bytes\n", (intmax_t) sb.st_blksize);
- printf("File size: %jd bytes\n", (intmax_t) sb.st_size);
- printf("Blocks allocated: %jd\n", (intmax_t) sb.st_blocks);
- printf("Created on: %d-%d-%d %d:%d:%d\n", dt.tm_mday, dt.tm_mon, dt.tm_year + 1900, dt.tm_hour, dt.tm_min, dt.tm_sec);
- printf("\n");
- }
- free(nume_fisere);
- }
Advertisement
Add Comment
Please, Sign In to add comment