MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / ServeFile

Function ServeFile

Source/SysOSX/Debug/WebDebug.cpp:222–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222static void ServeFile(WebDebugConnection * connection, const char * filename)
223{
224 FILE * fh = fopen(filename, "rb");
225 if (!fh)
226 {
227 Generate404(connection, filename);
228 return;
229 }
230
231 connection->BeginResponse(200, -1, GetContentTypeForFilename(filename));
232
233 static const size_t kBufSize = 1024;
234 size_t len_read;
235 char buf[kBufSize];
236 do
237 {
238 len_read = fread(buf, 1, kBufSize, fh);
239 if (len_read > 0)
240 connection->Write(buf, len_read);
241 }
242 while (len_read == kBufSize);
243
244 connection->EndResponse();
245 fclose(fh);
246}
247
248bool ServeResource(WebDebugConnection * connection, const char * resource_path)
249{

Callers 1

ServeResourceFunction · 0.85

Calls 5

Generate404Function · 0.85
BeginResponseMethod · 0.80
EndResponseMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected