Optimized the fill of the up- and downloads in TransfersDialog.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5191 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-06-01 20:51:14 +00:00
parent 40b1f6f053
commit 569d463f02
6 changed files with 308 additions and 312 deletions

View file

@ -157,26 +157,25 @@ bool RsDirUtil::crc32File(FILE *fd, uint64_t file_size,uint32_t chunk_size, CRC3
return true ;
}
std::string RsDirUtil::removeTopDir(const std::string& dir)
void RsDirUtil::removeTopDir(const std::string& dir, std::string& path)
{
std::string rest;
path.clear();
/* remove the subdir: [/][dir1.../]<top>[/]
*/
int i,j;
int len = dir.length();
for(j = len - 1; (j > 0) && (dir[j] == '/'); j--) ;
for(i = j; (i >= 0) && (dir[i] != '/'); i--) ;
int j = dir.find_last_not_of('/');
int i = dir.rfind('/', j);
/* remove any more slashes */
for(; (i >= 0) && (dir[i] == '/'); i--) ;
for(j = 0; j <= i; j++)
if (i > 0)
{
rest += dir[j];
i = dir.find_last_not_of('/', i);
}
return rest;
if (i > 0)
{
path.assign(dir, 0, i + 1);
}
}
std::string RsDirUtil::getRootDir(const std::string& dir)

View file

@ -41,7 +41,7 @@ namespace RsDirUtil {
std::string getTopDir(const std::string&);
std::string getRootDir(const std::string&);
std::string removeRootDir(const std::string& path);
std::string removeTopDir(const std::string& dir);
void removeTopDir(const std::string& dir, std::string &path);
std::string removeRootDirs(const std::string& path, const std::string& root);
// Renames file from to file to. Files should be on the same file system.