MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / createDataInStream

Method createDataInStream

src/common/FileManager.cpp:82–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80
81
82std::istream* FileManager::createDataInStream(const std::string& filename,
83 bool binary) const {
84 // choose open mode
85 std::ios::openmode mode = std::ios::in;
86 if (binary) {
87 mode |= std::ios::binary;
88 }
89
90 std::ifstream* stream = NULL;
91
92 const bool relative = !isAbsolute(filename);
93
94 if (relative) {
95 // try directory stored in DB
96 if (BZDB.isSet("directory")) {
97 stream = getInStream(catPath(BZDB.get("directory"), filename), mode);
98 if (stream) {
99 return stream;
100 }
101 }
102
103 // try data directory
104 stream = getInStream(catPath("data", filename), mode);
105 if (stream) {
106 return stream;
107 }
108 }
109
110 // try current directory (or absolute path)
111 stream = getInStream(filename, mode);
112 if (stream) {
113 return stream;
114 }
115
116 // try install directory
117#if defined(BZFLAG_DATA)
118 if (relative) {
119 stream = getInStream(catPath(BZFLAG_DATA, filename), mode);
120 if (stream) {
121 return stream;
122 }
123 }
124#endif
125
126 return NULL;
127}
128
129
130std::ostream* FileManager::createDataOutStream(const std::string& filename,

Callers 4

isCachedMethod · 0.80
loadCachedMethod · 0.80
readMethod · 0.80
loadFromFileMethod · 0.80

Calls 3

getInStreamFunction · 0.85
isSetMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected