Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mio does not accept C++17 std::filesystem::path's for opening mapped files #72

Open
BullyWiiPlaza opened this issue Feb 7, 2021 · 1 comment

Comments

@BullyWiiPlaza
Copy link

BullyWiiPlaza commented Feb 7, 2021

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?

@DanielHerchenbach
Copy link

DanielHerchenbach commented May 25, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants