1// LAF Base Library
2// Copyright (c) 2020 Igara Studio S.A.
3// Copyright (c) 2001-2018 David Capello
4//
5// This file is released under the terms of the MIT license.
6// Read LICENSE.txt for more information.
7
8#ifndef BASE_FILE_HANDLE_H_INCLUDED
9#define BASE_FILE_HANDLE_H_INCLUDED
10#pragma once
11
12#include <cstdio>
13#include <memory>
14#include <string>
15
16namespace base {
17
18 using FileHandle = std::shared_ptr<FILE>;
19
20 FILE* open_file_raw(const std::string& filename, const std::string& mode);
21 FileHandle open_file(const std::string& filename, const std::string& mode);
22 FileHandle open_file_with_exception(const std::string& filename, const std::string& mode);
23 FileHandle open_file_with_exception_sync_on_close(const std::string& filename, const std::string& mode);
24 int open_file_descriptor_with_exception(const std::string& filename, const std::string& mode);
25 void sync_file_descriptor(int fd);
26 void close_file_and_sync(FILE* file);
27
28}
29
30#endif
31