MCPcopy Create free account
hub / github.com/axmolengine/axmol / writeFile

Method writeFile

core/network/HttpCookie.cpp:260–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260void HttpCookie::writeFile()
261{
262 constexpr auto cookieText =
263 "# Netscape HTTP Cookie File\n"
264 "# http://curl.haxx.se/docs/http-cookies.html\n"
265 "# This file was generated by axmol! Edit at your own risk.\n"
266 "# Test axmol cookie write.\n\n"sv;
267 constexpr auto endLine = "\n"sv;
268
269 auto out = FileUtils::getInstance()->openFileStream(_cookieFileName, IFileStream::Mode::WRITE);
270 out->write(cookieText.data(), cookieText.size());
271
272 std::string line;
273
274 char expires[32] = {0}; // LONGLONG_STRING_SIZE=20
275 for (auto&& cookie : _cookies)
276 {
277 line.clear();
278 line.append(cookie.domain);
279 line.append(1, '\t');
280 cookie.tailmatch ? line.append("TRUE") : line.append("FALSE");
281 line.append(1, '\t');
282 line.append(cookie.path);
283 line.append(1, '\t');
284 cookie.secure ? line.append("TRUE") : line.append("FALSE");
285 line.append(1, '\t');
286 fmt::format_to(std::back_inserter(line), FMT_COMPILE("{}"), cookie.expires);
287 line.append(1, '\t');
288 line.append(cookie.name);
289 line.append(1, '\t');
290 line.append(cookie.value);
291 // line.append(1, '\n');
292
293 out->write(line.c_str(), static_cast<unsigned int>(line.length()));
294 out->write(endLine.data(), static_cast<unsigned int>(endLine.size()));
295 }
296
297 out->close();
298}
299
300void HttpCookie::setCookieFileName(std::string_view filename)
301{

Callers 2

~HttpClientMethod · 0.80
onRequestCompleteMethod · 0.80

Calls 11

getInstanceFunction · 0.85
openFileStreamMethod · 0.80
format_toFunction · 0.50
writeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
appendMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected