2 * SPDX-License-Identifier: MIT
4 * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
11 #include "cpp-common/bt2s/make-unique.hpp"
12 #include "cpp-common/vendor/fmt/format.h"
16 ctf_fs_file::UP
ctf_fs_file_create(const bt2c::Logger
& parentLogger
)
18 return bt2s::make_unique
<ctf_fs_file
>(parentLogger
);
21 int ctf_fs_file_open(struct ctf_fs_file
*file
, const char *mode
)
26 BT_CPPLOGI_SPEC(file
->logger
, "Opening file \"{}\" with mode \"{}\"", file
->path
, mode
);
27 file
->fp
.reset(fopen(file
->path
.c_str(), mode
));
29 BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC(file
->logger
, "Cannot open file", ": path={}, mode={}",
34 BT_CPPLOGI_SPEC(file
->logger
, "Opened file: {}", fmt::ptr(file
->fp
));
36 if (fstat(fileno(file
->fp
.get()), &stat
)) {
37 BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC(file
->logger
, "Cannot get file information", ": path={}",
42 file
->size
= stat
.st_size
;
43 BT_CPPLOGI_SPEC(file
->logger
, "File is {} bytes", (intmax_t) file
->size
);
This page took 0.041788 seconds and 4 git commands to generate.