void lggHunSpell_Wrapper::addWordToCustomDictionary(std::string wordToAdd) { if(!myHunspell)return; myHunspell->add(wordToAdd.c_str()); std::string filename(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", "emerald_custom.dic")); std::vector<std::string> lines; if(gDirUtilp->fileExists(filename)) { //get words already there.. llifstream importer(filename); std::string line; if(getline( importer, line ))//ignored the size { while( getline( importer, line ) ) lines.push_back(line); } importer.close(); } llofstream export_file; export_file.open(filename); std::string sizePart(llformat("%i",(int)(lines.size()+1))+"\n"); export_file.write(sizePart.c_str(),sizePart.length()); for(int i=0;i<(int)lines.size();i++) export_file.write(std::string(lines[i]+"\n").c_str(),lines[i].length()+1); //LLStringUtil::toLower(wordToAdd); wordToAdd=wordToAdd+std::string("\n"); export_file.write(wordToAdd.c_str(),wordToAdd.length()); //export_file << std::hex << 10 ; export_file.close(); }
void lggHunSpell_Wrapper::createCustomDic() { std::string filename(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", "custom.dic")); if (!gDirUtilp->fileExists(filename)) { llofstream export_file; export_file.open(filename); std::string sizePart("1\nLordGregGreg\n"); export_file.write(sizePart.c_str(),sizePart.length()); export_file.close(); } }