From: <arn...@us...> - 2006-10-07 21:51:35
|
Revision: 665 http://svn.sourceforge.net/dcplusplus/?rev=665&view=rev Author: arnetheduck Date: 2006-10-07 14:51:27 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Some more cleanup Modified Paths: -------------- dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/ShareManager.h dcplusplus/trunk/client/UploadManager.cpp Modified: dcplusplus/trunk/client/ShareManager.cpp =================================================================== --- dcplusplus/trunk/client/ShareManager.cpp 2006-10-07 15:02:06 UTC (rev 664) +++ dcplusplus/trunk/client/ShareManager.cpp 2006-10-07 21:51:27 UTC (rev 665) @@ -82,7 +82,7 @@ } } -string ShareManager::translateTTH(const TTHValue& tth) throw(ShareException) { +string ShareManager::toVirtual(const TTHValue& tth) throw(ShareException) { HashFileIter i = tthIndex.find(tth); if(i != tthIndex.end()) { return i->second->getADCPath(); @@ -91,7 +91,7 @@ } } -string ShareManager::translateFileName(const string& virtualFile) throw(ShareException) { +string ShareManager::toReal(const string& virtualFile) throw(ShareException) { if(virtualFile == "MyList.DcLst") { throw ShareException("NMDC-style lists no longer supported, please upgrade your client"); } else if(virtualFile == Transfer::USER_LIST_NAME_BZ || virtualFile == Transfer::USER_LIST_NAME) { @@ -109,23 +109,23 @@ } } -TTHValue ShareManager::getTTH(const string& virtualName) throw(ShareException) { +TTHValue ShareManager::getTTH(const string& virtualFile) throw(ShareException) { Lock l(cs); - string realName; + string realFile; Directory::File::Iter it; - if(!checkFile(virtualName, realName, it)) + if(!checkFile(virtualFile, realFile, it)) throw ShareException(); return it->getTTH(); } -MemoryInputStream* ShareManager::getTree(const string& aFile) { +MemoryInputStream* ShareManager::getTree(const string& virtualFile) { TigerTree tree; - if(aFile.compare(0, 4, "TTH/") == 0) { - if(!HashManager::getInstance()->getTree(TTHValue(aFile.substr(4)), tree)) + if(virtualFile.compare(0, 4, "TTH/") == 0) { + if(!HashManager::getInstance()->getTree(TTHValue(virtualFile.substr(4)), tree)) return 0; } else { try { - TTHValue tth = getTTH(aFile); + TTHValue tth = getTTH(virtualFile); HashManager::getInstance()->getTree(tth, tree); } catch(const Exception&) { return 0; @@ -191,7 +191,7 @@ bool ShareManager::checkFile(const string& virtualFile, string& realFile, Directory::File::Iter& it) { string file; if(virtualFile.compare(0, 4, "TTH/") == 0) { - file = translateTTH(TTHValue(virtualFile.substr(4))); + file = toVirtual(TTHValue(virtualFile.substr(4))); } else if(virtualFile.empty() || virtualFile[0] != '/') { return false; } else { Modified: dcplusplus/trunk/client/ShareManager.h =================================================================== --- dcplusplus/trunk/client/ShareManager.h 2006-10-07 15:02:06 UTC (rev 664) +++ dcplusplus/trunk/client/ShareManager.h 2006-10-07 21:51:27 UTC (rev 665) @@ -57,9 +57,9 @@ void addDirectory(const string& aDirectory, const string & aName) throw(ShareException); void removeDirectory(const string& aName, bool duringRefresh = false); void renameDirectory(const string& oName, const string& nName) throw(ShareException); - string translateTTH(const TTHValue& tth) throw(ShareException); - string translateFileName(const string& aFile) throw(ShareException); - TTHValue getTTH(const string& aFile) throw(ShareException); + string toVirtual(const TTHValue& tth) throw(ShareException); + string toReal(const string& virtualFile) throw(ShareException); + TTHValue getTTH(const string& virtualFile) throw(ShareException); void refresh(bool dirs = false, bool aUpdate = true, bool block = false) throw(ThreadException, ShareException); void setDirty() { xmlDirty = true; } @@ -70,7 +70,7 @@ StringPairList getDirectories() const { Lock l(cs); return virtualMap; } MemoryInputStream* generatePartialList(const string& dir, bool recurse); - MemoryInputStream* getTree(const string& aFile); + MemoryInputStream* getTree(const string& virtualFile); AdcCommand getFileInfo(const string& aFile) throw(ShareException); Modified: dcplusplus/trunk/client/UploadManager.cpp =================================================================== --- dcplusplus/trunk/client/UploadManager.cpp 2006-10-07 15:02:06 UTC (rev 664) +++ dcplusplus/trunk/client/UploadManager.cpp 2006-10-07 21:51:27 UTC (rev 665) @@ -88,7 +88,7 @@ string sourceFile; try { if(aType == Transfer::TYPE_FILE) { - sourceFile = ShareManager::getInstance()->translateFileName(aFile); + sourceFile = ShareManager::getInstance()->toReal(aFile); if(aFile == Transfer::USER_LIST_NAME) { // Unpack before sending... @@ -123,7 +123,7 @@ } } } else if(aType == Transfer::TYPE_TTHL) { - sourceFile = ShareManager::getInstance()->translateFileName(aFile); + sourceFile = ShareManager::getInstance()->toReal(aFile); MemoryInputStream* mis = ShareManager::getInstance()->getTree(aFile); if(!mis) { aSource.fileNotAvail(); @@ -183,7 +183,7 @@ // Check for tth root identifier string tFile = aFile; if (tFile.compare(0, 4, "TTH/") == 0) - tFile = ShareManager::getInstance()->translateTTH(TTHValue(aFile.substr(4))); + tFile = ShareManager::getInstance()->toVirtual(TTHValue(aFile.substr(4))); addFailedUpload(aSource, tFile + " (" + Util::toString((aStartPos*1000/(size+10))/10.0)+"% of " + Util::formatBytes(size) + " done)"); @@ -474,9 +474,9 @@ if(type == Transfer::TYPE_FILE) { try { - string realFile = ShareManager::getInstance()->translateFileName(ident); + string realFile = ShareManager::getInstance()->toReal(ident); TTHValue tth = ShareManager::getInstance()->getTTH(ident); - string virtualFile = ShareManager::getInstance()->translateTTH(tth); + string virtualFile = ShareManager::getInstance()->toVirtual(tth); int64_t size = File::getSize(realFile); SearchResult* sr = new SearchResult(SearchResult::TYPE_FILE, size, virtualFile, tth); aSource->send(sr->toRES(AdcCommand::TYPE_CLIENT)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |