#include <fcntl.h>
#include <errno.h>
#include <libgen.h>
+#include <unistd.h>
+#include <limits.h>
static char *
getRecentName(char *start, char *end)
{
char *res = 0;
int fd;
+ char buf[PATH_MAX];
strcpy(end, "/name");
fd = open(start, O_RDONLY);
if (res==0) {
*end = '\0';
- res = basename(start);
+ res = realpath(start, buf);
+ //printf("start='%s', res='%s'\n", start,res);
+ if (res==0) res = start;
+
+ res = basename(res);
}
return strdup(res);