13 #include <sys/types.h> 22 #if defined( __FreeBSD__ ) 23 #define RESTINIO_FREEBSD_TARGET 24 #elif defined(__APPLE__) && defined( __MACH__ ) 25 #define RESTINIO_MACOS_TARGET 31 using file_descriptor_t =
int;
50 inline file_descriptor_t
53 #if defined( RESTINIO_FREEBSD_TARGET ) || defined( RESTINIO_MACOS_TARGET ) 54 file_descriptor_t file_descriptor = ::open( file_path, O_RDONLY );
56 file_descriptor_t file_descriptor = ::open( file_path, O_RDONLY | O_LARGEFILE );
62 RESTINIO_FMT_FORMAT_STRING(
"unable to openfile '{}': {}" ),
67 return file_descriptor;
84 inline file_descriptor_t
85 open_file(
const std::filesystem::path & file_path )
89 return open_file( file_path.c_str() );
93 template <
typename META >
103 #if defined( RESTINIO_FREEBSD_TARGET ) || defined( RESTINIO_MACOS_TARGET ) 124 #if defined( RESTINIO_MACOS_TARGET ) constexpr file_descriptor_t null_file_descriptor()
Get file descriptor which stands for null.
std::enable_if< std::is_same< Parameter_Container, query_string_params_t >::value||std::is_same< Parameter_Container, router::route_params_t >::value, std::optional< Value_Type > >::type opt_value(const Parameter_Container ¶ms, string_view_t key)
Gets the value of a parameter specified by key wrapped in std::optional<Value_Type> if parameter exis...
file_descriptor_t open_file(const std::filesystem::path &file_path)
Helper function that accepts std::filesystem::path.
void close_file(file_descriptor_t fd)
Close file by its descriptor.
META get_file_meta(file_descriptor_t fd)
Get file size.
file_descriptor_t open_file(const char *file_path)
Open file.