MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / GetIndexFromPath

Method GetIndexFromPath

src/openrct2/core/Zip.cpp:44–60  ·  view source on GitHub ↗

* Normalises both the given path and the stored paths and finds the first match. */

Source from the content-addressed store, hash-verified

42 * Normalises both the given path and the stored paths and finds the first match.
43 */
44std::optional<size_t> IZipArchive::GetIndexFromPath(std::string_view path) const
45{
46 auto normalisedPath = NormalisePath(path);
47 if (!normalisedPath.empty())
48 {
49 auto numFiles = GetNumFiles();
50 for (size_t i = 0; i < numFiles; i++)
51 {
52 auto normalisedZipPath = NormalisePath(GetFileName(i));
53 if (normalisedZipPath == normalisedPath)
54 {
55 return i;
56 }
57 }
58 }
59 return std::nullopt;
60}
61
62bool IZipArchive::Exists(std::string_view path) const
63{

Callers 1

GetSizeMethod · 0.80

Calls 3

NormalisePathFunction · 0.85
GetFileNameFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected