From c947b4ba4b02a987cae31ae242299a0dac234c00 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 28 Sep 2009 17:26:32 +0000 Subject: [PATCH] windows compilation issues --- direct/src/plugin/fileSpec.cxx | 12 +++++++++--- direct/src/plugin/fileSpec.h | 2 +- direct/src/plugin/p3dDownload.I | 5 +++-- direct/src/plugin/p3dDownload.cxx | 8 +++++--- direct/src/plugin/p3dDownload.h | 3 ++- direct/src/plugin/p3dPackage.cxx | 5 +++++ direct/src/plugin/p3dPackage.h | 1 - direct/src/plugin/p3dPatchfileReader.cxx | 2 +- 8 files changed, 26 insertions(+), 12 deletions(-) diff --git a/direct/src/plugin/fileSpec.cxx b/direct/src/plugin/fileSpec.cxx index c9a8ff12fd..c23db1674f 100755 --- a/direct/src/plugin/fileSpec.cxx +++ b/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; diff --git a/direct/src/plugin/fileSpec.h b/direct/src/plugin/fileSpec.h index c02dd1fbc1..4c8297679b 100755 --- a/direct/src/plugin/fileSpec.h +++ b/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); diff --git a/direct/src/plugin/p3dDownload.I b/direct/src/plugin/p3dDownload.I index 59c4bbf747..044a8c49b8 100755 --- a/direct/src/plugin/p3dDownload.I +++ b/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; } //////////////////////////////////////////////////////////////////// diff --git a/direct/src/plugin/p3dDownload.cxx b/direct/src/plugin/p3dDownload.cxx index fbef0187c8..04b915aff1 100755 --- a/direct/src/plugin/p3dDownload.cxx +++ b/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 ©) : _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(); diff --git a/direct/src/plugin/p3dDownload.h b/direct/src/plugin/p3dDownload.h index 5062ea09a0..0b89c0bf75 100755 --- a/direct/src/plugin/p3dDownload.h +++ b/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: diff --git a/direct/src/plugin/p3dPackage.cxx b/direct/src/plugin/p3dPackage.cxx index 59173b1ffc..5e272419b4 100755 --- a/direct/src/plugin/p3dPackage.cxx +++ b/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 ©) : _dtype(copy._dtype), _file_spec(copy._file_spec) { + _total_client_expected_data = _file_spec.get_size(); } //////////////////////////////////////////////////////////////////// @@ -1104,6 +1106,9 @@ Download(const P3DPackage::Download ©) : //////////////////////////////////////////////////////////////////// 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); diff --git a/direct/src/plugin/p3dPackage.h b/direct/src/plugin/p3dPackage.h index 69335eb460..88610ede48 100755 --- a/direct/src/plugin/p3dPackage.h +++ b/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); diff --git a/direct/src/plugin/p3dPatchfileReader.cxx b/direct/src/plugin/p3dPatchfileReader.cxx index 62393d3e97..81e8cf2011 100644 --- a/direct/src/plugin/p3dPatchfileReader.cxx +++ b/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";