static int
ll (const char* p)
{
DIR* dir;
struct dirent* dirent;
struct stat st;
struct tm tm;
char buf[255];
FX (p4_cr);
FX (p4_start_Q_cr);
# ifdef VxWorks
dir = opendir ((char*)p);
# else
dir = opendir (p);
# endif
if (!dir) return -1;
while ((dirent=readdir(dir)))
{
strncpy (buf, p, 255);
strncat (buf, "/" , 255);
strncat (buf, dirent->d_name, 255);
stat (buf, &st);
memcpy (&tm, localtime (&st.st_mtime), sizeof(struct tm));
if (S_ISREG (st.st_mode))
{
p4_outf ("%8i %2i-%02i-%04i %2i:%02i:%02i %s" , st.st_size,
tm.tm_mday, tm.tm_mon+1, tm.tm_year+1900,
tm.tm_hour, tm.tm_min, tm.tm_sec,
dirent->d_name);
} else if (S_ISDIR (st.st_mode))
{
p4_outf ("DIRECTORY %2i-%02i-%04i %2i:%02i:%02i %s" ,
tm.tm_mday, tm.tm_mon+1, tm.tm_year+1900,
tm.tm_hour, tm.tm_min, tm.tm_sec,
dirent->d_name);
} else {
p4_outf ("SPECIAL %2i-%02i-%04i %2i:%02i:%02i %s" ,
tm.tm_mday, tm.tm_mon+1, tm.tm_year+1900,
tm.tm_hour, tm.tm_min, tm.tm_sec,
dirent->d_name);
}
if (p4_Q_cr())
break;
}
return closedir (dir);
} |