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

Method FindFile

src/openrct2/PlatformEnvironment.cpp:162–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160 }
161
162 u8string FindFile(DirBase base, DirId did, u8string_view fileName) const override
163 {
164 auto dataPath = GetDirectoryPath(base, did);
165
166 std::string alternativeFilename;
167 if (_rct2Variant != RCT2Variant::rct2Original && base == DirBase::rct2 && did == DirId::data)
168 {
169 // Special case, handle RCT Classic css ogg files
170 if (String::startsWith(fileName, "css", true) && String::endsWith(fileName, ".dat", true))
171 {
172 alternativeFilename = fileName.substr(0, fileName.size() - 3);
173 alternativeFilename.append("ogg");
174 fileName = alternativeFilename;
175 }
176 }
177
178 auto path = Path::ResolveCasing(Path::Combine(dataPath, fileName));
179 if (base == DirBase::rct1 && did == DirId::data && !File::Exists(path))
180 {
181 // Special case, handle RCT1 steam layout where some data files are under a CD root
182 auto basePath = GetDirectoryPath(base);
183 auto alternativePath = Path::ResolveCasing(Path::Combine(basePath, "RCTdeluxe_install", "Data", fileName));
184 if (File::Exists(alternativePath))
185 {
186 path = alternativePath;
187 }
188 }
189
190 return path;
191 }
192
193 void SetBasePath(DirBase base, u8string_view path) override
194 {

Callers 4

ImportMegaParkMethod · 0.80
GfxLoadG1Function · 0.80
GetAssetMethod · 0.80
ParseSourceMethod · 0.80

Calls 7

startsWithFunction · 0.85
endsWithFunction · 0.85
ExistsFunction · 0.85
appendMethod · 0.80
ResolveCasingFunction · 0.50
CombineFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected