mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added RequestDirDetails(path,...) for file sync plugin.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4807 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
35c7605704
commit
bd9cd22387
@ -1288,12 +1288,11 @@ std::string FileIndexMonitor::locked_findRealRoot(std::string rootdir) const
|
||||
return realroot;
|
||||
}
|
||||
|
||||
int FileIndexMonitor::RequestDirDetails(std::string uid, std::string /*path*/, DirDetails &/*details*/) const
|
||||
int FileIndexMonitor::RequestDirDetails(const std::string& path, DirDetails& details) const
|
||||
{
|
||||
/* lock it up */
|
||||
RsStackMutex mutex(fiMutex) ;
|
||||
|
||||
return (uid == fi.root->id) ;
|
||||
return fi.extractData(path,details) ;
|
||||
}
|
||||
|
||||
uint32_t FileIndexMonitor::getType(void *ref) const
|
||||
|
@ -136,7 +136,7 @@ class FileIndexMonitor: public CacheSource, public RsThread
|
||||
// Interface for browsing dir hirarchy
|
||||
int RequestDirDetails(void*, DirDetails&, uint32_t) const ;
|
||||
uint32_t getType(void*) const ;
|
||||
int RequestDirDetails(std::string uid, std::string path, DirDetails &details) const ;
|
||||
int RequestDirDetails(const std::string& path, DirDetails &details) const ;
|
||||
|
||||
// set/update shared directories
|
||||
virtual void setSharedDirectories(const std::list<SharedDirInfo>& dirs);
|
||||
|
@ -1227,6 +1227,59 @@ uint32_t FileIndex::getType(void *ref)
|
||||
|
||||
return static_cast<FileEntry*>(ref)->type() ;
|
||||
}
|
||||
|
||||
bool FileIndex::extractData(const std::string& fpath,DirDetails& details) const
|
||||
{
|
||||
void *ref = findRef(fpath) ;
|
||||
|
||||
if(ref == NULL)
|
||||
return false ;
|
||||
|
||||
return extractData(ref,details) ;
|
||||
}
|
||||
|
||||
void *FileIndex::findRef(const std::string& fpath) const
|
||||
{
|
||||
DirEntry *parent = root->findDirectory(fpath);
|
||||
|
||||
std::cerr << "findRef() Called on " << fpath << std::endl;
|
||||
|
||||
if (!parent)
|
||||
{
|
||||
//#ifdef FI_DEBUG
|
||||
std::cerr << "FileIndex::updateFileEntry() NULL parent";
|
||||
std::cerr << std::endl;
|
||||
//#endif
|
||||
return false;
|
||||
}
|
||||
std::cerr << "Found parent directory: " << std::endl;
|
||||
std::cerr << " parent.name = " << parent->name << std::endl;
|
||||
std::cerr << " parent.path = " << parent->path << std::endl;
|
||||
|
||||
if(parent->path == fpath) // directory!
|
||||
{
|
||||
std::cerr << " fpath is a directory. Returning parent!" << std::endl;
|
||||
return parent ;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << " fpath is a file. Looking into parent directory..." << std::endl;
|
||||
/* search in current dir */
|
||||
for(std::map<std::string, FileEntry *>::iterator fit = parent->files.begin(); fit != parent->files.end(); ++fit)
|
||||
{
|
||||
std::cerr << " trying " << parent->path + "/" + fit->second->name << std::endl;
|
||||
if(parent->path + "/" + fit->second->name == fpath)
|
||||
{
|
||||
std::cerr << " found !" << std::endl;
|
||||
return fit->second ;
|
||||
}
|
||||
}
|
||||
|
||||
std::cerr << " (EE) not found !" << std::endl;
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
bool FileIndex::extractData(void *ref,DirDetails& details)
|
||||
{
|
||||
if(!isValid(ref))
|
||||
|
@ -255,6 +255,9 @@ class FileIndex
|
||||
//
|
||||
static bool extractData(void *ref,DirDetails& details) ;
|
||||
static uint32_t getType(void *ref) ;
|
||||
|
||||
void *findRef(const std::string& path) const ;
|
||||
bool extractData(const std::string& path,DirDetails& details) const ;
|
||||
};
|
||||
|
||||
|
||||
|
@ -161,8 +161,21 @@ int FileIndexStore::loadCache(const CacheData &data)
|
||||
|
||||
|
||||
/* Search Interface - For Directory Access */
|
||||
int FileIndexStore::RequestDirDetails(std::string uid, std::string /*path*/, DirDetails& details) const
|
||||
int FileIndexStore::RequestDirDetails(const std::string& uid, const std::string& path, DirDetails& details) const
|
||||
{
|
||||
lockData();
|
||||
|
||||
std::map<RsPeerId, FileIndex *>::const_iterator it = indices.find(uid);
|
||||
bool found = true;
|
||||
|
||||
if (it != indices.end())
|
||||
found = it->second->extractData(path,details) ;
|
||||
|
||||
unlockData();
|
||||
|
||||
return found ;
|
||||
|
||||
#ifdef OLD_STUFF_TO_REMOVE
|
||||
/* lock it up */
|
||||
lockData();
|
||||
|
||||
@ -184,6 +197,7 @@ int FileIndexStore::RequestDirDetails(std::string uid, std::string /*path*/, Dir
|
||||
|
||||
unlockData();
|
||||
return found;
|
||||
#endif
|
||||
}
|
||||
|
||||
int FileIndexStore::RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) const
|
||||
|
@ -82,7 +82,7 @@ virtual int loadCache(const CacheData &data); /* actual load, once data availa
|
||||
|
||||
|
||||
/* Search Interface - For Directory Access */
|
||||
int RequestDirDetails(std::string uid, std::string path, DirDetails &details) const;
|
||||
int RequestDirDetails(const std::string& uid, const std::string& path, DirDetails &details) const;
|
||||
int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) const;
|
||||
uint32_t getType(void *ref) const ;
|
||||
|
||||
|
@ -484,7 +484,7 @@ bool ftServer::ExtraFileMove(std::string fname, std::string hash, uint64_t size,
|
||||
/******************** Directory Listing ************************/
|
||||
/***************************************************************/
|
||||
|
||||
int ftServer::RequestDirDetails(std::string uid, std::string path, DirDetails &details)
|
||||
int ftServer::RequestDirDetails(const std::string& uid, const std::string& path, DirDetails &details)
|
||||
{
|
||||
#ifdef SERVER_DEBUG
|
||||
std::cerr << "ftServer::RequestDirDetails(uid:" << uid;
|
||||
@ -497,7 +497,10 @@ int ftServer::RequestDirDetails(std::string uid, std::string path, DirDetails &d
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
#endif
|
||||
return mFiStore->RequestDirDetails(uid, path, details);
|
||||
if(uid == mLinkMgr->getOwnId())
|
||||
return mFiMon->RequestDirDetails(path, details);
|
||||
else
|
||||
return mFiStore->RequestDirDetails(uid, path, details);
|
||||
}
|
||||
|
||||
int ftServer::RequestDirDetails(void *ref, DirDetails &details, uint32_t flags)
|
||||
|
@ -175,7 +175,7 @@ virtual bool ExtraFileMove(std::string fname, std::string hash, uint64_t size,
|
||||
/***
|
||||
* Directory Listing / Search Interface
|
||||
***/
|
||||
virtual int RequestDirDetails(std::string uid, std::string path, DirDetails &details);
|
||||
virtual int RequestDirDetails(const std::string& uid, const std::string& path, DirDetails &details);
|
||||
virtual int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags);
|
||||
virtual uint32_t getType(void *ref,uint32_t flags) ;
|
||||
|
||||
|
@ -162,7 +162,7 @@ class RsFiles
|
||||
/***
|
||||
* Directory Listing / Search Interface
|
||||
*/
|
||||
virtual int RequestDirDetails(std::string uid, std::string path, DirDetails &details) = 0;
|
||||
virtual int RequestDirDetails(const std::string& uid, const std::string& path, DirDetails &details) = 0;
|
||||
|
||||
virtual int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) = 0;
|
||||
virtual uint32_t getType(void *ref,uint32_t flags) = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user