mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 13:06:01 +01:00
Use std::filesystem::path in more places (#10657)
Progress on #9205 Co-Authored-By: John Ericson <John.Ericson@Obsidian.Systems> * Get rid of `PathNG`, just use `std::filesystem::path`
This commit is contained in:
parent
9ae6455b0e
commit
fcbc36cf78
13 changed files with 104 additions and 82 deletions
|
|
@ -13,9 +13,8 @@ namespace nix {
|
|||
*
|
||||
* @todo drop `NG` suffix and replace the ones in `types.hh`.
|
||||
*/
|
||||
typedef std::filesystem::path PathNG;
|
||||
typedef std::list<Path> PathsNG;
|
||||
typedef std::set<Path> PathSetNG;
|
||||
typedef std::list<std::filesystem::path> PathsNG;
|
||||
typedef std::set<std::filesystem::path> PathSetNG;
|
||||
|
||||
/**
|
||||
* Stop gap until `std::filesystem::path_view` from P1030R6 exists in a
|
||||
|
|
@ -23,18 +22,18 @@ typedef std::set<Path> PathSetNG;
|
|||
*
|
||||
* @todo drop `NG` suffix and replace the one in `types.hh`.
|
||||
*/
|
||||
struct PathViewNG : std::basic_string_view<PathNG::value_type>
|
||||
struct PathViewNG : std::basic_string_view<std::filesystem::path::value_type>
|
||||
{
|
||||
using string_view = std::basic_string_view<PathNG::value_type>;
|
||||
using string_view = std::basic_string_view<std::filesystem::path::value_type>;
|
||||
|
||||
using string_view::string_view;
|
||||
|
||||
PathViewNG(const PathNG & path)
|
||||
: std::basic_string_view<PathNG::value_type>(path.native())
|
||||
PathViewNG(const std::filesystem::path & path)
|
||||
: std::basic_string_view<std::filesystem::path::value_type>(path.native())
|
||||
{ }
|
||||
|
||||
PathViewNG(const PathNG::string_type & path)
|
||||
: std::basic_string_view<PathNG::value_type>(path)
|
||||
PathViewNG(const std::filesystem::path::string_type & path)
|
||||
: std::basic_string_view<std::filesystem::path::value_type>(path)
|
||||
{ }
|
||||
|
||||
const string_view & native() const { return *this; }
|
||||
|
|
@ -43,10 +42,19 @@ struct PathViewNG : std::basic_string_view<PathNG::value_type>
|
|||
|
||||
std::string os_string_to_string(PathViewNG::string_view path);
|
||||
|
||||
PathNG::string_type string_to_os_string(std::string_view s);
|
||||
std::filesystem::path::string_type string_to_os_string(std::string_view s);
|
||||
|
||||
std::optional<PathNG> maybePathNG(PathView path);
|
||||
std::optional<std::filesystem::path> maybePath(PathView path);
|
||||
|
||||
PathNG pathNG(PathView path);
|
||||
std::filesystem::path pathNG(PathView path);
|
||||
|
||||
/**
|
||||
* Create string literals with the native character width of paths
|
||||
*/
|
||||
#ifndef _WIN32
|
||||
# define PATHNG_LITERAL(s) s
|
||||
#else
|
||||
# define PATHNG_LITERAL(s) L ## s
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue