aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2022-07-04 14:31:17 +0000
committerOmar Polo <op@omarpolo.com>2022-07-04 14:31:17 +0000
commit543f4a66fec191b16621ae4f7783782131a3b067 (patch)
tree77dcbdb0db85c83a754e76bd0a5dde5d45ee1910
parent5734723f92a0fd72967e89f9460ff9552ea9aff2 (diff)
add a trailing / for dirs in the directory index.
-rw-r--r--server.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/server.c b/server.c
index 0e7800c..2258e67 100644
--- a/server.c
+++ b/server.c
@@ -1098,9 +1098,13 @@ client_write(struct bufferevent *bev, void *d)
case REQUEST_DIR:
/* TODO: handle big big directories better */
for (c->diroff = 0; c->diroff < c->dirlen; ++c->diroff) {
+ const char *sufx = "";
+
encode_path(nam, sizeof(nam),
c->dir[c->diroff]->d_name);
- evbuffer_add_printf(out, "=> ./%s\n", nam);
+ if (c->dir[c->diroff]->d_type == DT_DIR)
+ sufx = "/";
+ evbuffer_add_printf(out, "=> ./%s%s\n", nam, sufx);
free(c->dir[c->diroff]);
}
free(c->dir);