aboutsummaryrefslogtreecommitdiff
path: root/katja/database.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'katja/database.cpp')
-rw-r--r--katja/database.cpp29
1 files changed, 29 insertions, 0 deletions
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 <filesystem>
+
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<std::string, database_package> read_installed_database()
+ {
+ std::multimap<std::string, database_package> 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;
+ }
}