mirror of
https://github.com/fumiama/simple-http-server.git
synced 2026-06-17 18:00:29 +08:00
尝试修复getfilesize
This commit is contained in:
8
server.c
8
server.c
@@ -38,7 +38,7 @@ static void cat(int, FILE *);
|
|||||||
static void cannot_execute(int);
|
static void cannot_execute(int);
|
||||||
static void error_die(const char *);
|
static void error_die(const char *);
|
||||||
static void execute_cgi(int, const char *, const char *, const char *);
|
static void execute_cgi(int, const char *, const char *, const char *);
|
||||||
static off_t get_file_size(const char *, int);
|
static uint32_t get_file_size(const char *, int);
|
||||||
static int get_line(int, char *, int);
|
static int get_line(int, char *, int);
|
||||||
static void handle_quit(int);
|
static void handle_quit(int);
|
||||||
static void headers(int, const char *);
|
static void headers(int, const char *);
|
||||||
@@ -287,12 +287,12 @@ static void execute_cgi(int client, const char *path, const char *method, const
|
|||||||
/* Returns the size of a file. */
|
/* Returns the size of a file. */
|
||||||
/* Parameters: path of the file */
|
/* Parameters: path of the file */
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
static off_t get_file_size(const char *filepath, int client) {
|
static uint32_t get_file_size(const char *filepath, int client) {
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
off_t sz;
|
uint32_t sz;
|
||||||
if (!stat(filepath, &statbuf)) {
|
if (!stat(filepath, &statbuf)) {
|
||||||
sz = statbuf.st_size;
|
sz = statbuf.st_size;
|
||||||
printf("file size: %lu\n", sz);
|
printf("file size: %u\n", sz);
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user