From dea8d34556c06b00108c7151ffcbd9b365be0757 Mon Sep 17 00:00:00 2001 From: Mike Goslin Date: Wed, 4 Jul 2001 01:18:37 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/downloader/downloader.I | 19 +++++++++++++++++++ panda/src/downloader/downloader.cxx | 8 ++++++++ panda/src/downloader/downloader.h | 3 +++ 3 files changed, 30 insertions(+) diff --git a/panda/src/downloader/downloader.I b/panda/src/downloader/downloader.I index 46c9042764..845c150e1c 100644 --- a/panda/src/downloader/downloader.I +++ b/panda/src/downloader/downloader.I @@ -110,6 +110,25 @@ get_bytes_written(void) const { return _total_bytes_written; } +//////////////////////////////////////////////////////////////////// +// Function: Downloader::get_bytes_requested +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE int Downloader:: +get_bytes_requested(void) const { + if (_ever_initiated == false) { + downloader_cat.warning() + << "Downloader::get_bytes_requested() - Download has not been " + << "initiated" << endl; + return 0; + } + if (_current_status != NULL) + return _current_status->_total_bytes_requested; + else + return _total_bytes_requested; +} + //////////////////////////////////////////////////////////////////// // Function: Downloader::get_bytes_per_second // Access: Public diff --git a/panda/src/downloader/downloader.cxx b/panda/src/downloader/downloader.cxx index 236ede831e..dd131dd4a2 100644 --- a/panda/src/downloader/downloader.cxx +++ b/panda/src/downloader/downloader.cxx @@ -67,6 +67,8 @@ Downloader(void) { _ever_initiated = false; _TCP_stack_initialized = false; _total_bytes_written = 0; + _total_bytes_requested = 0; + _total_bytes_requested = 0; } //////////////////////////////////////////////////////////////////// @@ -433,6 +435,7 @@ cleanup(void) { disconnect_from_server(); _dest_stream.close(); _total_bytes_written = _current_status->_total_bytes_written; + _total_bytes_requested = _current_status->_total_bytes_requested; delete _current_status; // We must set this to NULL otherwise there is a bad pointer floating around _current_status = NULL; @@ -543,6 +546,8 @@ run(void) { fret = fast_receive(_socket, _current_status, _receive_size); } + _current_status->_total_bytes_requested += _receive_size; + // Check for end of file if (fret == EU_eof) { if (_got_any_data == true) { @@ -664,6 +669,8 @@ run_to_ram(void) { fret = fast_receive(_socket, _current_status, _receive_size); } + _current_status->_total_bytes_requested += _receive_size; + // Check for end of file if (fret == EU_eof) { if (_got_any_data == true) { @@ -1003,6 +1010,7 @@ DownloadStatus(char *buffer, int first_byte, int last_byte, // will get the total size of the file, not just the number // of bytes for this partial download _total_bytes_written = first_byte; + _total_bytes_requested = first_byte; _partial_content = partial_content; reset(); } diff --git a/panda/src/downloader/downloader.h b/panda/src/downloader/downloader.h index 365220256a..5b104542a2 100644 --- a/panda/src/downloader/downloader.h +++ b/panda/src/downloader/downloader.h @@ -65,6 +65,7 @@ PUBLISHED: INLINE void set_disk_write_frequency(int frequency); INLINE int get_disk_write_frequency(void) const; INLINE int get_bytes_written(void) const; + INLINE int get_bytes_requested(void) const; INLINE float get_bytes_per_second(void) const; private: @@ -82,6 +83,7 @@ private: char *_next_in; int _bytes_in_buffer; int _total_bytes_written; + int _total_bytes_requested; int _first_byte; int _last_byte; int _total_bytes; @@ -124,6 +126,7 @@ private: DownloadStatus *_current_status; bool _got_any_data; int _total_bytes_written; + int _total_bytes_requested; bool _download_to_ram; double _tlast;