7 static char *timestring(time_t t)
9 static char TimeBuf[200];
10 struct tm *tm = localtime(&t);
12 strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %T",tm);
14 if (TimeBuf[strlen(TimeBuf)-1] == '\n') {
15 TimeBuf[strlen(TimeBuf)-1] = 0;
21 static void ls_one(char *fname)
23 char perms[11] = "----------";
24 char *perm_map = "rwxrwxrwx";
28 if (lstat(fname, &st) != 0) {
34 if (st.st_mode & (1<<i)) perms[9-i] = perm_map[8-i];
36 if (S_ISLNK(st.st_mode)) perms[0] = 'l';
37 if (S_ISDIR(st.st_mode)) perms[0] = 'd';
38 if (S_ISBLK(st.st_mode)) perms[0] = 'b';
39 if (S_ISCHR(st.st_mode)) perms[0] = 'c';
40 if (S_ISSOCK(st.st_mode)) perms[0] = 's';
41 if (S_ISFIFO(st.st_mode)) perms[0] = 'p';
44 printf("%s %11.0f %s %s\n",
46 (double)st.st_size, timestring(st.st_mtime), fname);
49 int main(int argc, char *argv[])
53 for (i=1; i<argc;i++) {