Feature request: Add std::filesystem::path overload for file_stdio::open
- Dominant language
- C++
- Stars
- 4.8k
- Forks
- 694
- Avg merge
- 12h 48m
- Merged PRs (30d)
- 1
Description
`file_stdio::open` currently only accepts a `char const* path`. Recently I had a std::filesystem::path and wanted to call `file_stdio::open`, noticed that I had to do `mypath.c_str()` to make it compile, briefly thought "hm that's a bit weird", but it worked and I didn't think further about it.
Then a week later, I noticed my code no longer compiled on Windows, because there, `mypath.c_str()` returns `wchar_t const*`(!). For the time being I made the compiler shut up by doing `mypath.string().c_str()`, but I'm not even sure that's correct, and really, it just made me wonder why Beast is doing this to me. :-)
Update: I see `file_stdio::open` specifically requires UTF-8, so maybe I should be using `reinterpret_cast(mypath.u8string().c_str())`? If so, that's not the most ergonomic API for opening a file specified by a std::filesystem::path.
Contributor guide
Research direction
Search for the declaration and implementation of file_stdio::open, then read how its current char const* path argument handles UTF-8. Check the surrounding tests or call sites for platform-specific path behavior. Done means a std::filesystem::path can be passed ergonomically and works correctly on Windows and other supported platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100