#include "function.h"
#define BUFMAX 4096
+#define MAXLEN 256
int strmaxlen (char *str, char ch)
{
struct stat sb = {0};
int error = (STAT (name, &sb) == -1);
- free (name);
-#ifdef WIN32
- elem->uid = strdup ("");
-#else /* Linux*/
+#ifndef WIN32
if (!error) {
struct passwd *pwd = getpwuid (sb.st_uid);
if (pwd) {
}
#endif
-#ifdef WIN32
- elem->gid = strdup ("");
-#else /* Linux*/
+#ifndef WIN32
if (!error) {
struct group *grp = getgrgid (sb.st_gid);
if (grp) {
}
#endif
+#ifndef WIN32
+ if ((elem->type == type_symb_e) || (elem->type == type_ldir_e) || (elem->type == type_lreg_e) || (elem->type == type_erlk_e)) {
+ char lname[MAXLEN + 1] = {0};
+ int len = readlink (name, lname, MAXLEN);
+ if (len != -1) {
+ elem->link = strdup (lname);
+ }
+ }
+#endif
+
+ free (name);
+
elem->nlk = sb.st_nlink;
}
break;
}
- if (elem->uid && *elem->uid) {
+ if (elem->link) {
+ strcat (status, " -> ");
+ strcat (status, elem->link);
+ } else if (elem->uid && *elem->uid) {
strcat (status, " ");
strcat (status, elem->uid);
strcat (status, "/");
if (list) {
while (list->nb--) {
free ((list->tab + list->nb)->gid);
+ free ((list->tab + list->nb)->link);
free ((list->tab + list->nb)->name);
free ((list->tab + list->nb)->uid);
}