Update of /cvsroot/sharedaemon/core/src
In directory sc8-pr-cvs1:/tmp/cvs-serv22311
Modified Files:
test.cpp
Log Message:
Added code to scan the whole incoming directory for .part.met files, which in turn are being loaded
Index: test.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/core/src/test.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- test.cpp 26 Nov 2003 01:22:56 -0000 1.28
+++ test.cpp 26 Nov 2003 02:07:04 -0000 1.29
@@ -591,6 +591,7 @@
int max_partfiles=0;
std::string IncomingDirectory="/mnt/Fat_C/gesaugt/Internet/eMule/Incoming";
std::map<std::string,ParseClass *> partfile;
+std::vector<std::string> partfilename;
void printhash(hash h) {
int i;
@@ -599,17 +600,20 @@
}
bool load_part_met(std::string part_met) {
+#ifdef PRINT_PART_MET_ON_LOADING
u8 part_met_magic;
u32 part_met_date;
hash part_met_filehash;
u32 part_met_chunkcount;
hash part_met_chunkhash;
u32 part_met_tagcount;
-
u32 i;
+#endif // #ifdef PRINT_PART_MET_ON_LOADING
printf("Loading part file %s ...",part_met.c_str());
+ partfilename.push_back(part_met);
+
ParseClass * & PartFile=partfile[part_met];
if (!PartFile) {
@@ -617,6 +621,8 @@
}
PartFile->Read(part_met.c_str());
+
+#ifdef PRINT_PART_MET_ON_LOADING
PartFile->Get(part_met_magic ,"magic"); printf("Magic =0x%02x\n",(unsigned)part_met_magic);
PartFile->Get(part_met_date ,"date"); printf("Date =0x%08x\n",(unsigned)part_met_date);
PartFile->Get(part_met_filehash ,"filehash"); printf("File hash ="); printhash(part_met_filehash); putchar('\n');
@@ -628,12 +634,32 @@
putchar('\n');
}
PartFile->Get(part_met_tagcount ,"tagcount"); printf("Tag count =%u\n",(unsigned)part_met_tagcount);
+#endif // #ifdef PRINT_PART_MET_ON_LOADING
printf(" done.\n");
return true;
}
+#include "main-c.h"
+
+bool load_part_met_wrapper(cstring base, cstring rel, cstring file) {
+ int sl=strlen(file);
+
+ if (sl<10) return true;
+ if (strcmp(file+sl-9,".part.met")) return true;
+
+ load_part_met(std::string(base)+"/"+rel+"/"+file);
+
+ return true;
+}
+
+void load_all_part_mets(std::string part_met_base_directory) {
+ EnumFiles(part_met_base_directory.c_str(),load_part_met_wrapper,NULL,NULL);
+
+// load_part_met(part_met_base_directory+"/"+"004.part.met");
+}
+
void parse_something() {
server_met_ps=parse_line(
"<BYTE>magic<DWORD>num_servers{<IPPORT>ip<DWORD>num_tags<TAG>tag[num_tags]}server[num_servers]"
@@ -1174,7 +1200,7 @@
}
// print_server_met();
- load_part_met(IncomingDirectory+"/"+"004.part.met");
+ load_all_part_mets(IncomingDirectory);
u32 clienttcpportid=Connection::Alloc();
|