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

Function TryClassifyAsS6

src/openrct2/FileClassifier.cpp:101–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101static bool TryClassifyAsS6(IStream* stream, ClassifiedFileInfo* result)
102{
103 bool success = false;
104 uint64_t originalPosition = stream->GetPosition();
105 try
106 {
107 auto chunkReader = SawyerChunkReader(stream);
108 auto s6Header = chunkReader.ReadChunkAs<RCT2::S6Header>();
109 if (s6Header.Type == S6_TYPE_SAVEDGAME)
110 {
111 result->Type = FileType::savedGame;
112 }
113 else if (s6Header.Type == S6_TYPE_SCENARIO)
114 {
115 result->Type = FileType::scenario;
116 }
117 result->Version = s6Header.Version;
118 success = true;
119 }
120 catch (const std::exception& e)
121 {
122 // Exceptions are likely to occur if file is not S6 format
123 LOG_VERBOSE(e.what());
124 }
125 stream->SetPosition(originalPosition);
126 return success;
127}
128
129static bool TryClassifyAsS4(IStream* stream, ClassifiedFileInfo* result)
130{

Callers 1

TryClassifyFileFunction · 0.85

Calls 4

SawyerChunkReaderClass · 0.85
GetPositionMethod · 0.45
whatMethod · 0.45
SetPositionMethod · 0.45

Tested by

no test coverage detected