this is a better strcuture i think
This commit is contained in:
parent
b929bda29f
commit
a9be33dd79
3 changed files with 52 additions and 61 deletions
|
@ -95,7 +95,7 @@ platform_sources = {
|
|||
'dragonfly' : ['src/os/bsd.cpp', 'src/os/bsd/package.cpp'],
|
||||
'freebsd' : ['src/os/bsd.cpp', 'src/os/bsd/package.cpp'],
|
||||
'haiku' : ['src/os/haiku.cpp', 'src/os/haiku/package.cpp'],
|
||||
'linux' : ['src/os/linux.cpp', 'src/os/linux/package.cpp'],
|
||||
'linux' : ['src/os/linux.cpp'],
|
||||
'netbsd' : ['src/os/bsd.cpp', 'src/os/bsd/package.cpp'],
|
||||
'serenity' : ['src/os/serenity.cpp', 'src/os/serenity/package.cpp'],
|
||||
'windows' : ['src/os/windows.cpp'],
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
#ifdef __linux__
|
||||
|
||||
// clang-format off
|
||||
#include <SQLiteCpp/Database.h> // SQLite::{Database, OPEN_READONLY}
|
||||
#include <SQLiteCpp/Exception.h> // SQLite::Exception
|
||||
#include <SQLiteCpp/Statement.h> // SQLite::Statement
|
||||
#include <climits> // PATH_MAX
|
||||
#include <cstring> // std::strlen
|
||||
#include <dbus/dbus-shared.h> // DBUS_BUS_SESSION
|
||||
#include <dbus/dbus-protocol.h> // DBUS_TYPE_*
|
||||
#include <dbus/dbus-shared.h> // DBUS_BUS_SESSION
|
||||
#include <expected> // std::{unexpected, expected}
|
||||
#include <filesystem> // std::filesystem::{current_path, directory_entry, directory_iterator, etc.}
|
||||
#include <format> // std::{format, format_to_n}
|
||||
#include <fstream> // std::ifstream
|
||||
#include <climits> // PATH_MAX
|
||||
#include <glaze/beve/read.hpp> // glz::read_beve
|
||||
#include <glaze/beve/write.hpp> // glz::write_beve
|
||||
#include <limits> // std::numeric_limits
|
||||
#include <string> // std::{getline, string (String)}
|
||||
#include <string_view> // std::string_view (StringView)
|
||||
|
@ -18,6 +24,7 @@
|
|||
#include <unistd.h> // readlink
|
||||
#include <utility> // std::move
|
||||
|
||||
#include "src/core/package.hpp"
|
||||
#include "src/util/defs.hpp"
|
||||
#include "src/util/error.hpp"
|
||||
#include "src/util/helpers.hpp"
|
||||
|
@ -472,4 +479,32 @@ namespace os {
|
|||
}
|
||||
} // namespace os
|
||||
|
||||
namespace package {
|
||||
using namespace std::string_literals;
|
||||
|
||||
fn GetDpkgCount() -> Result<u64, DracError> {
|
||||
return GetCountFromDirectory("Dpkg", fs::current_path().root_path() / "var" / "lib" / "dpkg" / "info", ".list"s);
|
||||
}
|
||||
|
||||
fn GetMossCount() -> Result<u64, DracError> {
|
||||
const PackageManagerInfo mossInfo = {
|
||||
.id = "moss",
|
||||
.dbPath = "/.moss/db/install",
|
||||
.countQuery = "SELECT COUNT(*) FROM meta",
|
||||
};
|
||||
|
||||
Result<u64, DracError> countResult = GetCountFromDb(mossInfo);
|
||||
|
||||
if (countResult)
|
||||
if (*countResult > 0)
|
||||
return *countResult - 1;
|
||||
|
||||
return countResult;
|
||||
}
|
||||
|
||||
fn GetPacmanCount() -> Result<u64, DracError> {
|
||||
return GetCountFromDirectory("Pacman", fs::current_path().root_path() / "var" / "lib" / "pacman" / "local", true);
|
||||
}
|
||||
} // namespace package
|
||||
|
||||
#endif // __linux__
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
#ifdef __linux__
|
||||
|
||||
// clang-format off
|
||||
#include "src/core/package.hpp"
|
||||
|
||||
#include <SQLiteCpp/Database.h> // SQLite::{Database, OPEN_READONLY}
|
||||
#include <SQLiteCpp/Exception.h> // SQLite::Exception
|
||||
#include <SQLiteCpp/Statement.h> // SQLite::Statement
|
||||
#include <filesystem> // std::filesystem::{current_path, directory_entry, directory_iterator, etc.}
|
||||
#include <glaze/beve/read.hpp> // glz::read_beve
|
||||
#include <glaze/beve/write.hpp> // glz::write_beve
|
||||
|
||||
#include "src/util/defs.hpp"
|
||||
// clang-format on
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
namespace package {
|
||||
fn GetDpkgCount() -> Result<u64, DracError> {
|
||||
return GetCountFromDirectory("Dpkg", fs::current_path().root_path() / "var" / "lib" / "dpkg" / "info", ".list"s);
|
||||
}
|
||||
|
||||
fn GetMossCount() -> Result<u64, DracError> {
|
||||
const PackageManagerInfo mossInfo = {
|
||||
.id = "moss",
|
||||
.dbPath = "/.moss/db/install",
|
||||
.countQuery = "SELECT COUNT(*) FROM meta",
|
||||
};
|
||||
|
||||
Result<u64, DracError> countResult = GetCountFromDb(mossInfo);
|
||||
|
||||
if (countResult)
|
||||
if (*countResult > 0)
|
||||
return *countResult - 1;
|
||||
|
||||
return countResult;
|
||||
}
|
||||
|
||||
fn GetPacmanCount() -> Result<u64, DracError> {
|
||||
return GetCountFromDirectory("Pacman", fs::current_path().root_path() / "var" / "lib" / "pacman" / "local", true);
|
||||
}
|
||||
} // namespace package
|
||||
|
||||
#endif // __linux__
|
Loading…
Add table
Add a link
Reference in a new issue