forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileSpec.I
More file actions
102 lines (92 loc) · 2.18 KB
/
fileSpec.I
File metadata and controls
102 lines (92 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file fileSpec.I
* @author drose
* @date 2009-06-29
*/
/**
* Returns the relative path to this file on disk, within the package root
* directory.
*/
inline const string &FileSpec::
get_filename() const {
return _filename;
}
/**
* Changes the relative path to this file on disk, within the package root
* directory.
*/
inline void FileSpec::
set_filename(const string &filename) {
_filename = filename;
}
/**
* Returns the full path to this file on disk.
*/
inline string FileSpec::
get_pathname(const string &package_dir) const {
return package_dir + "/" + _filename;
}
/**
* Returns the expected size of this file on disk, in bytes.
*/
inline size_t FileSpec::
get_size() const {
return _size;
}
/**
* Returns the expected last-modify timestamp of this file on disk.
*/
inline time_t FileSpec::
get_timestamp() const {
return _timestamp;
}
/**
* Returns true if we have successfully read a hash value, false otherwise.
*/
inline bool FileSpec::
has_hash() const {
return _got_hash;
}
/**
* After a call to quick_verify() or full_verify(), this method *may* return a
* pointer to a FileSpec that represents the actual data read on disk, or it
* may return NULL. If this returns a non-NULL value, you may use it to
* extract the md5 hash of the existing file, thus saving the effort of
* performing the hash twice.
*/
inline const FileSpec *FileSpec::
get_actual_file() const {
return _actual_file;
}
/**
* Returns the integer value corresponding to the indicated hex digit.
* Returns -1 if it is not a hex digit.
*/
inline int FileSpec::
decode_hexdigit(char c) {
if (isdigit(c)) {
return c - '0';
}
c = tolower(c);
if (c >= 'a' && c <= 'f') {
return c - 'a' + 10;
}
return -1;
}
/**
* Returns the hex digit corresponding to the indicated integer value.
*/
inline char FileSpec::
encode_hexdigit(int c) {
if (c >= 10) {
return c - 10 + 'a';
}
return c + '0';
}