mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 08:29:26 -05:00
moved rsexpr to file_sharing directory
This commit is contained in:
parent
274f924ca0
commit
9f66c0050b
@ -2,6 +2,7 @@
|
||||
|
||||
#include "dir_hierarchy.h"
|
||||
#include "filelist_io.h"
|
||||
//#include "rsexpr.h"
|
||||
|
||||
#define DEBUG_DIRECTORY_STORAGE 1
|
||||
|
||||
@ -570,6 +571,49 @@ bool InternalFileHierarchyStorage::searchHash(const RsFileHash& hash,std::list<D
|
||||
return false;
|
||||
}
|
||||
|
||||
int InternalFileHierarchyStorage::searchBoolExp(Expression * exp, std::list<DirectoryStorage::EntryIndex> &results) const
|
||||
{
|
||||
#ifdef TODO
|
||||
for(std::map<RsFileHash,DirectoryStorage::EntryIndex>::const_iterator it(mFileHashes.begin());it!=mFileHashes.end();++it)
|
||||
{
|
||||
const std::string &str1 = static_cast<FileEntry*>(mNodes[fit->second])->file_name;
|
||||
|
||||
{
|
||||
/*Evaluate the boolean expression and add it to the results if its true*/
|
||||
bool ret = exp->eval(fit->second);
|
||||
if (ret == true){
|
||||
results.push_back(fit->second);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int InternalFileHierarchyStorage::searchTerms(const std::list<std::string>& terms, std::list<DirectoryStorage::EntryIndex> &results) const
|
||||
{
|
||||
// most entries are likely to be files, so we could do a linear search over the entries tab.
|
||||
// instead we go through the table of hashes.
|
||||
|
||||
for(std::map<RsFileHash,DirectoryStorage::EntryIndex>::const_iterator it(mFileHashes.begin());it!=mFileHashes.end();++it)
|
||||
if(mNodes[it->second] != NULL)
|
||||
{
|
||||
const std::string &str1 = static_cast<FileEntry*>(mNodes[it->second])->file_name;
|
||||
|
||||
for(std::list<std::string>::const_iterator iter(terms.begin()); iter != terms.end(); ++iter)
|
||||
{
|
||||
/* always ignore case */
|
||||
const std::string &str2 = (*iter);
|
||||
#ifdef TODO
|
||||
if(str1.end() != std::search( str1.begin(), str1.end(), str2.begin(), str2.end(), CompareCharIC() ))
|
||||
{
|
||||
results.push_back(fit->second);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
bool InternalFileHierarchyStorage::check(std::string& error_string) const // checks consistency of storage.
|
||||
{
|
||||
// recurs go through all entries, check that all
|
||||
|
@ -110,7 +110,12 @@ public:
|
||||
uint32_t getType(DirectoryStorage::EntryIndex indx) const;
|
||||
DirectoryStorage::EntryIndex getSubFileIndex(DirectoryStorage::EntryIndex parent_index,uint32_t file_tab_index);
|
||||
DirectoryStorage::EntryIndex getSubDirIndex(DirectoryStorage::EntryIndex parent_index,uint32_t dir_tab_index);
|
||||
|
||||
// search. SearchHash is logarithmic. The other two are linear.
|
||||
|
||||
bool searchHash(const RsFileHash& hash,std::list<DirectoryStorage::EntryIndex>& results);
|
||||
int searchBoolExp(Expression * exp, std::list<DirectoryStorage::EntryIndex> &results) const ;
|
||||
int searchTerms(const std::list<std::string>& terms, std::list<DirectoryStorage::EntryIndex> &results) const ;
|
||||
|
||||
bool check(std::string& error_string) const ;// checks consistency of storage.
|
||||
|
||||
|
@ -160,62 +160,29 @@ void DirectoryStorage::saveNextTag(unsigned char *data, uint32_t& offset, uint8_
|
||||
|
||||
void DirectoryStorage::load(const std::string& local_file_name)
|
||||
{
|
||||
std::cerr << "DirectoryStorage::load()" << std::endl;
|
||||
|
||||
// first load the header, than all fields.
|
||||
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
mFileHierarchy->load(local_file_name);
|
||||
}
|
||||
void DirectoryStorage::save(const std::string& local_file_name)
|
||||
{
|
||||
std::cerr << "DirectoryStorage::Save()" << std::endl;
|
||||
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
mFileHierarchy->save(local_file_name);
|
||||
|
||||
// first write the header, than all fields.
|
||||
}
|
||||
void DirectoryStorage::print()
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
std::cerr << "LocalDirectoryStorage:" << std::endl;
|
||||
mFileHierarchy->print();
|
||||
}
|
||||
|
||||
bool LocalDirectoryStorage::getFileInfo(DirectoryStorage::EntryIndex i,FileInfo& info)
|
||||
int DirectoryStorage::searchTerms(const std::list<std::string>& terms, std::list<EntryIndex> &results) const
|
||||
{
|
||||
DirDetails d;
|
||||
extractData(i,d) ;
|
||||
|
||||
info.storage_permission_flags = d.flags; // Combination of the four RS_DIR_FLAGS_*. Updated when the file is a local stored file.
|
||||
info.parent_groups = d.parent_groups;
|
||||
info.transfer_info_flags = TransferRequestFlags(); // various flags from RS_FILE_HINTS_*
|
||||
info.path = d.path + "/" + d.name;
|
||||
info.fname = d.name;
|
||||
info.hash = d.hash;
|
||||
info.size = d.count;
|
||||
|
||||
// all this stuff below is not useful in this case.
|
||||
|
||||
info.mId = 0; /* (GUI) Model Id -> unique number */
|
||||
info.ext.clear();
|
||||
info.avail = 0; /* how much we have */
|
||||
info.rank = 0;
|
||||
info.age = 0;
|
||||
info.queue_position =0;
|
||||
info.searchId = 0; /* 0 if none */
|
||||
|
||||
/* Transfer Stuff */
|
||||
info.transfered = 0;
|
||||
info.tfRate = 0; /* in kbytes */
|
||||
info.downloadStatus = FT_STATE_COMPLETE ;
|
||||
std::list<TransferInfo> peers;
|
||||
|
||||
info.priority = SPEED_NORMAL;
|
||||
info.lastTS = 0;
|
||||
|
||||
return true;
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
return mFileHierarchy->searchTerms(terms,results);
|
||||
}
|
||||
int DirectoryStorage::searchBoolExp(Expression * exp, std::list<EntryIndex> &results) const
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
return mFileHierarchy->searchBoolExp(exp,results);
|
||||
}
|
||||
|
||||
bool DirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
|
||||
@ -444,6 +411,47 @@ bool LocalDirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
|
||||
return getFileSharingPermissions(indx,d.flags,d.parent_groups) ;
|
||||
}
|
||||
|
||||
bool LocalDirectoryStorage::getFileInfo(DirectoryStorage::EntryIndex i,FileInfo& info)
|
||||
{
|
||||
DirDetails d;
|
||||
extractData(i,d) ;
|
||||
|
||||
if(d.type != DIR_TYPE_FILE)
|
||||
{
|
||||
std::cerr << "(EE) LocalDirectoryStorage: asked for file info for index " << i << " which is not a file." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
info.storage_permission_flags = d.flags; // Combination of the four RS_DIR_FLAGS_*. Updated when the file is a local stored file.
|
||||
info.parent_groups = d.parent_groups;
|
||||
info.transfer_info_flags = TransferRequestFlags(); // various flags from RS_FILE_HINTS_*
|
||||
info.path = d.path + "/" + d.name;
|
||||
info.fname = d.name;
|
||||
info.hash = d.hash;
|
||||
info.size = d.count;
|
||||
|
||||
// all this stuff below is not useful in this case.
|
||||
|
||||
info.mId = 0; /* (GUI) Model Id -> unique number */
|
||||
info.ext.clear();
|
||||
info.avail = 0; /* how much we have */
|
||||
info.rank = 0;
|
||||
info.age = 0;
|
||||
info.queue_position =0;
|
||||
info.searchId = 0; /* 0 if none */
|
||||
|
||||
/* Transfer Stuff */
|
||||
info.transfered = 0;
|
||||
info.tfRate = 0; /* in kbytes */
|
||||
info.downloadStatus = FT_STATE_COMPLETE ;
|
||||
std::list<TransferInfo> peers;
|
||||
|
||||
info.priority = SPEED_NORMAL;
|
||||
info.lastTS = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LocalDirectoryStorage::getFileSharingPermissions(const EntryIndex& indx,FileStorageFlags& flags,std::list<RsNodeGroupId>& parent_groups)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
|
@ -24,9 +24,9 @@ class DirectoryStorage
|
||||
|
||||
void save() const ;
|
||||
|
||||
virtual int searchTerms(const std::list<std::string>& terms, std::list<EntryIndex> &results) const { NOT_IMPLEMENTED() ; return 0;}
|
||||
virtual int searchTerms(const std::list<std::string>& terms, std::list<EntryIndex> &results) const ;
|
||||
virtual int searchBoolExp(Expression * exp, std::list<EntryIndex> &results) const ;
|
||||
virtual int searchHash(const RsFileHash& hash, std::list<EntryIndex> &results) const ;
|
||||
virtual int searchBoolExp(Expression * exp, std::list<EntryIndex> &results) const { NOT_IMPLEMENTED() ; return 0; }
|
||||
|
||||
bool getDirUpdateTS(EntryIndex index,time_t& recurs_max_modf_TS,time_t& local_update_TS) ;
|
||||
bool setDirUpdateTS(EntryIndex index,time_t recurs_max_modf_TS,time_t local_update_TS) ;
|
||||
|
@ -55,6 +55,7 @@ file_lists {
|
||||
file_sharing/directory_storage.cc \
|
||||
file_sharing/directory_updater.cc \
|
||||
file_sharing/dir_hierarchy.cc \
|
||||
file_sharing/rsexpr.cc \
|
||||
file_sharing/rsfilelistitems.cc
|
||||
}
|
||||
|
||||
@ -366,11 +367,6 @@ INCLUDEPATH *= $${OPENPGPSDK_DIR}
|
||||
PRE_TARGETDEPS *= $${OPENPGPSDK_DIR}/lib/libops.a
|
||||
LIBS *= $${OPENPGPSDK_DIR}/lib/libops.a -lbz2
|
||||
|
||||
HEADERS += dbase/cachestrapper.h \
|
||||
dbase/fimonitor.h \
|
||||
dbase/findex.h \
|
||||
dbase/fistore.h
|
||||
|
||||
HEADERS += ft/ftchunkmap.h \
|
||||
ft/ftcontroller.h \
|
||||
ft/ftdata.h \
|
||||
@ -532,13 +528,6 @@ HEADERS += util/folderiterator.h \
|
||||
util/rsscopetimer.h \
|
||||
util/stacktrace.h
|
||||
|
||||
SOURCES += dbase/cachestrapper.cc \
|
||||
dbase/fimonitor.cc \
|
||||
dbase/findex.cc \
|
||||
dbase/fistore.cc \
|
||||
dbase/rsexpr.cc
|
||||
|
||||
|
||||
SOURCES += ft/ftchunkmap.cc \
|
||||
ft/ftcontroller.cc \
|
||||
ft/ftdatamultiplex.cc \
|
||||
|
@ -236,7 +236,7 @@ public:
|
||||
RsPeerId id;
|
||||
std::string name;
|
||||
RsFileHash hash;
|
||||
std::string path;
|
||||
std::string path; // full path of the parent directory, when it is a file; full path of the dir otherwise.
|
||||
uint64_t count;
|
||||
uint32_t age;
|
||||
FileStorageFlags flags;
|
||||
|
Loading…
Reference in New Issue
Block a user