mirror of
https://github.com/NixOS/nix
synced 2025-06-29 06:21:14 +02:00
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>
This commit is contained in:
parent
0836888002
commit
6c861b9c51
32 changed files with 616 additions and 97 deletions
|
@ -9,4 +9,14 @@ int setEnv(const char * name, const char * value)
|
|||
return ::setenv(name, value, 1);
|
||||
}
|
||||
|
||||
std::optional<std::string> getEnvOs(const std::string & key)
|
||||
{
|
||||
return getEnv(key);
|
||||
}
|
||||
|
||||
int setEnvOs(const OsString & name, const OsString & value)
|
||||
{
|
||||
return setEnv(name.c_str(), value.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,16 +8,6 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
std::string os_string_to_string(PathViewNG::string_view path)
|
||||
{
|
||||
return std::string { path };
|
||||
}
|
||||
|
||||
std::filesystem::path::string_type string_to_os_string(std::string_view s)
|
||||
{
|
||||
return std::string { s };
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> maybePath(PathView path)
|
||||
{
|
||||
return { path };
|
||||
|
|
|
@ -4,6 +4,7 @@ sources += files(
|
|||
'file-path.cc',
|
||||
'file-system.cc',
|
||||
'muxable-pipe.cc',
|
||||
'os-string.cc',
|
||||
'processes.cc',
|
||||
'signals.cc',
|
||||
'users.cc',
|
||||
|
|
21
src/libutil/unix/os-string.cc
Normal file
21
src/libutil/unix/os-string.cc
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include <algorithm>
|
||||
#include <codecvt>
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
|
||||
#include "file-path.hh"
|
||||
#include "util.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
std::string os_string_to_string(PathViewNG::string_view path)
|
||||
{
|
||||
return std::string{path};
|
||||
}
|
||||
|
||||
std::filesystem::path::string_type string_to_os_string(std::string_view s)
|
||||
{
|
||||
return std::string{s};
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue