mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Add file name len to entry structure
This commit is contained in:
parent
bc1e74bc56
commit
0945dfb91a
18
nnn.c
18
nnn.c
|
@ -196,6 +196,7 @@ typedef struct entry {
|
||||||
off_t size;
|
off_t size;
|
||||||
blkcnt_t blocks; /* number of 512B blocks allocated */
|
blkcnt_t blocks; /* number of 512B blocks allocated */
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
|
uchar nlen; /* Length of file name */
|
||||||
} *pEntry;
|
} *pEntry;
|
||||||
|
|
||||||
/* Bookmark */
|
/* Bookmark */
|
||||||
|
@ -1850,17 +1851,22 @@ dentfill(char *path, struct entry **dents,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* realloc() may result in memory move, we must re-adjust if that happens */
|
/* realloc() may result in memory move, we must re-adjust if that happens */
|
||||||
if (pnb != pnamebuf)
|
if (pnb != pnamebuf) {
|
||||||
for (count = 0; count < n; ++count)
|
dentp = *dents;
|
||||||
/* Add file name start offset to new buffer start */
|
dentp->name = pnamebuf;
|
||||||
(*dents + count)->name = pnamebuf + ((ulong)(*dents + count)->name - (ulong)pnb);
|
|
||||||
|
for (count = 1; count < n; ++dentp, ++count)
|
||||||
|
/* Current filename starts at last filename start + length */
|
||||||
|
(dentp + 1)->name = (char *)((size_t)dentp->name + dentp->nlen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dentp = *dents + n;
|
dentp = *dents + n;
|
||||||
|
|
||||||
/* Copy file name */
|
/* Copy file name */
|
||||||
dentp->name = pnamebuf + off;
|
dentp->name = (char *)((size_t)pnamebuf + off);
|
||||||
off += xstrlcpy(dentp->name, namep, NAME_MAX + 1);
|
dentp->nlen = xstrlcpy(dentp->name, namep, NAME_MAX + 1);
|
||||||
|
off += dentp->nlen;
|
||||||
|
|
||||||
/* Copy other fields */
|
/* Copy other fields */
|
||||||
dentp->mode = sb.st_mode;
|
dentp->mode = sb.st_mode;
|
||||||
|
|
Loading…
Reference in a new issue