1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-27 04:30:59 +01:00

Before adjusting computeFSClosure

This commit is contained in:
Wouter den Breejen 2007-06-29 14:56:32 +00:00
parent b32691da2b
commit 7eb2f61797
5 changed files with 68 additions and 31 deletions

View file

@ -43,13 +43,13 @@ bool isStatePath(const Path & path)
void assertStorePath(const Path & path)
{
if (!isStorePath(path))
throw Error(format("component path `%1%' is not in the Nix store (1)") % path); //TODO bug: this prints an empty path ...
throw Error(format("component path `%1%' is not in the Nix store") % path);
}
void assertStatePath(const Path & path)
{
if (!isStatePath(path))
throw Error(format("state path `%1%' is not in the Nix state-store (1)") % path); //TODO bug: this prints an empty path ...
throw Error(format("state path `%1%' is not in the Nix state-store") % path);
}
@ -64,6 +64,26 @@ Path toStorePath(const Path & path)
return Path(path, 0, slash);
}
Path toStoreOrStatePath(const Path & path)
{
bool isStorePath = isInStore(path);
bool isStateStore = isInStateStore(path);
if (!isStorePath && !isStateStore)
throw Error(format("path `%1%' is not in the Nix store or Nix state store") % path);
Path::size_type slash;
if(isStorePath)
slash = path.find('/', nixStore.size() + 1);
else
slash = path.find('/', nixStoreState.size() + 1);
if (slash == Path::npos)
return path;
else
return Path(path, 0, slash);
}
void checkStoreName(const string & name)
{