????????ls???????????????????????????μ????????????????????????????????????????????飬?????????С??????η???????????????????????????????
????????????????????:
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <unistd.h>
7 #include <dirent.h>
8 #include <sys/types.h>
9 #include <pwd.h>
10 #include <grp.h>
11 #include <time.h>
12 #define CNT 256
13 int file_name(DIR *fp?? char *path?? char name[][CNT]);
14 void str_sort(char name[][CNT]?? int cnt);
15 void mode_to_char(mode_t mode?? char *buf);
16 char *time_change(char *time);
17 void show(char name[][CNT]?? int cnt);
??????????????????????????????????????????????????????????int?????
??????????????????:
1intfile_name(DIR*fp??char*path??charname[][CNT])
2{
3intcnt=0;
4structdirent*p;
5while((p=readdir(fp))!=NULL)
6{
7if(strncmp(p->d_name??"."??1)==0||strncmp(p->d_name??".."??2)==0)
8continue;
9strcpy(name[cnt]??path);
10strcat(name[cnt]??"/");
11strcat(name[cnt]??p->d_name);
12cnt++;
13}
14closedir(fp);
15returncnt;
16}
??????????????????????????????????????????????char *buf?С?