| 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 | { |
no test coverage detected