mio
mio copied to clipboard
mio does not accept C++17 std::filesystem::path's for opening mapped files
A small improvement suggestion I have is that mio
does not accept an object of type std::filesystem::path
for mapped file paths:
const std::filesystem::path file_path = "...";
mio::mmap_source mapped_file(file_path); // Will not compile
The filesystem
library was added since C++17
.
Of course, you could just write the following right now and be all set:
const std::filesystem::path file_path = "...";
mio::mmap_source mapped_file(file_path.string());
But proper std::filesystem::path
argument support would be nicer overall.
The README
says that this is a C++11
library but moving forward and upgrading it to a C++17
library wouldn't hurt, would it?
I agree. If I am not mistaken, under Windows this would also drastically simplify support of unicode characters in the file path.
Under C++17, a path can be created from an utf8-encoded string by using
std::filesystem::path myPath = std::filesystem::u8path(u8"äßçdé.txt")
.
All that is needed then is one single line:
CreateFileW(myPath.wstring().c_str(), ... // use unicode version of fct'CreateFileW' and pass a wide character string