mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-17 19:30:36 +00:00
Added test to mg_stat(). Fixed set_gpass()
This commit is contained in:
1 parent
03dd8367bf
commit
038f8823f1
2 files changed
+15
-1
No files matched your search
+7
-1
@@ -1331,6 +1331,8 @@ static int mg_stat(struct mg_connection *conn, const char *path,
|
|||||||
filep->size = st.st_size;
|
filep->size = st.st_size;
|
||||||
filep->modification_time = st.st_mtime;
|
filep->modification_time = st.st_mtime;
|
||||||
filep->is_directory = S_ISDIR(st.st_mode);
|
filep->is_directory = S_ISDIR(st.st_mode);
|
||||||
|
} else {
|
||||||
|
filep->modification_time = (time_t) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return filep->membuf != NULL || filep->modification_time != (time_t) 0;
|
return filep->membuf != NULL || filep->modification_time != (time_t) 0;
|
||||||
@@ -4461,7 +4463,11 @@ static void uninitialize_ssl(struct mg_context *ctx) {
|
|||||||
static int set_gpass_option(struct mg_context *ctx) {
|
static int set_gpass_option(struct mg_context *ctx) {
|
||||||
struct file file;
|
struct file file;
|
||||||
const char *path = ctx->config[GLOBAL_PASSWORDS_FILE];
|
const char *path = ctx->config[GLOBAL_PASSWORDS_FILE];
|
||||||
return path == NULL || !mg_stat(fc(ctx), path, &file);
|
if (path != NULL && !mg_stat(fc(ctx), path, &file)) {
|
||||||
|
cry(fc(ctx), "Cannot open %s: %s", path, strerror(ERRNO));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_acl_option(struct mg_context *ctx) {
|
static int set_acl_option(struct mg_context *ctx) {
|
||||||
|
|||||||
@@ -349,6 +349,13 @@ static void test_user_data(void) {
|
|||||||
call_user(fc(ctx), MG_NEW_REQUEST);
|
call_user(fc(ctx), MG_NEW_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_mg_stat(void) {
|
||||||
|
static struct mg_context ctx;
|
||||||
|
struct file file;
|
||||||
|
memset(&file, 'A', sizeof(file));
|
||||||
|
ASSERT(!mg_stat(fc(&ctx), " does not exist ", &file));
|
||||||
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
test_base64_encode();
|
test_base64_encode();
|
||||||
test_match_prefix();
|
test_match_prefix();
|
||||||
@@ -360,6 +367,7 @@ int main(void) {
|
|||||||
test_set_throttle();
|
test_set_throttle();
|
||||||
test_next_option();
|
test_next_option();
|
||||||
test_user_data();
|
test_user_data();
|
||||||
|
test_mg_stat();
|
||||||
#ifdef USE_LUA
|
#ifdef USE_LUA
|
||||||
test_lua();
|
test_lua();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in new issue
Block a user