diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-12-17 18:47:07 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-01-08 16:24:46 +0300 |
commit | b2f240870b4f759a7cf6eaf4d4409d2f6b9af5e1 (patch) | |
tree | 7232967056b94cb3623eb80def4358bb61cc5d28 /libbpkg/manifest.cxx | |
parent | fbabb3ddf7f9bee71a6be767cc911b5b3b96333a (diff) |
Add package_manifest::load_files() function loading file-* values
Diffstat (limited to 'libbpkg/manifest.cxx')
-rw-r--r-- | libbpkg/manifest.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx index 8782409..b94b4da 100644 --- a/libbpkg/manifest.cxx +++ b/libbpkg/manifest.cxx @@ -1803,6 +1803,36 @@ namespace bpkg parse_package_manifest (p, move (nv), iu, fl, *this); } + static const string description_file ("description-file"); + static const string changes_file ("changes-file"); + + void package_manifest:: + load_files (const function<load_function>& loader) + { + auto load = [&loader] (const string& n, const path& p) + { + string r (loader (n, p)); + + if (r.empty ()) + throw parsing ("package " + n + " references empty file"); + + return r; + }; + + // Load the description-file manifest value. + // + if (description && description->file) + description = text_file (load (description_file, description->path)); + + // Load the changes-file manifest values. + // + for (text_file& c: changes) + { + if (c.file) + c = text_file (load (changes_file, c.path)); + } + } + static void serialize_package_manifest (manifest_serializer& s, const package_manifest& m, |