mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-11 15:35:13 +00:00
netutils: webserver: Fix directory handling
Summary: - I noticed that the webserver can not handle a directory. - This commit fixes this issue. Impact: - None Testing: - Tested with spresense:wifi_smp Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
parent
4eda9bda8f
commit
6fb173e3d5
2 changed files with 13 additions and 4 deletions
|
|
@ -109,7 +109,7 @@ bool httpd_is_file(FAR const char *filename)
|
|||
{
|
||||
char *path;
|
||||
int fd;
|
||||
bool ret = false;
|
||||
bool ret = true;
|
||||
|
||||
path = malloc(CONFIG_NAME_MAX);
|
||||
ASSERT(path);
|
||||
|
|
@ -117,12 +117,12 @@ bool httpd_is_file(FAR const char *filename)
|
|||
snprintf(path, CONFIG_NAME_MAX, "%s/%s",
|
||||
CONFIG_NETUTILS_HTTPD_PATH, filename);
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
fd = open(path, O_DIRECTORY);
|
||||
|
||||
if (-1 != fd)
|
||||
{
|
||||
close(fd);
|
||||
ret = true;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
free(path);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,16 @@ int httpd_sendfile_open(const char *name, struct httpd_fs_file *file)
|
|||
|
||||
file->len = (int) st.st_size;
|
||||
|
||||
file->fd = open(file->path, O_RDONLY);
|
||||
if (S_ISDIR(st.st_mode))
|
||||
{
|
||||
/* we assume -1 as a directory */
|
||||
|
||||
file->fd = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
file->fd = open(file->path, O_RDONLY);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_NETUTILS_HTTPD_DIRLIST
|
||||
if (file->fd == -1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue