diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-02-27 09:20:42 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-02-27 09:20:42 +0800 |
commit | d6de54690cca57a65da741ee88a106f2bfddceba (patch) | |
tree | 19e7ac3a6b509e73ce0a13585072ed416217c003 /mbbsd | |
parent | fa35b5963118ffca346300621a5284e076d5bd03 (diff) | |
download | pttbbs-d6de54690cca57a65da741ee88a106f2bfddceba.tar pttbbs-d6de54690cca57a65da741ee88a106f2bfddceba.tar.gz pttbbs-d6de54690cca57a65da741ee88a106f2bfddceba.tar.bz2 pttbbs-d6de54690cca57a65da741ee88a106f2bfddceba.tar.lz pttbbs-d6de54690cca57a65da741ee88a106f2bfddceba.tar.xz pttbbs-d6de54690cca57a65da741ee88a106f2bfddceba.tar.zst pttbbs-d6de54690cca57a65da741ee88a106f2bfddceba.zip |
don't truncate immediately
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1567 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/board.c | 6 | ||||
-rw-r--r-- | mbbsd/fav.c | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/mbbsd/board.c b/mbbsd/board.c index e26b6c74..149d5ccb 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -1174,13 +1174,11 @@ choose_board(int newflag) break; case '2': fav_save(); - setuserfile(fname, FAV4); - sprintf(genbuf, "%s.bak", fname); + setuserfile(fname, FAV4".bak"); Copy(fname, genbuf); break; case '3': - setuserfile(fname, FAV4); - sprintf(genbuf, "%s.bak", fname); + setuserfile(fname, FAV4".bak"); if (!dashf(genbuf)){ vmsg("你沒有備份你的最愛喔"); break; diff --git a/mbbsd/fav.c b/mbbsd/fav.c index e01fb4bc..25618b9c 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -430,7 +430,7 @@ static void write_favrec(int fd, fav_t *fp) int fav_save(void) { int fd; - char buf[128]; + char buf[64], buf2[64]; fav_t *fp = get_fav_root(); #ifdef MEM_CHECK if (fav_memcheck() != MEM_CHECK) @@ -439,12 +439,14 @@ int fav_save(void) if (fp == NULL) return -1; fav_cleanup(); - setuserfile(buf, FAV4); - fd = open(buf, O_CREAT | O_TRUNC | O_WRONLY, 0600); + setuserfile(buf, FAV4".tmp"); + setuserfile(buf2, FAV4); + fd = open(buf, O_CREAT | O_WRONLY, 0600); if (fd < 0) return -1; write_favrec(fd, fp); close(fd); + Rename(buf, buf2); return 0; } |