Introduce function get_installed_files()

This commit is contained in:
Alexander Karatarakis 2016-12-01 15:36:39 -08:00
parent 79399923b6
commit 7c2abc755f
2 changed files with 41 additions and 0 deletions

View File

@ -11,6 +11,14 @@ namespace vcpkg
void write_update(const vcpkg_paths& paths, const StatusParagraph& p); void write_update(const vcpkg_paths& paths, const StatusParagraph& p);
struct StatusParagraph_and_associated_files
{
StatusParagraph pgh;
std::vector<std::string> files;
};
std::vector<StatusParagraph_and_associated_files> get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db);
expected<SourceParagraph> try_load_port(const fs::path& control_path); expected<SourceParagraph> try_load_port(const fs::path& control_path);
inline expected<SourceParagraph> try_load_port(const vcpkg_paths& paths, const std::string& name) inline expected<SourceParagraph> try_load_port(const vcpkg_paths& paths, const std::string& name)

View File

@ -109,6 +109,39 @@ void vcpkg::write_update(const vcpkg_paths& paths, const StatusParagraph& p)
fs::rename(tmp_update_filename, update_filename); fs::rename(tmp_update_filename, update_filename);
} }
std::vector<StatusParagraph_and_associated_files> vcpkg::get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db)
{
std::vector<StatusParagraph_and_associated_files> installed_files;
std::string line;
for (const std::unique_ptr<StatusParagraph>& pgh : status_db)
{
if (pgh->state != install_state_t::installed)
{
continue;
}
std::fstream listfile(paths.listfile_path(pgh->package));
std::vector<std::string> 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<SourceParagraph> vcpkg::try_load_port(const fs::path& path) expected<SourceParagraph> vcpkg::try_load_port(const fs::path& path)
{ {
try try