Fixed the file-rehashing problem, by replacing all "," by "\," in file names in fc-own* files. When re-loading, all "\," are turned back into "," and not used as separators. Warning: although this is backward compatible with the old file format, peers having ","s in their files cannot exchange file lists with older RS versions.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.4.x@1835 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-11-17 20:05:18 +00:00
parent 47076a3615
commit 45c749c4f1

View File

@ -776,7 +776,20 @@ int FileIndex::loadIndex(std::string filename, std::string expectedHash, uint64_
/* parse line */
while(1)
{
getline(ss, word, ',');
word.clear() ;
while(1)
{
std::string tmp ;
getline(ss,tmp,',') ;
word += tmp ;
if(word[word.length()-1] == '\\') // when we find the string "\," we turn it into "," and continue
word[word.length()-1] = ',' ;
else
break ;
}
if (ss.eof())
goto error;
tokens.push_back(word);
@ -906,18 +919,22 @@ int FileIndex::saveIndex(std::string filename, std::string &fileHash, uint64_t &
return 1;
}
// Turns all "," in the string into "\,"
//
std::string FixName(std::string in)
{
/* replace any , with _ */
std::string out ;
int j=0 ;
for(unsigned int i = 0; i < in.length(); i++)
{
if (in[i] == ',')
{
in[i] = '_';
}
out += "\\" ;
out.push_back(in[i]) ;
}
return in;
return out;
}