BT_CPPLOGE_ERRNO_SPEC(ds_file->logger, "Cannot memory-unmap file",
": address={}, size={}, file_path=\"{}\", file={}",
fmt::ptr(ds_file->mmap_addr), ds_file->mmap_len,
- ds_file->file ? ds_file->file->path->str : "NULL",
+ ds_file->file ? ds_file->file->path : "NULL",
ds_file->file ? fmt::ptr(ds_file->file->fp) : NULL);
status = CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
goto end;
BT_ASSERT(ds_file->mmap_len > 0);
ds_file->mmap_addr =
- bt_mmap(ds_file->mmap_len, PROT_READ, MAP_PRIVATE, fileno(ds_file->file->fp),
+ bt_mmap(ds_file->mmap_len, PROT_READ, MAP_PRIVATE, fileno(ds_file->file->fp.get()),
ds_file->mmap_offset_in_file, static_cast<int>(ds_file->logger.level()));
if (ds_file->mmap_addr == MAP_FAILED) {
BT_CPPLOGE_SPEC(ds_file->logger,
"Cannot memory-map address (size {}) of file \"{}\" ({}) at offset {}: {}",
- ds_file->mmap_len, ds_file->file->path->str, fmt::ptr(ds_file->file->fp),
+ ds_file->mmap_len, ds_file->file->path, fmt::ptr(ds_file->file->fp),
(intmax_t) ds_file->mmap_offset_in_file, strerror(errno));
status = CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
goto end;
if (remaining_mmap_bytes(ds_file) == 0) {
/* Are we at the end of the file? */
if (ds_file->mmap_offset_in_file >= ds_file->file->size) {
- BT_CPPLOGD_SPEC(ds_file->logger, "Reached end of file \"{}\" ({})",
- ds_file->file->path->str, fmt::ptr(ds_file->file->fp));
+ BT_CPPLOGD_SPEC(ds_file->logger, "Reached end of file \"{}\" ({})", ds_file->file->path,
+ fmt::ptr(ds_file->file->fp));
status = CTF_MSG_ITER_MEDIUM_STATUS_EOF;
goto end;
}
goto end;
default:
BT_CPPLOGE_SPEC(ds_file->logger, "Cannot memory-map next region of file \"{}\" ({})",
- ds_file->file->path->str, fmt::ptr(ds_file->file->fp));
+ ds_file->file->path, fmt::ptr(ds_file->file->fp));
goto error;
}
}
bt_stream_class *ds_file_stream_class;
bt_stream *stream = NULL;
- ds_file_stream_class = bt_stream_borrow_class(ds_file->stream);
+ ds_file_stream_class = ds_file->stream->cls().libObjPtr();
if (stream_class != ds_file_stream_class) {
/*
goto end;
}
- stream = ds_file->stream;
+ stream = ds_file->stream->libObjPtr();
end:
return stream;
BT_ASSERT(index_entry);
/* Check if that file is already the one mapped. */
- if (!data->file || strcmp(index_entry->path, data->file->file->path->str) != 0) {
+ if (!data->file || data->file->file->path != index_entry->path) {
/* Destroy the previously used file. */
ctf_fs_ds_file_destroy(data->file);
/* Create the new file. */
- data->file = ctf_fs_ds_file_create(data->ds_file_group->ctf_fs_trace,
- data->ds_file_group->stream->libObjPtr(),
- index_entry->path, data->logger);
+ data->file =
+ ctf_fs_ds_file_create(data->ds_file_group->ctf_fs_trace, data->ds_file_group->stream,
+ index_entry->path, data->logger);
if (!data->file) {
BT_CPPLOGE_APPEND_CAUSE_SPEC(data->logger, "failed to create ctf_fs_ds_file.");
status = CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
uint32_t version_major, version_minor;
BT_CPPLOGI_SPEC(ds_file->logger, "Building index from .idx file of stream file {}",
- ds_file->file->path->str);
+ ds_file->file->path);
ret = ctf_msg_iter_get_packet_properties(msg_iter, &props);
if (ret) {
BT_CPPLOGI_STR_SPEC(ds_file->logger,
}
/* Look for index file in relative path index/name.idx. */
- basename = g_path_get_basename(ds_file->file->path->str);
+ basename = g_path_get_basename(ds_file->file->path.c_str());
if (!basename) {
BT_CPPLOGE_SPEC(ds_file->logger, "Cannot get the basename of datastream file {}",
- ds_file->file->path->str);
+ ds_file->file->path);
goto error;
}
- directory = g_path_get_dirname(ds_file->file->path->str);
+ directory = g_path_get_dirname(ds_file->file->path.c_str());
if (!directory) {
BT_CPPLOGE_SPEC(ds_file->logger, "Cannot get dirname of datastream file {}",
- ds_file->file->path->str);
+ ds_file->file->path);
goto error;
}
enum ctf_msg_iter_status iter_status = CTF_MSG_ITER_STATUS_OK;
auto currentPacketOffset = bt2c::DataLen::fromBytes(0);
- BT_CPPLOGI_SPEC(ds_file->logger, "Indexing stream file {}", ds_file->file->path->str);
+ BT_CPPLOGI_SPEC(ds_file->logger, "Indexing stream file {}", ds_file->file->path);
index = ctf_fs_ds_index_create();
if (!index) {
"Invalid packet size reported in file: stream=\"{}\", "
"packet-offset-bytes={}, packet-size-bytes={}, "
"file-size-bytes={}",
- ds_file->file->path->str, currentPacketOffset.bytes(),
+ ds_file->file->path, currentPacketOffset.bytes(),
currentPacketSize.bytes(), ds_file->file->size);
goto error;
}
goto end;
}
-struct ctf_fs_ds_file *ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace, bt_stream *stream,
- const char *path, const bt2c::Logger& parentLogger)
+struct ctf_fs_ds_file *ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace,
+ bt2::Stream::Shared stream, const char *path,
+ const bt2c::Logger& parentLogger)
{
int ret;
size_t offset_align;
goto error;
}
- ds_file->stream = stream;
- bt_stream_get_ref(ds_file->stream);
+ ds_file->stream = std::move(stream);
ds_file->metadata = ctf_fs_trace->metadata;
- g_string_assign(ds_file->file->path, path);
- ret = ctf_fs_file_open(ds_file->file, "rb");
+ ds_file->file->path = path;
+ ret = ctf_fs_file_open(ds_file->file.get(), "rb");
if (ret) {
goto error;
}
return;
}
- bt_stream_put_ref(ds_file->stream);
(void) ds_file_munmap(ds_file);
- if (ds_file->file) {
- ctf_fs_file_destroy(ds_file->file);
- }
-
delete ds_file;
}