Преглед на файлове

windows compilation issues

David Rose преди 16 години
родител
ревизия
c947b4ba4b

+ 9 - 3
direct/src/plugin/fileSpec.cxx

@@ -164,7 +164,7 @@ quick_verify(const string &package_dir) {
 
   // If the size is right but the timestamp is wrong, the file
   // soft-fails.  We follow this up with a hash check.
-  if (!priv_check_hash(pathname, st)) {
+  if (!priv_check_hash(pathname, &st)) {
     // Hard fail, the hash is wrong.
     //cerr << "hash check wrong: " << _filename << "\n";
     return false;
@@ -214,7 +214,7 @@ full_verify(const string &package_dir) {
     return false;
   }
 
-  if (!priv_check_hash(pathname, st)) {
+  if (!priv_check_hash(pathname, &st)) {
     // Hard fail, the hash is wrong.
     //cerr << "hash check wrong: " << _filename << "\n";
     return false;
@@ -353,9 +353,15 @@ output_hash(ostream &out) const {
 //               false otherwise.  Updates _actual_file with the data
 //               read from disk, including the hash, for future
 //               reference.
+//
+//               The parameter stp is a pointer to a stat structure.
+//               It's declared as a void * to get around issues with
+//               the nonstandard declaration of this structure in
+//               Windows.
 ////////////////////////////////////////////////////////////////////
 bool FileSpec::
-priv_check_hash(const string &pathname, const struct stat &st) {
+priv_check_hash(const string &pathname, void *stp) {
+  const struct stat &st = *(const struct stat *)stp;
   assert(_actual_file == NULL);
   _actual_file = new FileSpec;
   _actual_file->_filename = pathname;

+ 1 - 1
direct/src/plugin/fileSpec.h

@@ -53,7 +53,7 @@ public:
   void output_hash(ostream &out) const;
 
 private:
-  bool priv_check_hash(const string &pathname, const struct stat &st);
+  bool priv_check_hash(const string &pathname, void *stp);
   static inline int decode_hexdigit(char c);
   static inline char encode_hexdigit(int c);
 

+ 3 - 2
direct/src/plugin/p3dDownload.I

@@ -32,11 +32,12 @@ get_url() const {
 ////////////////////////////////////////////////////////////////////
 inline double P3DDownload::
 get_download_progress() const {
-  if (_total_expected_data == 0) {
+  int total_expected_data = max(_total_server_expected_data, _total_client_expected_data);
+  if (total_expected_data == 0) {
     return 0.0;
   }
 
-  return (double)_total_data / (double)_total_expected_data;
+  return (double)_total_data / (double)total_expected_data;
 }
 
 ////////////////////////////////////////////////////////////////////

+ 5 - 3
direct/src/plugin/p3dDownload.cxx

@@ -24,7 +24,8 @@ P3DDownload() {
   _status = P3D_RC_in_progress;
   _http_status_code = 0;
   _total_data = 0;
-  _total_expected_data = 0;
+  _total_client_expected_data = 0;
+  _total_server_expected_data = 0;
   _last_reported_time = 0;
   
   _canceled = false;
@@ -39,11 +40,12 @@ P3DDownload() {
 P3DDownload::
 P3DDownload(const P3DDownload &copy) :
   _url(copy._url),
-  _total_expected_data(copy._total_expected_data)
+  _total_client_expected_data(copy._total_client_expected_data)
 {
   _status = P3D_RC_in_progress;
   _http_status_code = 0;
   _total_data = 0;
+  _total_server_expected_data = 0;
   _last_reported_time = 0;
   
   _canceled = false;
@@ -115,7 +117,7 @@ feed_url_stream(P3D_result_code result_code,
     _total_data += this_data_size;
   }
 
-  _total_expected_data = max(total_expected_data, _total_data);
+  _total_server_expected_data = max(total_expected_data, _total_data);
 
   download_progress();
 

+ 2 - 1
direct/src/plugin/p3dDownload.h

@@ -66,7 +66,8 @@ protected:
   int _http_status_code;
 
   size_t _total_data;
-  size_t _total_expected_data;
+  size_t _total_client_expected_data;
+  size_t _total_server_expected_data;
   time_t _last_reported_time;
 
 private:

+ 5 - 0
direct/src/plugin/p3dPackage.cxx

@@ -1080,6 +1080,7 @@ Download(P3DPackage *package, DownloadType dtype, const FileSpec &file_spec) :
   _dtype(dtype),
   _file_spec(file_spec)
 {
+  _total_client_expected_data = _file_spec.get_size();
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -1095,6 +1096,7 @@ Download(const P3DPackage::Download &copy) :
   _dtype(copy._dtype),
   _file_spec(copy._file_spec)
 {
+  _total_client_expected_data = _file_spec.get_size();
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -1104,6 +1106,9 @@ Download(const P3DPackage::Download &copy) :
 ////////////////////////////////////////////////////////////////////
 void P3DPackage::Download::
 download_progress() {
+  nout << "download_progress " << get_url() << ": " << _total_data 
+       << " of " << _total_server_expected_data << " and "
+       << _total_client_expected_data << "\n";
   P3DFileDownload::download_progress();
   assert(_package->_active_download == this);
 

+ 0 - 1
direct/src/plugin/p3dPackage.h

@@ -201,7 +201,6 @@ private:
   void build_install_plans(TiXmlDocument *doc);
   void follow_install_plans(bool download_finished);
 
-  class InstallStep;
   void report_progress(InstallStep *step);
   void report_info_ready();
   void report_done(bool success);

+ 1 - 1
direct/src/plugin/p3dPatchfileReader.cxx

@@ -152,7 +152,7 @@ step() {
   size_t copy_length = read_uint16();
   if (copy_length != 0) {
     // Copy a number of bytes from the original source.
-    ssize_t offset = read_int32();
+    int offset = read_int32();
     _source_in.seekg(offset, ios::cur);
     if (!copy_bytes(_source_in, copy_length)) {
       nout << "Garbage in patchfile.\n";