| 1352 | } |
| 1353 | |
| 1354 | static 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 | |
| 1390 | static cc_result SaveLevelScreen_SaveMap(const cc_string* path) { |
| 1391 | struct GZipState* state; |
no test coverage detected