Update of /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/System
In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29716
Modified Files:
System.cpp System.h
Log Message:
Asynchronous downloading.
Index: System.cpp
===================================================================
RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/System/System.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** System.cpp 7 May 2007 20:06:54 -0000 1.13
--- System.cpp 16 May 2007 09:46:19 -0000 1.14
***************
*** 8,11 ****
--- 8,12 ----
#include <System/System.h>
+ #include <System/System-Thread-Download.h>
#include <Plan/Plan.h>
#include <Base/Config.h>
***************
*** 22,25 ****
--- 23,27 ----
#include <stdlib.h>
#include <sys/types.h>
+ #include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
***************
*** 97,101 ****
}
! int System::download(std::string url,
std::string localfile)
{
--- 99,103 ----
}
! int System::downloadNow(std::string url,
std::string localfile)
{
***************
*** 121,127 ****
--- 123,151 ----
exec0(cmd);
return(1);
+ }
+
+ int System::download(std::string url,
+ std::string localfile,
+ int expectedSize)
+ {
+ std::string msg;
+ SystemThreadDownload T(url, localfile, expectedSize);
+
+ msg="Downloading ";
+ msg+=url;
+
+ cbmUI->ProgressInit(msg);
+ T.Start();
+
+ while (!T.Terminated()) {
+ sleep(1);
+ cbmUI->Progress(T.Progress());
+ }
+ cbmUI->ProgressDone();
+ return(1);
}
+
int System::init(void)
{
***************
*** 559,562 ****
--- 583,595 ----
}
+ int System::fileSize(std::string fn)
+ {
+ struct stat buf;
+
+ stat(fn.c_str(), &buf);
+
+ return(buf.st_size);
+ }
+
void System::startTimer(void)
{
Index: System.h
===================================================================
RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/System/System.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** System.h 7 May 2007 20:06:54 -0000 1.8
--- System.h 16 May 2007 09:46:19 -0000 1.9
***************
*** 221,224 ****
--- 221,225 ----
/** Download a file or a page to a physical file.
+ *
* Uses wget for now.
* \param url URL containing data to download
***************
*** 226,231 ****
* \return 1 if ok.
*/ \
virtual int download(std::string url,
! std::string localfile);
/** Copy a local file.
--- 227,245 ----
* \return 1 if ok.
*/ \
+ virtual int downloadNow(std::string url,
+ std::string localfile);
+
+ /** Threaded download of a file or a page to a physical file.
+ *
+ * Uses wget for now.
+ *
+ * \param url URL containing data to download
+ * \param localfile local filename used to store data
+ * \param expectedSize File size expected, in bytes
+ * \return 1 if ok.
+ */ \
virtual int download(std::string url,
! std::string localfile,
! int expectedSize);
/** Copy a local file.
***************
*** 274,277 ****
--- 288,292 ----
std::string data);
+ virtual int fileSize(std::string fn);
/** Initialize current object's timer.
|