mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
don't store name, location name and date in new SSL certs. Location name is now stored in an extra file. Backwards compatible to old locations and old peers.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8072 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4fa3d00f26
commit
7e03f3944b
8 changed files with 75 additions and 13 deletions
|
@ -41,6 +41,7 @@
|
|||
#include <dirent.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
@ -722,6 +723,31 @@ Sha1CheckSum RsDirUtil::sha1sum(const unsigned char *data, uint32_t size)
|
|||
return Sha1CheckSum(sha_buf) ;
|
||||
}
|
||||
|
||||
bool RsDirUtil::saveStringToFile(const std::string &file, const std::string &str)
|
||||
{
|
||||
std::ofstream out(file.c_str(), std::ios_base::out | std::ios_base::binary);
|
||||
if(!out.is_open())
|
||||
{
|
||||
std::cerr << "RsDirUtil::saveStringToFile() ERROR: can't open file " << file << std::endl;
|
||||
return false;
|
||||
}
|
||||
out << str;
|
||||
}
|
||||
|
||||
bool RsDirUtil::loadStringFromFile(const std::string &file, std::string &str)
|
||||
{
|
||||
std::ifstream in(file.c_str(), std::ios_base::in | std::ios_base::binary);
|
||||
if(!in.is_open())
|
||||
{
|
||||
std::cerr << "RsDirUtil::loadStringFromFile() ERROR: can't open file " << file << std::endl;
|
||||
return false;
|
||||
}
|
||||
std::stringstream buffer;
|
||||
buffer << in.rdbuf();
|
||||
str = buffer.str();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RsDirUtil::renameFile(const std::string& from, const std::string& to)
|
||||
{
|
||||
int loops = 0;
|
||||
|
|
|
@ -97,6 +97,9 @@ bool getFileHash(const std::string& filepath,RsFileHash &hash, uint64_t &size,
|
|||
|
||||
Sha1CheckSum sha1sum(const uint8_t *data,uint32_t size) ;
|
||||
|
||||
bool saveStringToFile(const std::string& file, const std::string& str);
|
||||
bool loadStringFromFile(const std::string& file, std::string& str);
|
||||
|
||||
// Creates a lock file with given path, and returns the lock handle
|
||||
// returns:
|
||||
// 0: Success
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue