mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-06 13:24:16 -04:00
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:
parent
40b1f6f053
commit
569d463f02
6 changed files with 308 additions and 312 deletions
|
@ -1625,7 +1625,7 @@ bool ftController::FileDetails(const std::string &hash, FileInfo &info)
|
|||
info.fname = it->second->mName;
|
||||
info.flags = it->second->mFlags;
|
||||
info.priority = SPEED_NORMAL ;
|
||||
info.path = RsDirUtil::removeTopDir(it->second->mDestination); /* remove fname */
|
||||
RsDirUtil::removeTopDir(it->second->mDestination, info.path); /* remove fname */
|
||||
info.queue_position = it->second->mQueuePosition ;
|
||||
|
||||
/* get list of sources from transferModule */
|
||||
|
@ -1982,7 +1982,7 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
rft->file.name = fit->second->mName;
|
||||
rft->file.hash = fit->second->mHash;
|
||||
rft->file.filesize = fit->second->mSize;
|
||||
rft->file.path = RsDirUtil::removeTopDir(fit->second->mDestination); /* remove fname */
|
||||
RsDirUtil::removeTopDir(fit->second->mDestination, rft->file.path); /* remove fname */
|
||||
rft->flags = fit->second->mFlags;
|
||||
rft->state = fit->second->mState;
|
||||
fit->second->mTransfer->getFileSources(rft->allPeerIds.ids);
|
||||
|
@ -2031,7 +2031,7 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
rft->file.name = pit->mName;
|
||||
rft->file.hash = pit->mHash;
|
||||
rft->file.filesize = pit->mSize;
|
||||
rft->file.path = RsDirUtil::removeTopDir(pit->mDest); /* remove fname */
|
||||
RsDirUtil::removeTopDir(pit->mDest, rft->file.path); /* remove fname */
|
||||
rft->flags = pit->mFlags;
|
||||
rft->allPeerIds.ids = pit->mSrcIds;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue