Skip to content

Commit

Permalink
print mod times for all files (also dirs)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-rden authored and emikulic committed Mar 12, 2024
1 parent 60256bc commit cbf356b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions darkhttpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2072,15 +2072,20 @@ static void generate_dir_listing(struct connection *conn, const char *path,
append_escaped(listing, list[i]->name);
append(listing, "</a>");

if (list[i]->is_dir)
append(listing, "/\n");
char buf[DIR_LIST_MTIME_SIZE];
struct tm tm;
localtime_r(&list[i]->mtime.tv_sec, &tm);
strftime(buf, sizeof buf, DIR_LIST_MTIME_FORMAT, &tm);

if (list[i]->is_dir) {
append(listing, "/");
appendl(listing, spaces, maxlen-strlen(list[i]->name));
append(listing, buf);
append(listing, "\n");
}
else {
appendl(listing, spaces, maxlen-strlen(list[i]->name));
append(listing, " ");
char buf[DIR_LIST_MTIME_SIZE];
struct tm tm;
localtime_r(&list[i]->mtime.tv_sec, &tm);
strftime(buf, sizeof buf, DIR_LIST_MTIME_FORMAT, &tm);
append(listing, buf);
appendf(listing, " %10llu\n", llu(list[i]->size));
}
Expand Down

0 comments on commit cbf356b

Please sign in to comment.