diff --git a/bin/webs.c b/bin/webs.c
index 5babb8f..a326bbc 100644
--- a/bin/webs.c
+++ b/bin/webs.c
@@ -76,7 +76,7 @@ done:
}
}
-static void bfmt_dir (hio_svc_htts_t* htts, int fd, hio_svc_htts_file_bfmt_dir_type_t type, const hio_bch_t* name, void* ctx)
+static void bfmt_dir (hio_svc_htts_t* htts, int fd, const hio_bch_t* qpath, hio_svc_htts_file_bfmt_dir_type_t type, const hio_bch_t* name, void* ctx)
{
/* TODO: do bufferring */
/* "name */
@@ -93,8 +93,20 @@ static void bfmt_dir (hio_svc_htts_t* htts, int fd, hio_svc_htts_file_bfmt_dir_t
{
HIO_ASSERT (hio_svc_htts_gethio(htts), name != HIO_NULL);
+ if (name[0] == '.' && name[1] == '\0') return;
+
+ if (qpath[0] == '\0' || (qpath[0] == '/' && qpath[1] == '\0'))
+ {
+ /* at the root */
+ if (name[0] == '.' && name[1] == '.' && name[2] == '\0') return;
+ }
+
/* TODO: get the directory name
-check if the entry is a directory or something else */
+check if the entry is a directory or something else
+do escaping...
+show file size?
+append / if the file is a directory
+*/
write (fd, "
", 2);
diff --git a/lib/hio-http.h b/lib/hio-http.h
index 4c238bd..c021245 100644
--- a/lib/hio-http.h
+++ b/lib/hio-http.h
@@ -171,7 +171,7 @@ typedef enum hio_svc_htts_file_bfmt_dir_type_t hio_svc_htts_file_bfmt_dir_type_t
struct hio_svc_htts_file_cbs_t
{
- int (*bfmt_dir) (hio_svc_htts_t* htts, int fd, hio_svc_htts_file_bfmt_dir_type_t type, const hio_bch_t* name, void* ctx);
+ int (*bfmt_dir) (hio_svc_htts_t* htts, int fd, const hio_bch_t* qpath, hio_svc_htts_file_bfmt_dir_type_t type, const hio_bch_t* name, void* ctx);
void *ctx;
};
typedef struct hio_svc_htts_file_cbs_t hio_svc_htts_file_cbs_t;
diff --git a/lib/http-file.c b/lib/http-file.c
index bf4dabc..067c609 100644
--- a/lib/http-file.c
+++ b/lib/http-file.c
@@ -719,12 +719,12 @@ static int open_peer_for_dir_listing (file_t* file, const hio_bch_t* dir_path, i
if (file->cbs && file->cbs->bfmt_dir)
{
/* TODO: can support sorting?? */
- file->cbs->bfmt_dir (file->htts, alt_fd, HIO_SVC_HTTS_FILE_BFMT_DIR_HEADER, HIO_NULL, file->cbs->ctx);
+ file->cbs->bfmt_dir (file->htts, alt_fd, file->req_qpath, HIO_SVC_HTTS_FILE_BFMT_DIR_HEADER, HIO_NULL, file->cbs->ctx);
while ((de = readdir(dp)))
{
- file->cbs->bfmt_dir (file->htts, alt_fd, HIO_SVC_HTTS_FILE_BFMT_DIR_ENTRY, de->d_name, file->cbs->ctx);
+ file->cbs->bfmt_dir (file->htts, alt_fd, file->req_qpath, HIO_SVC_HTTS_FILE_BFMT_DIR_ENTRY, de->d_name, file->cbs->ctx);
}
- file->cbs->bfmt_dir (file->htts, alt_fd, HIO_SVC_HTTS_FILE_BFMT_DIR_FOOTER, HIO_NULL, file->cbs->ctx);
+ file->cbs->bfmt_dir (file->htts, alt_fd, file->req_qpath, HIO_SVC_HTTS_FILE_BFMT_DIR_FOOTER, HIO_NULL, file->cbs->ctx);
}
else
{