summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-03-12 15:34:00 +0800
committerPeng Wu <alexepico@gmail.com>2012-03-12 15:34:36 +0800
commit12dcae34add906d84b904717c9c6bbe23358a985 (patch)
tree567de5789f92c45ac5fcdff4527b5aff811a29d5
parentee803d04c74654b3fec3f4857ad31648da83a83b (diff)
downloadlibpinyin-12dcae34add906d84b904717c9c6bbe23358a985.zip
libpinyin-12dcae34add906d84b904717c9c6bbe23358a985.tar.gz
libpinyin-12dcae34add906d84b904717c9c6bbe23358a985.tar.xz
fixes pinyin_save
-rw-r--r--src/pinyin.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index 5257c49..b6f91a1 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -21,6 +21,8 @@
#include "pinyin.h"
+#include <stdio.h>
+#include <unistd.h>
#include <glib/gstdio.h>
#include "pinyin_internal.h"
@@ -226,6 +228,7 @@ bool pinyin_save(pinyin_context_t * context){
tmpfilename = g_build_filename(context->m_user_dir,
"user.db.tmp", NULL);
+ unlink(tmpfilename);
filename = g_build_filename(context->m_user_dir, "user.db", NULL);
context->m_user_bigram->save_db(tmpfilename);
rename(tmpfilename, filename);