From dfa5a732bab2bf4c50c6b193cb49cd3a67aef720 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 10 Mar 2025 12:16:31 +0100 Subject: Display packages installed from a repository --- katja/database.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'katja/database.cpp') diff --git a/katja/database.cpp b/katja/database.cpp index 555e679..11e3730 100644 --- a/katja/database.cpp +++ b/katja/database.cpp @@ -1,5 +1,12 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ #include "katja/database.hpp" +#include + namespace katja { database_package database_package::create_database_package(const std::string& fullname) @@ -47,6 +54,16 @@ namespace katja { } + bool database_package::operator<(const database_package& that) const + { + return this->name < that.name; + } + + bool database_package::operator>(const database_package& that) const + { + return this->name > that.name; + } + std::string database_package::to_string() const { std::string package_string; @@ -64,4 +81,16 @@ namespace katja return package_string; } + + std::multimap read_installed_database() + { + std::multimap result; + + for (const auto& entry : std::filesystem::directory_iterator(katja::database)) + { + database_package database_entry{ entry.path().filename() }; + result.emplace(database_entry.name, database_entry); + } + return result; + } } -- cgit v1.2.3