MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / FioFOpenFileTar

Function FioFOpenFileTar

src/fileio.cpp:223–234  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

221 * @note The file is read from within the tar file, and may not return \c EOF after reading the whole file.
222 */
223static 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.

Callers 2

FioFOpenFileFunction · 0.85
ExtractTarFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected