Panda3D
patchfile.I
1 // Filename: patchfile.I
2 // Created by: darren, mike (09Jan97)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 //#include "config_downloader.h"
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: Patchfile::get_progress
19 // Access: Published
20 // Description: Returns a value in the range 0..1, representing the
21 // amount of progress through the patchfile, during a
22 // session.
23 ////////////////////////////////////////////////////////////////////
24 INLINE PN_stdfloat Patchfile::
25 get_progress() const {
26  if (!_initiated) {
27  express_cat.warning()
28  << "Patchfile::get_progress() - Patch has not been initiated" << endl;
29  return 0.0f;
30  }
31  nassertr(_total_bytes_to_process > 0, 0.0f);
32  return ((PN_stdfloat)_total_bytes_processed / (PN_stdfloat)_total_bytes_to_process);
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function: Patchfile::set_allow_multifile
37 // Access: Published
38 // Description: If this flag is set true, the Patchfile will make a
39 // special case for patching Panda Multifiles, if
40 // detected, and attempt to patch them on a
41 // subfile-by-subfile basis. If this flag is false, the
42 // Patchfile will always patch the file on a full-file
43 // basis.
44 //
45 // This has effect only when building patches; it is not
46 // used for applying patches.
47 ////////////////////////////////////////////////////////////////////
48 INLINE void Patchfile::
49 set_allow_multifile(bool allow_multifile) {
50  _allow_multifile = allow_multifile;
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: Patchfile::get_allow_multifile
55 // Access: Published
56 // Description: See set_allow_multifile().
57 ////////////////////////////////////////////////////////////////////
58 INLINE bool Patchfile::
59 get_allow_multifile() {
60  return _allow_multifile;
61 }
62 
63 ////////////////////////////////////////////////////////////////////
64 // Function: Patchfile::set_footprint_length
65 // Access: Published
66 // Description:
67 ////////////////////////////////////////////////////////////////////
68 INLINE void Patchfile::
69 set_footprint_length(int length) {
70  nassertv(length > 0);
71  _footprint_length = length;
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: Patchfile::get_footprint_length
76 // Access: Published
77 // Description:
78 ////////////////////////////////////////////////////////////////////
79 INLINE int Patchfile::
80 get_footprint_length() {
81  return _footprint_length;
82 }
83 
84 ////////////////////////////////////////////////////////////////////
85 // Function: Patchfile::reset_footprint_length
86 // Access: Published
87 // Description:
88 ////////////////////////////////////////////////////////////////////
89 INLINE void Patchfile::
90 reset_footprint_length() {
91  _footprint_length = _DEFAULT_FOOTPRINT_LENGTH;
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function: Patchfile::has_source_hash
96 // Access: Published
97 // Description: Returns true if the MD5 hash for the source file is
98 // known. (Some early versions of the patch file did
99 // not store this information.)
100 ////////////////////////////////////////////////////////////////////
101 INLINE bool Patchfile::
102 has_source_hash() const {
103  return (_version_number >= 1);
104 }
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function: Patchfile::get_source_hash
108 // Access: Published
109 // Description: Returns the MD5 hash for the source file.
110 ////////////////////////////////////////////////////////////////////
111 INLINE const HashVal &Patchfile::
112 get_source_hash() const {
113  nassertr(has_source_hash(), _MD5_ofSource);
114  return _MD5_ofSource;
115 }
116 
117 ////////////////////////////////////////////////////////////////////
118 // Function: Patchfile::get_result_hash
119 // Access: Published
120 // Description: Returns the MD5 hash for the file after the patch has
121 // been applied.
122 ////////////////////////////////////////////////////////////////////
123 INLINE const HashVal &Patchfile::
124 get_result_hash() const {
125  return _MD5_ofResult;
126 }
Stores a 128-bit value that represents the hashed contents (typically MD5) of a file or buffer...
Definition: hashVal.h:32