Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void listDirectory(char *name) {
- DIR *dir;
- directoryContent fileInfo;
- growingArray content;
- int i;
- initArray(&content,2);
- if ((dir = opendir(name)) == NULL) {
- perror("Blad");
- }
- while ((fileInfo.dp = readdir(dir)) != NULL) {
- if (stat(fileInfo.dp->d_name, &(fileInfo.statbuf)) == -1)
- continue;
- fileInfo.userID = getpwuid(fileInfo.statbuf.st_uid);
- fileInfo.userGroup = getgrgid(fileInfo.statbuf.st_gid);
- getDate(fileInfo.dateLastAccess, fileInfo.statbuf, 64);
- insertArray(&content,fileInfo);
- }
- closedir(dir);
- qsort(content.array, content.used, sizeof(directoryContent),compare);
- for(i = 0; i < content.used; i++){
- polishMonth(content.array[i].dateLastAccess);
- printList(content.array[i]);
- }
- freeArray(&content);
- }
- int main(int argc, char **argv) {
- if(argc <= 1){
- listDirectory(".");
- }
- else{/*Czy tam pisze Elsa ?*/
- listDirectory(argv[1]);
- }
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement