2 * SPDX-License-Identifier: MIT
4 * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
11 #include "cpp-common/vendor/fmt/format.h"
15 void ctf_fs_file_destroy(struct ctf_fs_file
*file
)
22 g_string_free(file
->path
, TRUE
);
28 void ctf_fs_file_deleter::operator()(ctf_fs_file
* const file
) noexcept
30 ctf_fs_file_destroy(file
);
33 ctf_fs_file::UP
ctf_fs_file_create(const bt2c::Logger
& parentLogger
)
35 ctf_fs_file::UP file
{new ctf_fs_file
{parentLogger
}};
37 file
->path
= g_string_new(NULL
);
51 int ctf_fs_file_open(struct ctf_fs_file
*file
, const char *mode
)
56 BT_CPPLOGI_SPEC(file
->logger
, "Opening file \"{}\" with mode \"{}\"", file
->path
->str
, mode
);
57 file
->fp
.reset(fopen(file
->path
->str
, mode
));
59 BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC(file
->logger
, "Cannot open file", ": path={}, mode={}",
60 file
->path
->str
, mode
);
64 BT_CPPLOGI_SPEC(file
->logger
, "Opened file: {}", fmt::ptr(file
->fp
));
66 if (fstat(fileno(file
->fp
.get()), &stat
)) {
67 BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC(file
->logger
, "Cannot get file information", ": path={}",
72 file
->size
= stat
.st_size
;
73 BT_CPPLOGI_SPEC(file
->logger
, "File is {} bytes", (intmax_t) file
->size
);
This page took 0.031153 seconds and 4 git commands to generate.