Panda3D
virtualFile.I
1 // Filename: virtualFile.I
2 // Created by: drose (03Aug02)
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: VirtualFile::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE VirtualFile::
22 VirtualFile() {
23 }
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function: VirtualFile::get_original_filename
27 // Access: Published
28 // Description: Returns the original filename as it was used to
29 // locate this VirtualFile. This is usually, but not
30 // always, the same string returned by get_filename().
31 ////////////////////////////////////////////////////////////////////
32 INLINE const Filename &VirtualFile::
34  return _original_filename;
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: VirtualFile::read_file
39 // Access: Public
40 // Description: Returns the entire contents of the file as a string.
41 ////////////////////////////////////////////////////////////////////
42 INLINE string VirtualFile::
43 read_file(bool auto_unwrap) const {
44  string result;
45  read_file(result, auto_unwrap);
46  return result;
47 }
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function: VirtualFile::write_file
51 // Access: Public
52 // Description: Writes the entire contents of the file as a string,
53 // if it is writable.
54 ////////////////////////////////////////////////////////////////////
55 INLINE bool VirtualFile::
56 write_file(const string &data, bool auto_wrap) {
57  return write_file((const unsigned char *)data.data(), data.size(), auto_wrap);
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function: VirtualFile::set_original_filename
62 // Access: Public
63 // Description: Stores the original filename that was used to locate
64 // this VirtualFile. This is normally called only by
65 // the VirtualFileSystem, as it creates each
66 // VirtualFile.
67 ////////////////////////////////////////////////////////////////////
68 INLINE void VirtualFile::
69 set_original_filename(const Filename &filename) {
70  _original_filename = filename;
71 }
72 
73 
74 INLINE ostream &
75 operator << (ostream &out, const VirtualFile &file) {
76  file.output(out);
77  return out;
78 }
79 
void set_original_filename(const Filename &filename)
Stores the original filename that was used to locate this VirtualFile.
Definition: virtualFile.I:69
The abstract base class for a file or directory within the VirtualFileSystem.
Definition: virtualFile.h:37
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
const Filename & get_original_filename() const
Returns the original filename as it was used to locate this VirtualFile.
Definition: virtualFile.I:33
bool write_file(const string &data, bool auto_wrap)
Writes the entire contents of the file as a string, if it is writable.
Definition: virtualFile.I:56
string read_file(bool auto_unwrap) const
Returns the entire contents of the file as a string.
Definition: virtualFile.I:43