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