MCPcopy Create free account
hub / github.com/acl-dev/acl / parse

Method parse

lib_acl_cpp/src/mime/mime.cpp:167–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167bool mime::parse(const char* file_path) {
168 ifstream fp;
169
170 if (!fp.open_read(file_path)) {
171 logger_error("open %s error %s", file_path, last_serror());
172 return false;
173 }
174
175 string buf(1024);
176 const char* ptr;
177 int ret;
178
179 while (1) {
180#if 0
181 if (fp.gets(buf, false) == false)
182 break;
183 ptr = buf.c_str();
184 ret = (int) buf.length();
185#elif 1
186 ret = fp.read(buf.c_str(), buf.capacity() - 1, false);
187 if (ret <= 0) {
188 break;
189 }
190 ptr = buf.c_str();
191#else
192 char ch;
193 if (!fp.read(ch)) {
194 break;
195 }
196 buf = (char) ch;
197 ptr = buf.c_str();
198 ret = (int) buf.length();
199#endif
200
201 if (mime_state_update(m_pMimeState, ptr, ret) == 1) {
202 break;
203 }
204 buf.clear();
205 }
206
207 fp.close();
208 primary_head_finish();
209 if (m_pFilePath) {
210 acl_myfree(m_pFilePath);
211 }
212 m_pFilePath = acl_mystrdup(file_path);
213 return true;
214}
215
216static bool save_as(ifstream& in, ostream& out, long long pos, ssize_t len) {
217 if (pos < 0 || len <= 0) {

Callers 10

runMethod · 0.45
runMethod · 0.45
set_content_typeMethod · 0.45
hvigor-wrapper.jsFile · 0.45
mrFunction · 0.45
SrFunction · 0.45
deserialiseMethod · 0.45
TcFunction · 0.45
constructorMethod · 0.45
olFunction · 0.45

Calls 10

mime_state_updateFunction · 0.85
getsMethod · 0.80
capacityMethod · 0.80
last_serrorFunction · 0.50
open_readMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45
readMethod · 0.45
clearMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected