MCPcopy Create free account
hub / github.com/cocos/cocos-engine / readFile

Method readFile

native/cocos/network/HttpCookie.cpp:32–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30#include "platform/FileUtils.h"
31
32void HttpCookie::readFile() {
33 ccstd::string inString = cc::FileUtils::getInstance()->getStringFromFile(_cookieFileName);
34 if (!inString.empty()) {
35 ccstd::vector<ccstd::string> cookiesVec;
36 cookiesVec.clear();
37
38 std::stringstream stream(inString);
39 ccstd::string item;
40 while (std::getline(stream, item, '\n')) {
41 cookiesVec.push_back(item);
42 }
43
44 if (cookiesVec.empty()) {
45 return;
46 }
47
48 _cookies.clear();
49
50 for (auto &cookie : cookiesVec) {
51 if (cookie.length() == 0) {
52 continue;
53 }
54
55 if (cookie.find("#HttpOnly_") != ccstd::string::npos) {
56 cookie = cookie.substr(10);
57 }
58
59 if (cookie.at(0) == '#') {
60 continue;
61 }
62
63 CookiesInfo co;
64 std::stringstream streamInfo(cookie);
65 ccstd::vector<ccstd::string> elems;
66 ccstd::string elemsItem;
67
68 while (std::getline(streamInfo, elemsItem, '\t')) {
69 elems.push_back(elemsItem);
70 }
71
72 co.domain = elems[0];
73 if (co.domain.at(0) == '.') {
74 co.domain = co.domain.substr(1);
75 }
76 co.tailmatch = (strcmp("TRUE", elems[1].c_str()) != 0);
77 co.path = elems[2];
78 co.secure = (strcmp("TRUE", elems[3].c_str()) != 0);
79 co.expires = elems[4];
80 co.name = elems[5];
81 co.value = elems[6];
82 _cookies.push_back(co);
83 }
84 }
85}
86
87const ccstd::vector<CookiesInfo> *HttpCookie::getCookies() const {
88 return &_cookies;

Callers 15

replaceInFileMethod · 0.80
setOrientationMethod · 0.80
fnParseXmlMethod · 0.80
setOrientationMethod · 0.80
setOrientationMethod · 0.80
fnParseXmlMethod · 0.80
createMethod · 0.80
runTestFunction · 0.80
lod-group.test.tsFile · 0.80
downloadArrayBufferFunction · 0.80
downloadTextFunction · 0.80
downloadJsonFunction · 0.80

Calls 7

getStringFromFileMethod · 0.80
substrMethod · 0.80
clearMethod · 0.65
push_backMethod · 0.65
findMethod · 0.65
emptyMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected