* Opens a file from inside a tar archive. * @param entry The entry to open. * @param[out] filesize If not \c nullptr, size of the opened file. * @return File handle of the opened file, or \c nullptr if the file is not available. * @note The file is read from within the tar file, and may not return \c EOF after reading the whole file. */
| 221 | * @note The file is read from within the tar file, and may not return \c EOF after reading the whole file. |
| 222 | */ |
| 223 | static std::optional<FileHandle> FioFOpenFileTar(const TarFileListEntry &entry, size_t *filesize) |
| 224 | { |
| 225 | auto f = FileHandle::Open(entry.tar_filename, "rb"); |
| 226 | if (!f.has_value()) return std::nullopt; |
| 227 | |
| 228 | if (fseek(*f, entry.position, SEEK_SET) < 0) { |
| 229 | return std::nullopt; |
| 230 | } |
| 231 | |
| 232 | if (filesize != nullptr) *filesize = entry.size; |
| 233 | return f; |
| 234 | } |
| 235 | |
| 236 | /** |
| 237 | * Opens a OpenTTD file somewhere in a personal or global directory. |
no outgoing calls
no test coverage detected