diff options
author | Shea Levy <shea@shealevy.com> | 2018-01-25T15·05-0800 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2018-02-06T21·48-0500 |
commit | 69d82e5c58bf6d7e16fc296f598c352da2a618d0 (patch) | |
tree | 22f76d4df9460225f7877c8c4eca4b9c2ecdc9e2 /src/libstore | |
parent | 98f3c75a0e16f5aaaecb25a46f988580efb04d19 (diff) |
Add path primop.
builtins.path allows specifying the name of a path (which makes paths with store-illegal names now addable), allows adding paths with flat instead of recursive hashes, allows specifying a filter (so is a generalization of filterSource), and allows specifying an expected hash (enabling safe path adding in pure mode).
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/store-api.cc | 5 | ||||
-rw-r--r-- | src/libstore/store-api.hh | 6 |
2 files changed, 5 insertions, 6 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 77ab87ef728e..7abb300a9bb8 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -222,11 +222,10 @@ Path Store::makeTextPath(const string & name, const Hash & hash, } -std::pair<Path, Hash> Store::computeStorePathForPath(const Path & srcPath, - bool recursive, HashType hashAlgo, PathFilter & filter) const +std::pair<Path, Hash> Store::computeStorePathForPath(const string & name, + const Path & srcPath, bool recursive, HashType hashAlgo, PathFilter & filter) const { Hash h = recursive ? hashPath(hashAlgo, srcPath, filter).first : hashFile(hashAlgo, srcPath); - string name = baseNameOf(srcPath); Path dstPath = makeFixedOutputPath(recursive, h, name); return std::pair<Path, Hash>(dstPath, h); } diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index c0e735cd314c..bf0862ef1bb3 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -305,9 +305,9 @@ public: /* This is the preparatory part of addToStore(); it computes the store path to which srcPath is to be copied. Returns the store path and the cryptographic hash of the contents of srcPath. */ - std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath, - bool recursive = true, HashType hashAlgo = htSHA256, - PathFilter & filter = defaultPathFilter) const; + std::pair<Path, Hash> computeStorePathForPath(const string & name, + const Path & srcPath, bool recursive = true, + HashType hashAlgo = htSHA256, PathFilter & filter = defaultPathFilter) const; /* Preparatory part of addTextToStore(). |