3 * Copyright (c) 2022 Francis Deslauriers <francis.deslauriers@efficios.com>
5 * SPDX-License-Identifier: MIT
10 #include "file-utils.hpp"
14 std::vector
<std::uint8_t> dataFromFile(const char * const filePath
)
17 * Open a file stream and seek to the end of the stream to compute the size
18 * of the buffer required.
20 std::ifstream file
{filePath
, std::ios::binary
| std::ios::ate
};
23 throw NoSuchFileOrDirectoryError
{};
26 const auto size
= file
.tellg();
27 std::vector
<uint8_t> buffer(static_cast<std::size_t>(size
));
30 * Seek the reading head back at the beginning of the stream to actually
33 file
.seekg(0, std::ios::beg
);
34 file
.read(reinterpret_cast<char *>(buffer
.data()), size
);
38 } /* namespace bt2c */