MCPcopy Create free account
hub / github.com/acl-dev/acl / getFilesize

Method getFilesize

lib_acl_cpp/samples/websocket/upload_server/http_servlet.cpp:203–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203long long http_servlet::getFilesize(acl::websocket& in)
204{
205 if (in.read_frame_head() == false)
206 {
207 printf("read_frame_head error\r\n");
208 return -1;
209 }
210
211 unsigned char opcode = in.get_frame_opcode();
212 switch (opcode)
213 {
214 case acl::FRAME_TEXT:
215 case acl::FRAME_BINARY:
216 break;
217 default:
218 printf("invalid opcode: 0x%0x\r\n", opcode);
219 return -1;
220 }
221
222 char buf[256];
223 int ret = in.read_frame_data(buf, sizeof(buf) - 1);
224 if (ret < 0)
225 {
226 printf("read_frame_data for filesize error\r\n");
227 return -1;
228 }
229 buf[ret] = 0;
230 long long len = atoll(buf);
231 printf("file size: %lld, buf: %s\r\n", len, buf);
232 if (len <= 0)
233 {
234 printf("invalid file length: %lld\r\n", len);
235 return -1;
236 }
237
238 return len;
239}
240
241bool http_servlet::saveFile(acl::websocket& in, const acl::string& filename,
242 long long len)

Callers

nothing calls this directly

Calls 2

read_frame_headMethod · 0.80
read_frame_dataMethod · 0.80

Tested by

no test coverage detected