mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-17 05:22:31 -04:00
added code to avoid corruption of bdboot.txt: first write to tmp file then move the file. Refers on Windows utf16ToUtf8 from libretroshare. This forward reference can be improved.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5434 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
21e97a47df
commit
c3db4dacf7
4 changed files with 68 additions and 1 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "bitdht/bdstore.h"
|
||||
#include "util/bdnet.h"
|
||||
#include "util/bdfile.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
@ -213,8 +214,9 @@ void bdStore::writeStore(std::string file)
|
|||
return;
|
||||
}
|
||||
|
||||
std::string filetmp = file + ".tmp" ;
|
||||
|
||||
FILE *fd = fopen(file.c_str(), "w");
|
||||
FILE *fd = fopen(filetmp.c_str(), "w");
|
||||
|
||||
if (!fd)
|
||||
{
|
||||
|
@ -234,6 +236,11 @@ void bdStore::writeStore(std::string file)
|
|||
|
||||
}
|
||||
fclose(fd);
|
||||
|
||||
if(!bdFile::renameFile(filetmp,file))
|
||||
std::cerr << "Could not rename file !!" << std::endl;
|
||||
else
|
||||
std::cerr << "Successfully renamed file " << filetmp << " to " << file << std::endl;
|
||||
}
|
||||
|
||||
void bdStore::writeStore()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue