Skip to content

Commit a60eed3

Browse files
committed
Port to StandardPaths
1 parent eeb43c9 commit a60eed3

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/engine/engine.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <fcitx-utils/keysym.h>
2727
#include <fcitx-utils/log.h>
2828
#include <fcitx-utils/macros.h>
29-
#include <fcitx-utils/standardpath.h>
29+
#include <fcitx-utils/standardpaths.h>
3030
#include <fcitx-utils/stringutils.h>
3131
#include <fcitx-utils/textformatflags.h>
3232
#include <fcitx-utils/utf8.h>
@@ -357,9 +357,9 @@ JyutpingEngine::JyutpingEngine(Instance *instance)
357357
libime::DefaultLanguageModelResolver::instance()
358358
.languageModelFileForLanguage("zh_HK")));
359359

360-
const auto &standardPath = StandardPath::global();
361-
auto systemDictFile = standardPath.open(StandardPath::Type::Data,
362-
"libime/jyutping.dict", O_RDONLY);
360+
const auto &standardPath = StandardPaths::global();
361+
auto systemDictFile =
362+
standardPath.open(StandardPathsType::Data, "libime/jyutping.dict");
363363
if (systemDictFile.isValid()) {
364364
IFDStreamBuf buffer(systemDictFile.fd());
365365
std::istream in(&buffer);
@@ -373,8 +373,9 @@ JyutpingEngine::JyutpingEngine(Instance *instance)
373373
prediction_.setUserLanguageModel(ime_->model());
374374

375375
do {
376-
auto file = standardPath.openUser(StandardPath::Type::PkgData,
377-
"jyutping/user.dict", O_RDONLY);
376+
auto file =
377+
standardPath.open(StandardPathsType::PkgData, "jyutping/user.dict",
378+
StandardPathsMode::User);
378379

379380
if (file.fd() < 0) {
380381
break;
@@ -390,8 +391,9 @@ JyutpingEngine::JyutpingEngine(Instance *instance)
390391
}
391392
} while (0);
392393
do {
393-
auto file = standardPath.openUser(StandardPath::Type::PkgData,
394-
"jyutping/user.history", O_RDONLY);
394+
auto file =
395+
standardPath.open(StandardPathsType::PkgData,
396+
"jyutping/user.history", StandardPathsMode::User);
395397

396398
try {
397399
IFDStreamBuf buffer(file.fd());
@@ -729,9 +731,9 @@ void JyutpingEngine::doReset(InputContext *inputContext) {
729731

730732
void JyutpingEngine::save() {
731733
safeSaveAsIni(config_, "conf/jyutping.conf");
732-
const auto &standardPath = StandardPath::global();
734+
const auto &standardPath = StandardPaths::global();
733735
standardPath.safeSave(
734-
StandardPath::Type::PkgData, "jyutping/user.dict", [this](int fd) {
736+
StandardPathsType::PkgData, "jyutping/user.dict", [this](int fd) {
735737
OFDStreamBuf buffer(fd);
736738
std::ostream out(&buffer);
737739
try {
@@ -743,7 +745,7 @@ void JyutpingEngine::save() {
743745
return false;
744746
}
745747
});
746-
standardPath.safeSave(StandardPath::Type::PkgData, "jyutping/user.history",
748+
standardPath.safeSave(StandardPathsType::PkgData, "jyutping/user.history",
747749
[this](int fd) {
748750
OFDStreamBuf buffer(fd);
749751
std::ostream out(&buffer);

0 commit comments

Comments
 (0)