diff --git a/panda/src/downloader/download.I b/panda/src/downloader/download.I index ebf09af57e..6381d73a96 100644 --- a/panda/src/downloader/download.I +++ b/panda/src/downloader/download.I @@ -78,6 +78,17 @@ get_disk_write_frequency(void) const { return _disk_write_frequency; } +//////////////////////////////////////////////////////////////////// +// Function: Download::get_bytes_written +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE int Download:: +get_bytes_written(void) const { + nassertr(_current_status != NULL, 0); + return _current_status->_total_bytes_written; +} + //////////////////////////////////////////////////////////////////// // Function: Download::get_bytes_per_second // Access: Public @@ -86,5 +97,6 @@ get_disk_write_frequency(void) const { INLINE float Download:: get_bytes_per_second(void) const { nassertr(_tlast - _tfirst > 0.0, 0.0); + nassertr(_current_status != NULL, 0.0); return (float)((double)_current_status->_total_bytes / (_tlast - _tfirst)); } diff --git a/panda/src/downloader/download.cxx b/panda/src/downloader/download.cxx index 4e9fe3930c..df96fb21c3 100644 --- a/panda/src/downloader/download.cxx +++ b/panda/src/downloader/download.cxx @@ -361,6 +361,7 @@ run(void) { if (connect_to_server() == false) return DS_error_connect; + int ret = DS_ok; double t0 = _clock.get_real_time(); if (_tfirst == 0.0) { _tfirst = t0; @@ -376,6 +377,7 @@ run(void) { if (write_to_disk(_current_status) == false) { return DS_error_write; } + ret = DS_write; } // Allocate a new buffer @@ -395,6 +397,7 @@ run(void) { << "Download::run() - Flushing buffer" << endl; if (write_to_disk(_current_status) == false) return DS_error_write; + ret = DS_write; } // Attempt to receive the bytes from the socket @@ -407,6 +410,7 @@ run(void) { if (_current_status->_bytes_in_buffer > 0) { if (write_to_disk(_current_status) == false) return DS_error_write; + ret = DS_write; } return DS_success; } else { @@ -420,7 +424,7 @@ run(void) { } _got_any_data = true; - return DS_ok; + return ret; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/downloader/download.h b/panda/src/downloader/download.h index f663e261ec..1e00b93cb7 100644 --- a/panda/src/downloader/download.h +++ b/panda/src/downloader/download.h @@ -58,6 +58,7 @@ PUBLISHED: INLINE float get_byte_rate(void) const; INLINE void set_disk_write_frequency(int frequency); INLINE int get_disk_write_frequency(void) const; + INLINE int get_bytes_written(void) const; INLINE float get_bytes_per_second(void) const; private: