MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / DownloadFile

Function DownloadFile

engine/Poseidon/Network/XML/Xml.cpp:721–759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

719 FD_SET(sock, &mask);
720 if (!select(sock + 1, &mask, nullptr, nullptr, &ti))
721 {
722 LOG_DEBUG(Core, "HTTP: Truncating data to {} bytes", ptr - beginPtr);
723 endPtr = ptr;
724 break;
725 }
726 msgLen = recv(sock, ptr, left, 0); // receive rest of the data
727 if (msgLen < 0)
728 {
729 LOG_DEBUG(Core, "HTTP: Error receiving data ({})!", errno);
730 if (--errCounter < 0)
731 {
732 endPtr = ptr;
733 break;
734 }
735 }
736 else
737 {
738 ptr += msgLen;
739 left -= msgLen;
740 }
741 } while (left);
742
743 ::close(sock);
744 LOG_DEBUG(Core, "HTTP: OK loading URL '{}' ({} bytes)", url, endPtr - beginPtr);
745#ifdef NET_LOG_HTTP
746#ifdef NET_LOG_BRIEF
747 NetLog("HTTP('%s',%u)", url, endPtr - beginPtr);
748#else
749 NetLog("HTTP: OK loading URL '%s' (%u bytes)", url, endPtr - beginPtr);
750#endif
751#endif
752
753 ok = true;
754 ptr = beginPtr;
755}
756
757void QIHTTPStream::close()
758{
759 if (beginPtr)
760 free(beginPtr);
761 ptr = beginPtr = endPtr = nullptr;
762 ok = false;

Callers 3

DownloadToMemThreadFunction · 0.85
DownloadToFileThreadFunction · 0.85

Calls 7

openMethod · 0.45
failMethod · 0.45
getMethod · 0.45
eofMethod · 0.45
PutMethod · 0.45
FlushMethod · 0.45
getDataMethod · 0.45

Tested by

no test coverage detected