| 454 | } |
| 455 | |
| 456 | void StoreSession::save_dso(pv::data::DsoSnapshot *dso_snapshot) |
| 457 | { |
| 458 | char chunk_name[20] = {0}; |
| 459 | int ret = SR_ERR; |
| 460 | |
| 461 | uint64_t size = dso_snapshot->get_sample_count(); |
| 462 | int ch_num = dso_snapshot->get_channel_num(); |
| 463 | _unit_count = size * ch_num; |
| 464 | |
| 465 | for(auto s : _session->get_signals()) |
| 466 | { |
| 467 | if (s->get_type() == SR_CHANNEL_DSO) { |
| 468 | int ch_index = s->get_index(); |
| 469 | |
| 470 | if (!dso_snapshot->has_data(ch_index)) |
| 471 | continue; |
| 472 | |
| 473 | if (_canceled) |
| 474 | break; |
| 475 | |
| 476 | const uint8_t *data_buffer = dso_snapshot->get_samples(0, 0, ch_index); |
| 477 | |
| 478 | snprintf(chunk_name, 19, "O-%d/0", ch_index); |
| 479 | ret = m_zipDoc.AddFromBuffer(chunk_name, (const char*)data_buffer, size) ? SR_OK : -1; |
| 480 | |
| 481 | if (ret != SR_OK) { |
| 482 | if (!_has_error) { |
| 483 | _has_error = true; |
| 484 | _error = L_S(STR_PAGE_DLG, S_ID(IDS_MSG_STORESESS_SAVEPROC_ERROR2), |
| 485 | "Failed to create zip file. Please check write permission of this path."); |
| 486 | } |
| 487 | progress_updated(); |
| 488 | if (_has_error) |
| 489 | QFile::remove(_file_name); |
| 490 | return; |
| 491 | } |
| 492 | |
| 493 | _units_stored += size; |
| 494 | progress_updated(); |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | progress_updated(); |
| 499 | |
| 500 | if (_canceled || size == 0 || ch_num == 0){ |
| 501 | QFile::remove(_file_name); |
| 502 | } |
| 503 | else { |
| 504 | bool bret = m_zipDoc.Close(); |
| 505 | m_zipDoc.Release(); |
| 506 | |
| 507 | if (!bret){ |
| 508 | _has_error = true; |
| 509 | _error = m_zipDoc.GetError(); |
| 510 | } |
| 511 | } |
| 512 | } |
| 513 |
nothing calls this directly
no test coverage detected