windows compilation issues

This commit is contained in:
David Rose 2009-09-28 17:26:32 +00:00
parent 3771d613ad
commit c947b4ba4b
8 changed files with 26 additions and 12 deletions

View File

@ -164,7 +164,7 @@ quick_verify(const string &package_dir) {
// If the size is right but the timestamp is wrong, the file // If the size is right but the timestamp is wrong, the file
// soft-fails. We follow this up with a hash check. // 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. // Hard fail, the hash is wrong.
//cerr << "hash check wrong: " << _filename << "\n"; //cerr << "hash check wrong: " << _filename << "\n";
return false; return false;
@ -214,7 +214,7 @@ full_verify(const string &package_dir) {
return false; return false;
} }
if (!priv_check_hash(pathname, st)) { if (!priv_check_hash(pathname, &st)) {
// Hard fail, the hash is wrong. // Hard fail, the hash is wrong.
//cerr << "hash check wrong: " << _filename << "\n"; //cerr << "hash check wrong: " << _filename << "\n";
return false; return false;
@ -353,9 +353,15 @@ output_hash(ostream &out) const {
// false otherwise. Updates _actual_file with the data // false otherwise. Updates _actual_file with the data
// read from disk, including the hash, for future // read from disk, including the hash, for future
// reference. // 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:: 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); assert(_actual_file == NULL);
_actual_file = new FileSpec; _actual_file = new FileSpec;
_actual_file->_filename = pathname; _actual_file->_filename = pathname;

View File

@ -53,7 +53,7 @@ public:
void output_hash(ostream &out) const; void output_hash(ostream &out) const;
private: 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 int decode_hexdigit(char c);
static inline char encode_hexdigit(int c); static inline char encode_hexdigit(int c);

View File

@ -32,11 +32,12 @@ get_url() const {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
inline double P3DDownload:: inline double P3DDownload::
get_download_progress() const { 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 0.0;
} }
return (double)_total_data / (double)_total_expected_data; return (double)_total_data / (double)total_expected_data;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

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

View File

@ -66,7 +66,8 @@ protected:
int _http_status_code; int _http_status_code;
size_t _total_data; 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; time_t _last_reported_time;
private: private:

View File

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

View File

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

View File

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