From 7dbc9ae4fef34c6fd836b939bd559e54b8008b72 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 19 Jan 2018 17:13:40 -0800 Subject: fixes #216 HTTP server side API refactoring, directory serving support This changes the backend (internal) HTTP API to provide a much more sensible handler scheme, where the handlers are opaque objects and we can allocate a handler for different types of tasks. We've also added support serving up directories of static content, and added code to validate that the directory serving is working as intended. This is a key enabling step towards the public API. --- src/core/file.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/core/file.c') diff --git a/src/core/file.c b/src/core/file.c index d7000a6a..4715be2a 100644 --- a/src/core/file.c +++ b/src/core/file.c @@ -28,6 +28,26 @@ nni_file_delete(const char *name) return (nni_plat_file_delete(name)); } +bool +nni_file_is_file(const char *name) +{ + int ft; + if ((nni_file_type(name, &ft) == 0) && (ft == NNI_FILE_TYPE_FILE)) { + return (true); + } + return (false); +} + +bool +nni_file_is_dir(const char *name) +{ + int ft; + if ((nni_file_type(name, &ft) == 0) && (ft == NNI_FILE_TYPE_DIR)) { + return (true); + } + return (false); +} + struct walkdata { nni_file_walker fn; void * arg; -- cgit v1.2.3-70-g09d2