mirror of
https://github.com/fumiama/simple-http-server.git
synced 2026-06-05 00:30:23 +08:00
stat失效的方案
This commit is contained in:
6
server.c
6
server.c
@@ -293,6 +293,12 @@ off_t get_file_size(const char *filepath) {
|
||||
struct stat statbuf;
|
||||
if (stat(filepath, &statbuf) == 0) {
|
||||
printf("file size: %u\n", statbuf.st_size);
|
||||
if(statbuf.st_size == 0) {
|
||||
FILE* fp = fopen(filepath, "ab+");
|
||||
off_t sz = ftell(fp);
|
||||
printf("ftell size: %u\n", sz);
|
||||
return sz;
|
||||
}
|
||||
return statbuf.st_size;
|
||||
}
|
||||
else return -1;
|
||||
|
||||
Reference in New Issue
Block a user