From 4a65c8d66b38fbc5ac154d13087f617b458ac9a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 7 Jun 2021 22:51:46 +0800 Subject: [PATCH] =?UTF-8?q?stat=E5=A4=B1=E6=95=88=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server.c b/server.c index 63fe8f4..97dd1fb 100644 --- a/server.c +++ b/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;