Skip to content

Commit

Permalink
Don't use resources for Hunspell helpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jun 24, 2021
1 parent f8c5bc2 commit 0a0097b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions spellcheck/third_party/hunspell_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,25 @@ QString CustomDictionaryPath() {
}

[[nodiscard]] Hunspell LoadUtfInitializer() {
const auto affHelperName = u"utf_helper.aff"_q;
const auto dicHelperName = u"utf_helper.dic"_q;
const auto full = [&](const QString &name) {
return ::Spellchecker::WorkingDirPath() + '/' + name;
};
const auto ensure = [&](const QString &name) {
const auto from = ":/misc/hunspell/" + name;
const auto path = full(name);
if (!QFile::exists(path)) {
QDir().mkpath(::Spellchecker::WorkingDirPath());
Assert(QFile::exists(from));
QFile(from).copy(path);
const auto aff = full(u"utf_helper.aff"_q);
const auto dic = full(u"utf_helper.dic"_q);
if (!QFile::exists(aff)) {
QDir().mkpath(::Spellchecker::WorkingDirPath());
auto f = QFile(aff);
if (f.open(QIODevice::WriteOnly)) {
f.write("SET UTF-8" + kLineBreak);
}
};
ensure(affHelperName);
ensure(dicHelperName);
const auto prepared = PreparePaths(
full(affHelperName),
full(dicHelperName));
}
if (!QFile::exists(dic)) {
auto f = QFile(dic);
if (f.open(QIODevice::WriteOnly)) {
f.write("1" + kLineBreak + "Zzz" + kLineBreak);
}
}
const auto prepared = PreparePaths(aff, dic);
return Hunspell(prepared.aff.constData(), prepared.dic.constData());
}

Expand Down

0 comments on commit 0a0097b

Please sign in to comment.