diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-01-19 17:13:40 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-01-20 15:03:12 -0800 |
| commit | 7dbc9ae4fef34c6fd836b939bd559e54b8008b72 (patch) | |
| tree | 54660fef8a4a597c067a18953a295f1cfdb96cf0 /src/core | |
| parent | 338706c2420ce3e51b546a6ba2574e10346a511b (diff) | |
| download | nng-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')
| -rw-r--r-- | src/core/file.c | 20 | ||||
| -rw-r--r-- | src/core/file.h | 8 |
2 files changed, 28 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; diff --git a/src/core/file.h b/src/core/file.h index b45aae61..7969ae5f 100644 --- a/src/core/file.h +++ b/src/core/file.h @@ -76,4 +76,12 @@ extern char *nni_file_join(const char *, const char *); // The returned value generally is within the supplied path name. extern const char *nni_file_basename(const char *); +// nni_file_is_file returns true if the path references a file. It returns +// false if an error occurs, or the path references something else. +extern bool nni_file_is_file(const char *); + +// nni_file_is_dir returns true if the path references a directroy. It returns +// false if an error occurs, or the path references something else. +extern bool nni_file_is_dir(const char *); + #endif // CORE_FILE_H |
