1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-11 13:06:01 +01:00
nix/src/libutil/file-path.hh
John Ericson 6c861b9c51 Factor out lookupExecutable and other PATH improvments
This ended up motivating a good deal of other infra improvements in
order to get Windows right:

- `OsString` to complement `std::filesystem::path`

- env var code for working with the underlying `OsString`s

- Rename `PATHNG_LITERAL` to `OS_STR`

- `NativePathTrait` renamed to `OsPathTrait`, given a character template
  parameter until #9205 is complete.

Split `tests.cc` matching split of `util.{cc,hh}` last year.

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-08-07 18:12:58 -04:00

47 lines
998 B
C++

#pragma once
///@file
#include <filesystem>
#include "types.hh"
#include "os-string.hh"
namespace nix {
/**
* Paths are just `std::filesystem::path`s.
*
* @todo drop `NG` suffix and replace the ones in `types.hh`.
*/
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
* future C++ standard.
*
* @todo drop `NG` suffix and replace the one in `types.hh`.
*/
struct PathViewNG : OsStringView
{
using string_view = OsStringView;
using string_view::string_view;
PathViewNG(const std::filesystem::path & path)
: OsStringView{path.native()}
{ }
PathViewNG(const OsString & path)
: OsStringView{path}
{ }
const string_view & native() const { return *this; }
string_view & native() { return *this; }
};
std::optional<std::filesystem::path> maybePath(PathView path);
std::filesystem::path pathNG(PathView path);
}