diff options
author | Peng Wu <alexepico@gmail.com> | 2012-03-12 13:55:53 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-03-12 13:55:53 +0800 |
commit | ad345300d1bf8e9691ad24692a62421d04226948 (patch) | |
tree | 6471536129b148a8b09524738f389bd9e0898921 /src | |
parent | c71bfd49ed3042c2844b81e76fbf3cde7b0da10e (diff) | |
download | libpinyin-ad345300d1bf8e9691ad24692a62421d04226948.tar.gz libpinyin-ad345300d1bf8e9691ad24692a62421d04226948.tar.xz libpinyin-ad345300d1bf8e9691ad24692a62421d04226948.zip |
improves pinyin_save
Diffstat (limited to 'src')
-rw-r--r-- | src/pinyin.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp index 5f6ebc6..b8726f6 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -215,8 +215,12 @@ bool pinyin_save(pinyin_context_t * context){ g_free(filename); delete newlog; + gchar * tmpfilename = g_build_filename(context->m_user_dir, + "user.db.tmp", NULL); filename = g_build_filename(context->m_user_dir, "user.db", NULL); - context->m_user_bigram->save_db(filename); + context->m_user_bigram->save_db(tmpfilename); + rename(tmpfilename, filename); + g_free(tmpfilename); g_free(filename); mark_version(context->m_user_dir); |