19#if defined(RESTINIO_ASIO_HAS_WINDOWS_OVERLAPPED_PTR)
59 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
67 file_path, GetLastError() )
71 return file_descriptor;
89open_file(
const std::filesystem::path & file_path )
91 const auto wide_file_path = file_path.wstring();
95 wide_file_path.c_str(),
100 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
113 "open_file(std::filesystem::path) "
114 "unable to openfile: error({})" ),
119 return file_descriptor;
124template <
typename META >
130 std::chrono::system_clock::time_point flastmodified;
134 LARGE_INTEGER file_size;
136 if( GetFileSizeEx( fd, &file_size ) )
138 fsize =
static_cast< file_size_t >( file_size.QuadPart );
145 "unable to get file size: error code:{}" ),
151 if( GetFileTime( fd, NULL, NULL, &ftWrite ) )
156 constexpr std::uint64_t nanosec100_in_microsec = 10;
157 constexpr std::uint64_t epoch_difference_in_microsec =
158 11644473600ULL * 1000 *1000;
163 ull.LowPart = ftWrite.dwLowDateTime;
164 ull.HighPart = ftWrite.dwHighDateTime;
167 std::chrono::system_clock::time_point{
168 std::chrono::microseconds(
169 ull.QuadPart / nanosec100_in_microsec - epoch_difference_in_microsec ) };
176 "unable to get file last modification: error code:{}" ),
182 return META{ fsize, flastmodified};
Exception class for all exceptions thrown by RESTinio.
#define RESTINIO_FMT_FORMAT_STRING(s)
constexpr file_descriptor_t null_file_descriptor()
Get file descriptor which stands for null.
void close_file(file_descriptor_t fd)
Close file by its descriptor.
file_descriptor_t open_file(const char *file_path)
Open file.
std::FILE * file_descriptor_t
std::int64_t file_offset_t
META get_file_meta(file_descriptor_t fd)
Get file size.
std::uint64_t file_size_t