MCPcopy Create free account
hub / github.com/ddnet/ddnet / ReadIntegrityFile

Function ReadIntegrityFile

src/android/android_main.cpp:120–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118};
119
120static std::vector<CIntegrityFileLine> ReadIntegrityFile(const char *pFilename)
121{
122 CLineReader LineReader;
123 if(!LineReader.OpenFile(io_open(pFilename, IOFLAG_READ)))
124 {
125 return {};
126 }
127
128 std::vector<CIntegrityFileLine> vLines;
129 while(const char *pReadLine = LineReader.Get())
130 {
131 const char *pSpaceInLine = str_rchr(pReadLine, ' ');
132 CIntegrityFileLine Line;
133 char aSha256[SHA256_MAXSTRSIZE];
134 if(pSpaceInLine == nullptr)
135 {
136 if(!vLines.empty())
137 {
138 // Only the first line is allowed to not contain a filename
139 log_error("android", "Failed to parse line %" PRIzu " of '%s': line does not contain space", vLines.size() + 1, pFilename);
140 return {};
141 }
142 Line.m_aFilename[0] = '\0';
143 str_copy(aSha256, pReadLine);
144 }
145 else
146 {
147 str_truncate(Line.m_aFilename, sizeof(Line.m_aFilename), pReadLine, pSpaceInLine - pReadLine);
148 str_copy(aSha256, pSpaceInLine + 1);
149 }
150 if(sha256_from_str(&Line.m_Sha256, aSha256) != 0)
151 {
152 log_error("android", "Failed to parse line %" PRIzu " of '%s': invalid SHA256 string", vLines.size() + 1, pFilename);
153 return {};
154 }
155 vLines.emplace_back(std::move(Line));
156 }
157
158 return vLines;
159}
160
161const char *InitAndroid()
162{

Callers 1

InitAndroidFunction · 0.85

Calls 7

io_openFunction · 0.85
str_rchrFunction · 0.85
str_truncateFunction · 0.85
sha256_from_strFunction · 0.85
str_copyFunction · 0.50
OpenFileMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected