MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / dumpLofTemps

Function dumpLofTemps

tools/dump_everything/dump_everything.cpp:1054–1088  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1052namespace fs = fs;
1053
1054static void dumpLofTemps(fs::path basePath, const UString &prefix)
1055{
1056 auto tabFileName = prefix + ".tab";
1057 auto datFileName = prefix + ".dat";
1058
1059 LogWarning("Reading LOFTEMPS \"%s\"", prefix);
1060 size_t tabSize = 0;
1061 {
1062 auto tabFile = fw().data->fs.open(tabFileName);
1063 if (!tabFile)
1064 {
1065 LogError("Failed to open LOFTEMPS tab \"%s\"", tabFileName);
1066 return;
1067 }
1068 tabSize = tabFile.size();
1069 }
1070 auto count = tabSize / 4;
1071
1072 auto outPath = basePath / prefix.str();
1073 fs::create_directories(outPath);
1074
1075 for (size_t i = 0; i < count; i++)
1076 {
1077 auto imgPath = format("LOFTEMPS:%s:%s:%u", datFileName, tabFileName, (unsigned)i);
1078 auto img = fw().data->loadImage(imgPath);
1079 if (!img)
1080 {
1081 LogError("Failed to load \"%s\"", imgPath);
1082 return;
1083 }
1084 auto outName = format("%u.png", (unsigned)i);
1085 auto filePath = outPath / outName.str();
1086 fw().data->writeImage(filePath.native(), img);
1087 }
1088}
1089
1090static void dumpRaw(fs::path outDir, const RawImage &i)
1091{

Callers 1

mainFunction · 0.85

Calls 5

formatFunction · 0.85
openMethod · 0.80
sizeMethod · 0.45
loadImageMethod · 0.45
writeImageMethod · 0.45

Tested by

no test coverage detected