MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / DoSaveMap

Function DoSaveMap

src/Menus.c:1354–1388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1352}
1353
1354static cc_result DoSaveMap(const cc_string* path, struct GZipState* state) {
1355 static const cc_string schematic = String_FromConst(".schematic");
1356 static const cc_string mine = String_FromConst(".mine");
1357 struct Stream stream, compStream;
1358 cc_filepath raw_path;
1359 cc_result res;
1360
1361 Platform_EncodePath(&raw_path, path);
1362 res = Stream_CreatePath(&stream, &raw_path);
1363 if (res) { Logger_IOWarn2(res, "creating", &raw_path); return res; }
1364
1365 GZip_MakeStream(&compStream, state, &stream);
1366
1367 if (String_CaselessEnds(path, &schematic)) {
1368 res = Schematic_Save(&compStream);
1369 } else if (String_CaselessEnds(path, &mine)) {
1370 res = Dat_Save(&compStream);
1371 } else {
1372 res = Cw_Save(&compStream);
1373 }
1374
1375 if (res) {
1376 stream.Close(&stream);
1377 Logger_IOWarn2(res, "encoding", &raw_path); return res;
1378 }
1379
1380 if ((res = compStream.Close(&compStream))) {
1381 stream.Close(&stream);
1382 Logger_IOWarn2(res, "closing", &raw_path); return res;
1383 }
1384
1385 res = stream.Close(&stream);
1386 if (res) { Logger_IOWarn2(res, "closing", &raw_path); return res; }
1387 return 0;
1388}
1389
1390static cc_result SaveLevelScreen_SaveMap(const cc_string* path) {
1391 struct GZipState* state;

Callers 1

SaveLevelScreen_SaveMapFunction · 0.85

Calls 8

Stream_CreatePathFunction · 0.85
Logger_IOWarn2Function · 0.85
GZip_MakeStreamFunction · 0.85
String_CaselessEndsFunction · 0.85
Schematic_SaveFunction · 0.85
Dat_SaveFunction · 0.85
Cw_SaveFunction · 0.85
Platform_EncodePathFunction · 0.70

Tested by

no test coverage detected