Panda3D
datagramOutputFile.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 datagramOutputFile.I
10  * @author drose
11  * @date 2000-10-27
12  */
13 
14 /**
15  *
16  */
17 INLINE DatagramOutputFile::
18 DatagramOutputFile() {
19  _error = false;
20  _wrote_first_datagram = false;
21  _out = nullptr;
22  _owns_out = false;
23 }
24 
25 /**
26  *
27  */
28 INLINE DatagramOutputFile::
29 ~DatagramOutputFile() {
30  close();
31 }
32 
33 /**
34  * Opens the indicated filename for writing. Returns true on success, false
35  * on failure.
36  */
37 INLINE bool DatagramOutputFile::
38 open(const Filename &filename) {
39  return open(new FileReference(filename));
40 }
41 
42 /**
43  * Returns the ostream represented by the output file.
44  */
45 INLINE std::ostream &DatagramOutputFile::
46 get_stream() {
47  static std::ofstream null_stream;
48  nassertr(_out != nullptr, null_stream);
49  return *_out;
50 }
Keeps a reference-counted pointer to a file on disk.
Definition: fileReference.h:26
bool open(const FileReference *file)
Opens the indicated filename for writing.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
void close()
Closes the file.