acassis commented on code in PR #3406:
URL: https://github.com/apache/nuttx-apps/pull/3406#discussion_r2840450044
##########
nshlib/nsh_fscmds.c:
##########
@@ -360,13 +364,52 @@ static int ls_handler(FAR struct nsh_vtbl_s *vtbl, FAR
const char *dirpath,
if ((lsflags & (LSFLAGS_SIZE | LSFLAGS_LONG | LSFLAGS_UID_GID)) != 0)
{
- struct stat buf;
+ struct stat buf;
- memset(&buf, 0, sizeof(struct stat));
+ memset(&buf, 0, sizeof(buf));
+
+ /* stat the file */
+ if (entryp != NULL)
+ {
+ FAR char *fullpath = nsh_getdirpath(vtbl, dirpath, entryp->d_name);
+ ret = stat(fullpath, &buf);
+ free(fullpath);
+ }
+ else
+ {
+ ret = stat(dirpath, &buf);
+ }
- /* stat the file */
+ #ifdef CONFIG_CLOCK_TIMEKEEPING
+ if (ret == 0 && buf.st_mtime > 0 && buf.st_mtime < 0x7FFFFFFF)
+ {
+ struct tm tm;
+ time_t t = buf.st_mtime;
- if (entryp != NULL)
+ #ifdef CONFIG_LIBC_LOCALTIME
+ localtime_r(&t, &tm);
+ nsh_output(vtbl, " %04d-%02d-%02d %02d:%02d",
+ tm.tm_year + 1900,
+ tm.tm_mon + 1,
+ tm.tm_mday,
+ tm.tm_hour,
+ tm.tm_min);
Review Comment:
@Biancaa-R please fix the alignment, all "tm.*" lines should start
immediately after the "(" from previous line.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]