From 7c2abc755f58beaea36aa1cbc1c3b7f375e567a3 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 1 Dec 2016 15:36:39 -0800 Subject: Introduce function get_installed_files() --- toolsrc/src/vcpkg.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'toolsrc/src') diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 6c5224f56..57b2e7adb 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -109,6 +109,39 @@ void vcpkg::write_update(const vcpkg_paths& paths, const StatusParagraph& p) fs::rename(tmp_update_filename, update_filename); } +std::vector vcpkg::get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db) +{ + std::vector installed_files; + + std::string line; + + for (const std::unique_ptr& pgh : status_db) + { + if (pgh->state != install_state_t::installed) + { + continue; + } + + std::fstream listfile(paths.listfile_path(pgh->package)); + + std::vector installed_files_of_current_pgh; + while (std::getline(listfile, line)) + { + if (line.empty()) + { + continue; + } + + installed_files_of_current_pgh.push_back(line); + } + + const StatusParagraph_and_associated_files pgh_and_files = {*pgh, std::move(installed_files_of_current_pgh)}; + installed_files.push_back(pgh_and_files); + } + + return installed_files; +} + expected vcpkg::try_load_port(const fs::path& path) { try -- cgit v1.2.3