zorajiang / mongoose

Automatically exported from code.google.com/p/mongoose
0 stars 0 forks source link

No indication that directory for option root does not exist. #101

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Even with DEBUG defined, there is no indication that the directory
configured for option-root does not exist.  Maybe there is something
in the logs but I didn't have them turned on.

Original issue reported on code.google.com by joel.she...@gmail.com on 16 Nov 2009 at 2:56

GoogleCodeExporter commented 8 years ago
The following is enough code to detect the error on Linux and RTEMS and return 
an
error.  It may have to be different on Windows.

static bool_t
set_root_option(struct mg_context *ctx, const char *root)
{
    struct stat buf;
    if ( stat(root, &buf) != 0) {
        cry(fc(ctx), "Invalid directory for root (%s)", root);
        return (FALSE);

    }
    return (TRUE);
}

static const struct mg_option known_options[] = {
    {"root", "\tWeb root directory", NULL, OPT_ROOT, set_root_option},

Original comment by joel.she...@gmail.com on 16 Nov 2009 at 5:22

GoogleCodeExporter commented 8 years ago
Doh!  You guys already had mg_stat. :)

static bool_t
set_root_option(struct mg_context *ctx, const char *root)
{
    struct mgstat buf;
    if ( mg_stat(root, &buf) != 0) {
        cry(fc(ctx), "Invalid directory for root (%s)", root);
        return (FALSE);

    }
    return (TRUE);
}

Original comment by joel.she...@gmail.com on 16 Nov 2009 at 5:26

GoogleCodeExporter commented 8 years ago
Patched in, http://code.google.com/p/mongoose/source/detail?r=478

Thank you!

Original comment by valenok on 27 Nov 2009 at 5:15