MCPcopy Create free account
hub / github.com/diasurgical/devilution / Open

Method Open

Source/mpqapi.cpp:164–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162 _BLOCKENTRY *sgpBlockTbl;
163
164 bool Open(const char *name)
165 {
166 Close();
167#ifdef _DEBUG
168 SDL_Log("Opening %s", name);
169#endif
170 exists = FileExists(name);
171 std::ios::openmode mode = std::ios::in | std::ios::out | std::ios::binary;
172 if (exists) {
173 if (GetFileSize(name, &size) == 0) {
174 SDL_Log("GetFileSize(\"%s\") failed with \"%s\"", name, std::strerror(errno));
175 return false;
176#ifdef _DEBUG
177 } else {
178 SDL_Log("GetFileSize(\"%s\") = %" PRIuMAX, name, size);
179#endif
180 }
181 } else {
182 mode |= std::ios::trunc;
183 }
184 if (!stream.Open(name, mode)) {
185 stream.Close();
186 return false;
187 }
188 modified = !exists;
189
190 this->name = name;
191 return true;
192 }
193
194 bool Close(bool clear_tables = true)
195 {

Callers 1

OpenMPQFunction · 0.45

Calls 4

SDL_LogFunction · 0.85
FileExistsFunction · 0.85
GetFileSizeFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected