فهرست منبع

Merge pull request #225 from danielrempel/master

Call mg_stat in mg_fopen, so all members of mg_file are set after calling mg_fopen.
Still, there is a stamp coupling that should be removed later: mg_fopen and mg_stat should work on different data structures.
bel2125 9 سال پیش
والد
کامیت
f39e377ffc
1فایلهای تغییر یافته به همراه4 افزوده شده و 0 حذف شده
  1. 4 0
      src/civetweb.c

+ 4 - 0
src/civetweb.c

@@ -1481,6 +1481,10 @@ mg_fopen(struct mg_connection *conn,
 	 * the same structure (bad cohesion). */
 	/* memset(filep, 0, sizeof(*filep)); <-- remove this (issue #244) */
 
+	struct stat st;
+	if (stat(path, &st) == 0)
+		filep->size = st.st_size;
+
 	if (!is_file_in_memory(conn, path, filep)) {
 #ifdef _WIN32
 		wchar_t wbuf[PATH_MAX], wmode[20];