diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-02-07 14:32:44 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-02-07 14:32:44 +0000 |
commit | fbc434ee4c39e7516f3634371442899864786584 (patch) | |
tree | 9ea7e2d90f78fa6b100c35c135822b984c408882 /src/libstore/store.cc | |
parent | 450c358e2055488897349bf50951cce16ad9bc90 (diff) |
* `nix-store -qb' to query derivation environment bindings. Useful
for finding build-time dependencies (possibly after a build). E.g.,
$ nix-store -qb aterm $(nix-store -qd $(which strc))
/nix/store/jw7c7s65n1gwhxpn35j9rgcci6ilzxym-aterm-2.3.1
* Arguments to nix-store can be files within store objects, e.g.,
/nix/store/jw7c...-aterm-2.3.1/bin/baffle.
* Idem for garbage collector roots.
Diffstat (limited to 'src/libstore/store.cc')
-rw-r--r-- | src/libstore/store.cc | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/libstore/store.cc b/src/libstore/store.cc index a3e98f696..693a388b3 100644 --- a/src/libstore/store.cc +++ b/src/libstore/store.cc @@ -176,12 +176,18 @@ void copyPath(const Path & src, const Path & dst) } -bool isStorePath(const Path & path) +bool isInStore(const Path & path) { return path[0] == '/' && path.compare(0, nixStore.size(), nixStore) == 0 && path.size() >= nixStore.size() + 2 - && path[nixStore.size()] == '/' + && path[nixStore.size()] == '/'; +} + + +bool isStorePath(const Path & path) +{ + return isInStore(path) && path.find('/', nixStore.size() + 1) == Path::npos; } @@ -193,6 +199,18 @@ void assertStorePath(const Path & path) } +Path toStorePath(const Path & path) +{ + if (!isInStore(path)) + throw Error(format("path `%1%' is not in the Nix store") % path); + unsigned int slash = path.find('/', nixStore.size() + 1); + if (slash == Path::npos) + return path; + else + return Path(path, 0, slash); +} + + void canonicalisePathMetaData(const Path & path) { checkInterrupt(); |