Panda3D
|
00001 // Filename: virtualFile.I 00002 // Created by: drose (03Aug02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: VirtualFile::Constructor 00018 // Access: Public 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE VirtualFile:: 00022 VirtualFile() { 00023 } 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: VirtualFile::get_original_filename 00027 // Access: Published 00028 // Description: Returns the original filename as it was used to 00029 // locate this VirtualFile. This is usually, but not 00030 // always, the same string returned by get_filename(). 00031 //////////////////////////////////////////////////////////////////// 00032 INLINE const Filename &VirtualFile:: 00033 get_original_filename() const { 00034 return _original_filename; 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: VirtualFile::read_file 00039 // Access: Public 00040 // Description: Returns the entire contents of the file as a string. 00041 //////////////////////////////////////////////////////////////////// 00042 INLINE string VirtualFile:: 00043 read_file(bool auto_unwrap) const { 00044 string result; 00045 read_file(result, auto_unwrap); 00046 return result; 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: VirtualFile::write_file 00051 // Access: Public 00052 // Description: Writes the entire contents of the file as a string, 00053 // if it is writable. 00054 //////////////////////////////////////////////////////////////////// 00055 INLINE bool VirtualFile:: 00056 write_file(const string &data, bool auto_wrap) { 00057 return write_file((const unsigned char *)data.data(), data.size(), auto_wrap); 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: VirtualFile::set_original_filename 00062 // Access: Public 00063 // Description: Stores the original filename that was used to locate 00064 // this VirtualFile. This is normally called only by 00065 // the VirtualFileSystem, as it creates each 00066 // VirtualFile. 00067 //////////////////////////////////////////////////////////////////// 00068 INLINE void VirtualFile:: 00069 set_original_filename(const Filename &filename) { 00070 _original_filename = filename; 00071 } 00072 00073 00074 INLINE ostream & 00075 operator << (ostream &out, const VirtualFile &file) { 00076 file.output(out); 00077 return out; 00078 } 00079