aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http_server.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-03-19 10:48:51 +0000
committerChristian Grothoff <christian@grothoff.org>2012-03-19 10:48:51 +0000
commitb3e1d0806fb274c62a5acf19c56369b71f992312 (patch)
tree657a7cd7a327aad0e7598b3d28cecc0d5cd95cd4 /src/transport/plugin_transport_http_server.c
parent0385dc1043912d3ddc5d57f6b7346054a30f64ef (diff)
downloadgnunet-b3e1d0806fb274c62a5acf19c56369b71f992312.tar.gz
gnunet-b3e1d0806fb274c62a5acf19c56369b71f992312.zip
-LRN: calculate file size for single files when needed and use GNUNET_DISK_file_size instead of STAT
Diffstat (limited to 'src/transport/plugin_transport_http_server.c')
-rw-r--r--src/transport/plugin_transport_http_server.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index 8ec5a5e43..68b6a2a4f 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -95,12 +95,13 @@ static char *
95server_load_file (const char *file) 95server_load_file (const char *file)
96{ 96{
97 struct GNUNET_DISK_FileHandle *gn_file; 97 struct GNUNET_DISK_FileHandle *gn_file;
98 struct stat fstat; 98 uint64_t fsize;
99 char *text = NULL; 99 char *text = NULL;
100 100
101 if (0 != STAT (file, &fstat)) 101 if (GNUNET_OK != GNUNET_DISK_file_size (file,
102 &fsize, GNUNET_NO, GNUNET_YES))
102 return NULL; 103 return NULL;
103 text = GNUNET_malloc (fstat.st_size + 1); 104 text = GNUNET_malloc (fsize + 1);
104 gn_file = 105 gn_file =
105 GNUNET_DISK_file_open (file, GNUNET_DISK_OPEN_READ, 106 GNUNET_DISK_file_open (file, GNUNET_DISK_OPEN_READ,
106 GNUNET_DISK_PERM_USER_READ); 107 GNUNET_DISK_PERM_USER_READ);
@@ -109,13 +110,13 @@ server_load_file (const char *file)
109 GNUNET_free (text); 110 GNUNET_free (text);
110 return NULL; 111 return NULL;
111 } 112 }
112 if (GNUNET_SYSERR == GNUNET_DISK_file_read (gn_file, text, fstat.st_size)) 113 if (GNUNET_SYSERR == GNUNET_DISK_file_read (gn_file, text, fsize))
113 { 114 {
114 GNUNET_free (text); 115 GNUNET_free (text);
115 GNUNET_DISK_file_close (gn_file); 116 GNUNET_DISK_file_close (gn_file);
116 return NULL; 117 return NULL;
117 } 118 }
118 text[fstat.st_size] = '\0'; 119 text[fsize] = '\0';
119 GNUNET_DISK_file_close (gn_file); 120 GNUNET_DISK_file_close (gn_file);
120 return text; 121 return text;
121} 122}