Skip to content

Feature request: Add std::filesystem::path overload for file_stdio::open #3092

Description

@Eelis

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<char const *>(mypath.u8string().c_str())? If so, that's not the most ergonomic API for opening a file specified by a std::filesystem::path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions