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
executable file
·129 lines (118 loc) · 4.36 KB
/
fileSpec.I
File metadata and controls
executable file
·129 lines (118 loc) · 4.36 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Filename: fileSpec.I
// Created by: drose (29Jun09)
//
////////////////////////////////////////////////////////////////////
//
// 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."
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: FileSpec::get_filename
// Access: Public
// Description: Returns the relative path to this file on disk,
// within the package root directory.
////////////////////////////////////////////////////////////////////
inline const string &FileSpec::
get_filename() const {
return _filename;
}
////////////////////////////////////////////////////////////////////
// Function: FileSpec::set_filename
// Access: Public
// Description: Changes the relative path to this file on disk,
// within the package root directory.
////////////////////////////////////////////////////////////////////
inline void FileSpec::
set_filename(const string &filename) {
_filename = filename;
}
////////////////////////////////////////////////////////////////////
// Function: FileSpec::get_pathname
// Access: Public
// Description: Returns the full path to this file on disk.
////////////////////////////////////////////////////////////////////
inline string FileSpec::
get_pathname(const string &package_dir) const {
return package_dir + "/" + _filename;
}
////////////////////////////////////////////////////////////////////
// Function: FileSpec::get_size
// Access: Public
// Description: Returns the expected size of this file on disk, in
// bytes.
////////////////////////////////////////////////////////////////////
inline size_t FileSpec::
get_size() const {
return _size;
}
////////////////////////////////////////////////////////////////////
// Function: FileSpec::get_timestamp
// Access: Public
// Description: Returns the expected last-modify timestamp of this
// file on disk.
////////////////////////////////////////////////////////////////////
inline time_t FileSpec::
get_timestamp() const {
return _timestamp;
}
////////////////////////////////////////////////////////////////////
// Function: FileSpec::has_hash
// Access: Public
// Description: Returns true if we have successfully read a hash
// value, false otherwise.
////////////////////////////////////////////////////////////////////
inline bool FileSpec::
has_hash() const {
return _got_hash;
}
////////////////////////////////////////////////////////////////////
// Function: FileSpec::get_actual_file
// Access: Public
// Description: 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;
}
////////////////////////////////////////////////////////////////////
// Function: FileSpec::decode_hexdigit
// Access: Private
// Description: 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;
}
////////////////////////////////////////////////////////////////////
// Function: FileSpec::encode_hexdigit
// Access: Private
// Description: 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';
}