Commit 80423ed6 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

More effective way to read the file when parsing one

parent 4cbcda6d
......@@ -117,19 +117,18 @@ shared_ptr<BelCardList> BelCardParser::parse(const string &input) {
shared_ptr<BelCardList> BelCardParser::parseFile(const string &filename) {
ifstream istr;, ifstream::in | ifstream::binary);
ifstream istr(filename.c_str(), ifstream::in | ifstream::binary);
if (!istr.is_open() || {
if (!istr || !istr.is_open() || {
bctbx_error("[belcard] Couldn't open file %s", filename.c_str());
return NULL;
stringstream vcardStream;
// The following line has been replaced by the copy() because this was crashing with the gnustl library on Android.
//vcardStream << istr.rdbuf();
copy(istreambuf_iterator<char>(istr), istreambuf_iterator<char>(), ostreambuf_iterator<char>(vcardStream));
string vcard = vcardStream.str();
string vcard;
istr.seekg(0, ios::end);
istr.seekg(0, ios::beg);[0], vcard.size());
string vcards = belcard_unfold(vcard);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment