aboutsummaryrefslogtreecommitdiff
path: root/src/core/file.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-01-19 17:13:40 -0800
committerGarrett D'Amore <garrett@damore.org>2018-01-20 15:03:12 -0800
commit7dbc9ae4fef34c6fd836b939bd559e54b8008b72 (patch)
tree54660fef8a4a597c067a18953a295f1cfdb96cf0 /src/core/file.c
parent338706c2420ce3e51b546a6ba2574e10346a511b (diff)
downloadnng-7dbc9ae4fef34c6fd836b939bd559e54b8008b72.tar.gz
nng-7dbc9ae4fef34c6fd836b939bd559e54b8008b72.tar.bz2
nng-7dbc9ae4fef34c6fd836b939bd559e54b8008b72.zip
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.
Diffstat (limited to 'src/core/file.c')
-rw-r--r--src/core/file.c20
1 files changed, 20 insertions, 0 deletions
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;