patchfile.I 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Filename: patchfile.I
  2. // Created by: darren, mike (09Jan97)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. //#include "config_downloader.h"
  19. ////////////////////////////////////////////////////////////////////
  20. // Function: Patchfile::get_progress
  21. // Access: Published
  22. // Description:
  23. ////////////////////////////////////////////////////////////////////
  24. INLINE float Patchfile::
  25. get_progress(void) const {
  26. if (false == _initiated) {
  27. express_cat.warning()
  28. << "Patchfile::get_progress() - Patch has not been initiated" << endl;
  29. return 0.0f;
  30. }
  31. nassertr(_result_file_length > 0, 0.0f);
  32. return ((float)_total_bytes_processed / (float)_result_file_length);
  33. }
  34. ////////////////////////////////////////////////////////////////////
  35. // Function: Patchfile::set_footprint_length
  36. // Access: Published
  37. // Description:
  38. ////////////////////////////////////////////////////////////////////
  39. INLINE void Patchfile::
  40. set_footprint_length(int length) {
  41. nassertv(_footprint_length > 0);
  42. _footprint_length = length;
  43. }
  44. ////////////////////////////////////////////////////////////////////
  45. // Function: Patchfile::get_footprint_length
  46. // Access: Published
  47. // Description:
  48. ////////////////////////////////////////////////////////////////////
  49. INLINE int Patchfile::
  50. get_footprint_length() {
  51. return _footprint_length;
  52. }
  53. ////////////////////////////////////////////////////////////////////
  54. // Function: Patchfile::reset_footprint_length
  55. // Access: Published
  56. // Description:
  57. ////////////////////////////////////////////////////////////////////
  58. INLINE void Patchfile::
  59. reset_footprint_length() {
  60. _footprint_length = _DEFAULT_FOOTPRINT_LENGTH;
  61. }
  62. ////////////////////////////////////////////////////////////////////
  63. // Function: Patchfile::has_source_hash
  64. // Access: Published
  65. // Description: Returns true if the MD5 hash for the source file is
  66. // known. (Some early versions of the patch file did
  67. // not store this information.)
  68. ////////////////////////////////////////////////////////////////////
  69. INLINE bool Patchfile::
  70. has_source_hash() const {
  71. return (_version_number >= 1);
  72. }
  73. ////////////////////////////////////////////////////////////////////
  74. // Function: Patchfile::get_source_hash
  75. // Access: Published
  76. // Description: Returns the MD5 hash for the source file.
  77. ////////////////////////////////////////////////////////////////////
  78. INLINE const HashVal &Patchfile::
  79. get_source_hash() const {
  80. nassertr(has_source_hash(), _MD5_ofSource);
  81. return _MD5_ofSource;
  82. }
  83. ////////////////////////////////////////////////////////////////////
  84. // Function: Patchfile::get_result_hash
  85. // Access: Published
  86. // Description: Returns the MD5 hash for the file after the patch has
  87. // been applied.
  88. ////////////////////////////////////////////////////////////////////
  89. INLINE const HashVal &Patchfile::
  90. get_result_hash() const {
  91. return _MD5_ofResult;
  92. }