void SaveCbdbFile() { if (stream == null) { return; } stream.Close(); stream = null; string dumpPath = BlockDBFile.DumpPath(mapName); string filePath = BlockDBFile.FilePath(mapName); if (File.Exists(filePath)) { File.Delete(filePath); } File.Move(dumpPath, filePath); }
object DumpRow(IDataRecord record, object arg) { if (errorOccurred) { return(arg); } try { if (stream == null) { stream = File.Create(BlockDBFile.DumpPath(mapName)); string lvlPath = LevelInfo.MapPath(mapName); dims = IMapImporter.Formats[0].ReadDimensions(lvlPath); BlockDBFile.WriteHeader(stream, dims); } // Only log maps which have a used BlockDB to avoid spam entriesWritten++; if (entriesWritten == 10) { string progress = " (" + DBUpgrader.Progress + ")"; Logger.Log(LogType.SystemActivity, "Dumping BlockDB for " + mapName + progress); } UpdateBlock(record); UpdateCoords(record); UpdatePlayerID(record); UpdateTimestamp(record); buffer.Add(entry); WriteBuffer(false); } catch (Exception ex) { Logger.LogError(ex); errorOccurred = true; } return(arg); }