Wrap fclose to avoid compiler warnings

This commit is contained in:
Frédéric Mangano 2024-11-01 10:20:49 +09:00
parent d9b051210b
commit 3293647e8f
2 changed files with 10 additions and 2 deletions

View File

@ -119,13 +119,16 @@ using byte_string_view = std::basic_string_view<uint8_t>;
* \{
*/
/** fclose wrapper for std::unique_ptrs deleter. */
void close_file(FILE*);
/**
* Smart auto-closing FILE* handle.
*
* It implictly converts from an already opened FILE*.
*/
struct file : std::unique_ptr<FILE, decltype(&fclose)> {
file(FILE* f = nullptr) : std::unique_ptr<FILE, decltype(&fclose)>(f, &fclose) {}
struct file : std::unique_ptr<FILE, decltype(&close_file)> {
file(FILE* f = nullptr) : std::unique_ptr<FILE, decltype(&close_file)>(f, &close_file) {}
};
/**

View File

@ -29,6 +29,11 @@ ot::byte_string_view operator""_bsv(const char* data, size_t size)
return ot::byte_string_view(reinterpret_cast<const uint8_t*>(data), size);
}
void ot::close_file(FILE* file)
{
fclose(file);
}
void ot::partial_file::open(const char* destination)
{
final_name = destination;