Jelajahi Sumber

*** empty log message ***

Mike Goslin 25 tahun lalu
induk
melakukan
4137f57be8

+ 12 - 0
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));
 }

+ 5 - 1
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;
 }
 
 ////////////////////////////////////////////////////////////////////

+ 1 - 0
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: