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

Function TryClassifyAsS4

src/openrct2/FileClassifier.cpp:129–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129static bool TryClassifyAsS4(IStream* stream, ClassifiedFileInfo* result)
130{
131 bool success = false;
132 uint64_t originalPosition = stream->GetPosition();
133 try
134 {
135 size_t dataLength = static_cast<size_t>(stream->GetLength());
136 auto data = stream->ReadArray<uint8_t>(dataLength);
137 stream->SetPosition(originalPosition);
138 int32_t fileTypeVersion = DetectFileType(data.get(), dataLength);
139
140 int32_t type = fileTypeVersion & FILE_TYPE_MASK;
141 int32_t version = fileTypeVersion & FILE_VERSION_MASK;
142
143 if (type == FILE_TYPE_SV4)
144 {
145 result->Type = FileType::savedGame;
146 result->Version = version;
147 success = true;
148 }
149 else if (type == FILE_TYPE_SC4)
150 {
151 result->Type = FileType::scenario;
152 result->Version = version;
153 success = true;
154 }
155 }
156 catch (const std::exception& e)
157 {
158 Console::Error::WriteLine(e.what());
159 }
160
161 stream->SetPosition(originalPosition);
162 return success;
163}
164
165static bool TryClassifyAsTD4_TD6(IStream* stream, ClassifiedFileInfo* result)
166{

Callers 1

TryClassifyFileFunction · 0.85

Calls 7

DetectFileTypeFunction · 0.85
WriteLineFunction · 0.85
getMethod · 0.65
GetPositionMethod · 0.45
GetLengthMethod · 0.45
SetPositionMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected