옵션 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | void ls(char *filename) { DIR *dp; file *f=0; struct dirent *dent; struct stat buf; char buffer[BUFSIZ]; if((dp = opendir(filename))== NULL) { perror("opendir"); exit(1); } printf("%s:\n", filename); //printf("mode\t\tnlink\tuser(uid)\tgroup(gid)\tsize\tmtime\t\t\tname\n"); while(dent = readdir(dp)) { lstat(dent->d_name, &buf); insert_list(&f, buf.st_mode, buf.st_nlink, buf.st_uid, buf.st_gid, buf.st_size, buf.st_mtime, dent->d_name); } print_list(&f); while(f) { if(S_ISDIR(buf.st_mode) && strcmp(f->filename, ".")!=0 && strcmp(f->filename, "..")!=0) { sprintf(buffer, "%s/%s", filename, f->filename); printf("\n"); ls(buffer); } f = f->next; } closedir(dp); } |
CodeHighligher |