Skip to content

Use std::filesystem::path for Path #9205

@Ericson2314

Description

@Ericson2314

We currently have Path defined as std::string. This is kinda sloppy in general, but especially bad if we ever want to work on Windows.

We should instead use std::filesystem::path, which is the newish C++ standard Path type, and which does all the right things on all platforms.

Unfortunately, there isn't yet a std::filesystem::path_view. cplusplus/papers#406 will eventually fix this, but it is not yet stable and won't be for a while. This gives us two choices:

  1. Use https://github.com/ned14/llfio, which is pioneering what will hopefully be standardized as std::filesystem::path_view.
  2. Hand-roll our own PathView, which can be a small convenience around std::basic_string_view<Path::value_type> that has the missing implicit coercions.

I think (2) is the better first step; we can easily got from (2) to (1) later if we want.

Also per what @edolstra says before CanonPath should not change and we should also use it more. It would be for "internal" paths / paths in our SourcePath VFS we want almost all file access to go though. That means std::filesystem::path is just used for the lower level glue code with the OS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions