mirror of
https://github.com/NixOS/nix.git
synced 2025-11-14 22:42:41 +01:00
Move some MixStoreDirMethods members to the right .cc file
I had not wanted to cause unncessary churn before, but now that we've bitten the bullet with the Big Reformat, I feel it is the right time. Future readers will appreciate that the declarations and definitions files are one-to-one as they should be, and `store-api.cc` is good to shrink in any event. I don't think there are outstanding PRs changing this code either. (I had some for a while, but they are all merged.)
This commit is contained in:
parent
9ff4c446df
commit
e07440665c
3 changed files with 170 additions and 168 deletions
|
|
@ -74,58 +74,4 @@ StorePath StorePath::random(std::string_view name)
|
|||
return StorePath(Hash::random(HashAlgorithm::SHA1), name);
|
||||
}
|
||||
|
||||
StorePath MixStoreDirMethods::parseStorePath(std::string_view path) const
|
||||
{
|
||||
// On Windows, `/nix/store` is not a canonical path. More broadly it
|
||||
// is unclear whether this function should be using the native
|
||||
// notion of a canonical path at all. For example, it makes to
|
||||
// support remote stores whose store dir is a non-native path (e.g.
|
||||
// Windows <-> Unix ssh-ing).
|
||||
auto p =
|
||||
#ifdef _WIN32
|
||||
path
|
||||
#else
|
||||
canonPath(std::string(path))
|
||||
#endif
|
||||
;
|
||||
if (dirOf(p) != storeDir)
|
||||
throw BadStorePath("path '%s' is not in the Nix store", p);
|
||||
return StorePath(baseNameOf(p));
|
||||
}
|
||||
|
||||
std::optional<StorePath> MixStoreDirMethods::maybeParseStorePath(std::string_view path) const
|
||||
{
|
||||
try {
|
||||
return parseStorePath(path);
|
||||
} catch (Error &) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
bool MixStoreDirMethods::isStorePath(std::string_view path) const
|
||||
{
|
||||
return (bool) maybeParseStorePath(path);
|
||||
}
|
||||
|
||||
StorePathSet MixStoreDirMethods::parseStorePathSet(const PathSet & paths) const
|
||||
{
|
||||
StorePathSet res;
|
||||
for (auto & i : paths)
|
||||
res.insert(parseStorePath(i));
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string MixStoreDirMethods::printStorePath(const StorePath & path) const
|
||||
{
|
||||
return (storeDir + "/").append(path.to_string());
|
||||
}
|
||||
|
||||
PathSet MixStoreDirMethods::printStorePathSet(const StorePathSet & paths) const
|
||||
{
|
||||
PathSet res;
|
||||
for (auto & i : paths)
|
||||
res.insert(printStorePath(i));
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace nix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue