mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-27 12:26:24 +00:00
Remove mg_stat
This commit is contained in:
1 parent
7e1d4325ec
commit
d6dbf831f7
8 files changed
+63
-53
No files matched your search
+8
-8
@@ -371,7 +371,7 @@ static void restore_http_cb(struct mg_connection *c) {
|
||||
c->pfn = http_cb;
|
||||
}
|
||||
|
||||
char *mg_http_etag(char *buf, size_t len, mg_stat_t *st) {
|
||||
char *mg_http_etag(char *buf, size_t len, struct stat *st) {
|
||||
snprintf(buf, len, "\"%lx." MG_INT64_FMT "\"", (unsigned long) st->st_mtime,
|
||||
(int64_t) st->st_size);
|
||||
return buf;
|
||||
@@ -512,10 +512,10 @@ static int getrange(struct mg_str *s, int64_t *a, int64_t *b) {
|
||||
void mg_http_serve_file(struct mg_connection *c, struct mg_http_message *hm,
|
||||
const char *path, const char *mime, const char *hdrs) {
|
||||
struct mg_str *inm = mg_http_get_header(hm, "If-None-Match");
|
||||
mg_stat_t st;
|
||||
struct stat st;
|
||||
char etag[64];
|
||||
FILE *fp = fopen(path, "rb");
|
||||
if (fp == NULL || mg_stat(path, &st) != 0 ||
|
||||
if (fp == NULL || stat(path, &st) != 0 ||
|
||||
mg_http_etag(etag, sizeof(etag), &st) != etag) {
|
||||
LOG(LL_DEBUG, ("404 [%.*s] [%s] %p", (int) hm->uri.len, hm->uri.ptr, path,
|
||||
(void *) fp));
|
||||
@@ -589,8 +589,8 @@ bool mg_is_dir(const char *path) {
|
||||
struct FF_STAT st;
|
||||
return (ff_stat(path, &st) == 0) && (st.st_mode & FF_IFDIR);
|
||||
#else
|
||||
mg_stat_t st;
|
||||
return mg_stat(path, &st) == 0 && S_ISDIR(st.st_mode);
|
||||
struct stat st;
|
||||
return stat(path, &st) == 0 && S_ISDIR(st.st_mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -706,7 +706,7 @@ struct dirent *readdir(DIR *d) {
|
||||
#endif
|
||||
|
||||
static void printdirentry(struct mg_connection *c, const char *name,
|
||||
mg_stat_t *stp) {
|
||||
struct stat *stp) {
|
||||
char size[64], mod[64], path[MG_PATH_MAX];
|
||||
int is_dir = S_ISDIR(stp->st_mode), n = 0;
|
||||
const char *slash = is_dir ? "/" : "";
|
||||
@@ -787,14 +787,14 @@ static void listdir(struct mg_connection *c, struct mg_http_message *hm,
|
||||
(int) hm->uri.len, hm->uri.ptr);
|
||||
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
mg_stat_t st;
|
||||
struct stat st;
|
||||
const char *sep = dp->d_name[0] == MG_DIRSEP ? "/" : "";
|
||||
// Do not show current dir and hidden files
|
||||
if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) continue;
|
||||
// SPIFFS can report "/foo.txt" in the dp->d_name
|
||||
if (snprintf(path, sizeof(path), "%s%s%s", dir, sep, dp->d_name) < 0) {
|
||||
LOG(LL_ERROR, ("%s truncated", dp->d_name));
|
||||
} else if (mg_stat(path, &st) != 0) {
|
||||
} else if (stat(path, &st) != 0) {
|
||||
LOG(LL_ERROR, ("%lu stat(%s): %d", c->id, path, errno));
|
||||
} else {
|
||||
printdirentry(c, dp->d_name, &st);
|
||||
|
||||
Reference in new issue
Block a user