From 45c749c4f1b330c64e4d7e4b0090141d04ad5093 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 17 Nov 2009 20:05:18 +0000 Subject: [PATCH] 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 --- libretroshare/src/dbase/findex.cc | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/libretroshare/src/dbase/findex.cc b/libretroshare/src/dbase/findex.cc index 6f526b3c7..4d5235311 100644 --- a/libretroshare/src/dbase/findex.cc +++ b/libretroshare/src/dbase/findex.cc @@ -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; }