mirror of
https://github.com/NixOS/nix
synced 2025-07-06 05:01:48 +02:00
For example, instead of doing
#include "nix/store-config.hh"
#include "nix/derived-path.hh"
Now do
#include "nix/store/config.hh"
#include "nix/store/derived-path.hh"
This was originally planned in the issue, and also recent requested by
Eelco.
Most of the change is purely mechanical. There is just one small
additional issue. See how, in the example above, we took this
opportunity to also turn `<comp>-config.hh` into `<comp>/config.hh`.
Well, there was already a `nix/util/config.{cc,hh}`. Even though there
is not a public configuration header for libutil (which also would be
called `nix/util/config.{cc,hh}`) that's still confusing, To avoid any
such confusion, we renamed that to `nix/util/configuration.{cc,hh}`.
Finally, note that the libflake headers already did this, so we didn't
need to do anything to them. We wouldn't want to mistakenly get
`nix/flake/flake/flake.hh`!
Progress on #7876
(cherry picked from commit cc24766fa6
)
66 lines
1.7 KiB
C++
66 lines
1.7 KiB
C++
#include "nix/util/source-path.hh"
|
|
|
|
namespace nix {
|
|
|
|
std::string_view SourcePath::baseName() const
|
|
{ return path.baseName().value_or("source"); }
|
|
|
|
SourcePath SourcePath::parent() const
|
|
{
|
|
auto p = path.parent();
|
|
assert(p);
|
|
return {accessor, std::move(*p)};
|
|
}
|
|
|
|
std::string SourcePath::readFile() const
|
|
{ return accessor->readFile(path); }
|
|
|
|
bool SourcePath::pathExists() const
|
|
{ return accessor->pathExists(path); }
|
|
|
|
SourceAccessor::Stat SourcePath::lstat() const
|
|
{ return accessor->lstat(path); }
|
|
|
|
std::optional<SourceAccessor::Stat> SourcePath::maybeLstat() const
|
|
{ return accessor->maybeLstat(path); }
|
|
|
|
SourceAccessor::DirEntries SourcePath::readDirectory() const
|
|
{ return accessor->readDirectory(path); }
|
|
|
|
std::string SourcePath::readLink() const
|
|
{ return accessor->readLink(path); }
|
|
|
|
void SourcePath::dumpPath(
|
|
Sink & sink,
|
|
PathFilter & filter) const
|
|
{ return accessor->dumpPath(path, sink, filter); }
|
|
|
|
std::optional<std::filesystem::path> SourcePath::getPhysicalPath() const
|
|
{ return accessor->getPhysicalPath(path); }
|
|
|
|
std::string SourcePath::to_string() const
|
|
{ return accessor->showPath(path); }
|
|
|
|
SourcePath SourcePath::operator / (const CanonPath & x) const
|
|
{ return {accessor, path / x}; }
|
|
|
|
SourcePath SourcePath::operator / (std::string_view c) const
|
|
{ return {accessor, path / c}; }
|
|
|
|
bool SourcePath::operator==(const SourcePath & x) const noexcept
|
|
{
|
|
return std::tie(*accessor, path) == std::tie(*x.accessor, x.path);
|
|
}
|
|
|
|
std::strong_ordering SourcePath::operator<=>(const SourcePath & x) const noexcept
|
|
{
|
|
return std::tie(*accessor, path) <=> std::tie(*x.accessor, x.path);
|
|
}
|
|
|
|
std::ostream & operator<<(std::ostream & str, const SourcePath & path)
|
|
{
|
|
str << path.to_string();
|
|
return str;
|
|
}
|
|
|
|
}
|