hopefully this works ?
This commit is contained in:
parent
a9be33dd79
commit
7e7678f5f0
11 changed files with 79 additions and 257 deletions
10
meson.build
10
meson.build
|
@ -92,12 +92,12 @@ base_sources = files('src/core/system_data.cpp', 'src/core/package.cpp', 'src/co
|
||||||
|
|
||||||
platform_sources = {
|
platform_sources = {
|
||||||
'darwin' : ['src/os/macos.cpp', 'src/os/macos/bridge.mm'],
|
'darwin' : ['src/os/macos.cpp', 'src/os/macos/bridge.mm'],
|
||||||
'dragonfly' : ['src/os/bsd.cpp', 'src/os/bsd/package.cpp'],
|
'dragonfly' : ['src/os/bsd.cpp'],
|
||||||
'freebsd' : ['src/os/bsd.cpp', 'src/os/bsd/package.cpp'],
|
'freebsd' : ['src/os/bsd.cpp'],
|
||||||
'haiku' : ['src/os/haiku.cpp', 'src/os/haiku/package.cpp'],
|
'haiku' : ['src/os/haiku.cpp'],
|
||||||
'linux' : ['src/os/linux.cpp'],
|
'linux' : ['src/os/linux.cpp'],
|
||||||
'netbsd' : ['src/os/bsd.cpp', 'src/os/bsd/package.cpp'],
|
'netbsd' : ['src/os/bsd.cpp'],
|
||||||
'serenity' : ['src/os/serenity.cpp', 'src/os/serenity/package.cpp'],
|
'serenity' : ['src/os/serenity.cpp'],
|
||||||
'windows' : ['src/os/windows.cpp'],
|
'windows' : ['src/os/windows.cpp'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string> // std::string (String)
|
|
||||||
#include <toml++/impl/node.hpp> // toml::node
|
#include <toml++/impl/node.hpp> // toml::node
|
||||||
#include <toml++/impl/node_view.hpp> // toml::node_view
|
#include <toml++/impl/node_view.hpp> // toml::node_view
|
||||||
#include <toml++/impl/table.hpp> // toml::table
|
#include <toml++/impl/table.hpp> // toml::table
|
||||||
#include <variant> // std::variant
|
#include <variant> // std::variant
|
||||||
//
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h> // GetUserNameA
|
#include <windows.h> // GetUserNameA
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -116,7 +116,7 @@ namespace {
|
||||||
};
|
};
|
||||||
|
|
||||||
fn CreateColorCircles() -> Element {
|
fn CreateColorCircles() -> Element {
|
||||||
fn color_view =
|
fn colorView =
|
||||||
std::views::iota(0, 16) | std::views::transform([](i32 colorIndex) {
|
std::views::iota(0, 16) | std::views::transform([](i32 colorIndex) {
|
||||||
return ftxui::hbox(
|
return ftxui::hbox(
|
||||||
{ ftxui::text("◯") | ftxui::bold | ftxui::color(static_cast<ftxui::Color::Palette256>(colorIndex)),
|
{ ftxui::text("◯") | ftxui::bold | ftxui::color(static_cast<ftxui::Color::Palette256>(colorIndex)),
|
||||||
|
@ -124,9 +124,9 @@ namespace {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
Elements elements_container(std::ranges::begin(color_view), std::ranges::end(color_view));
|
Elements elementsContainer(std::ranges::begin(colorView), std::ranges::end(colorView));
|
||||||
|
|
||||||
return hbox(elements_container);
|
return hbox(elementsContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_visual_width(const String& str) -> usize { return ftxui::string_width(str); }
|
fn get_visual_width(const String& str) -> usize { return ftxui::string_width(str); }
|
||||||
|
|
|
@ -9,13 +9,13 @@
|
||||||
#include <sys/sysctl.h> // sysctlbyname
|
#include <sys/sysctl.h> // sysctlbyname
|
||||||
#include <sys/un.h> // LOCAL_PEERCRED
|
#include <sys/un.h> // LOCAL_PEERCRED
|
||||||
#include <sys/utsname.h> // uname, utsname
|
#include <sys/utsname.h> // uname, utsname
|
||||||
#include <unistd.h> // readlink
|
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
#ifndef __NetBSD__
|
||||||
#include <kenv.h> // kenv
|
#include <kenv.h> // kenv
|
||||||
#include <sys/ucred.h> // xucred
|
#include <sys/ucred.h> // xucred
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "src/core/package.hpp"
|
||||||
#include "src/util/defs.hpp"
|
#include "src/util/defs.hpp"
|
||||||
#include "src/util/error.hpp"
|
#include "src/util/error.hpp"
|
||||||
#include "src/util/helpers.hpp"
|
#include "src/util/helpers.hpp"
|
||||||
|
@ -165,9 +165,8 @@ namespace {
|
||||||
|
|
||||||
Result<String, DracError> exePathResult = GetPathByPid(peerPid);
|
Result<String, DracError> exePathResult = GetPathByPid(peerPid);
|
||||||
|
|
||||||
if (!exePathResult) {
|
if (!exePathResult)
|
||||||
return Err(std::move(exePathResult).error());
|
return Err(std::move(exePathResult).error());
|
||||||
}
|
|
||||||
|
|
||||||
const String& exeRealPath = *exePathResult;
|
const String& exeRealPath = *exePathResult;
|
||||||
|
|
||||||
|
@ -485,4 +484,22 @@ namespace os {
|
||||||
}
|
}
|
||||||
} // namespace os
|
} // namespace os
|
||||||
|
|
||||||
|
namespace package {
|
||||||
|
#ifdef __NetBSD__
|
||||||
|
fn GetPkgSrcCount() -> Result<u64, DracError> {
|
||||||
|
return GetCountFromDirectory("pkgsrc", fs::current_path().root_path() / "usr" / "pkg" / "pkgdb", true);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
fn GetPkgNgCount() -> Result<u64, DracError> {
|
||||||
|
const PackageManagerInfo pkgInfo = {
|
||||||
|
.id = "pkgng",
|
||||||
|
.dbPath = "/var/db/pkg/local.sqlite",
|
||||||
|
.countQuery = "SELECT COUNT(*) FROM packages",
|
||||||
|
};
|
||||||
|
|
||||||
|
return GetCountFromDb(pkgInfo);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} // namespace package
|
||||||
|
|
||||||
#endif // __FreeBSD__ || __DragonFly__ || __NetBSD__
|
#endif // __FreeBSD__ || __DragonFly__ || __NetBSD__
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
|
|
||||||
|
|
||||||
// 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 <glaze/beve/write.hpp> // glz::write_beve
|
|
||||||
#include <glaze/core/common.hpp> // glz::object
|
|
||||||
#include <glaze/core/meta.hpp> // glz::detail::Object
|
|
||||||
|
|
||||||
#include "src/util/defs.hpp"
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
namespace package {
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
fn GetPkgNgCount() -> Result<u64, DracError> {
|
|
||||||
const PackageManagerInfo pkgInfo = {
|
|
||||||
.id = "pkgng", // Use core struct
|
|
||||||
.dbPath = "/var/db/pkg/local.sqlite",
|
|
||||||
.countQuery = "SELECT COUNT(*) FROM packages",
|
|
||||||
};
|
|
||||||
|
|
||||||
return GetCountFromDb(pkgInfo);
|
|
||||||
}
|
|
||||||
#elif defined(__NetBSD__)
|
|
||||||
fn GetPkgSrcCount() -> Result<u64, DracError> {
|
|
||||||
return GetCountFromDirectory("pkgsrc", fs::current_path().root_path() / "usr" / "pkg" / "pkgdb", true);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} // namespace package
|
|
||||||
|
|
||||||
#endif // __FreeBSD__ || __DragonFly__ || __NetBSD__
|
|
147
src/os/haiku.cpp
147
src/os/haiku.cpp
|
@ -1,9 +1,9 @@
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#include <File.h> // For BFile
|
|
||||||
#include <AppFileInfo.h> // For BAppFileInfo and version_info
|
#include <AppFileInfo.h> // For BAppFileInfo and version_info
|
||||||
#include <Errors.h> // B_OK, strerror, status_t
|
#include <Errors.h> // B_OK, strerror, status_t
|
||||||
|
#include <File.h> // For BFile
|
||||||
#include <OS.h> // get_system_info, system_info
|
#include <OS.h> // get_system_info, system_info
|
||||||
#include <climits> // PATH_MAX
|
#include <climits> // PATH_MAX
|
||||||
#include <cstring> // std::strlen
|
#include <cstring> // std::strlen
|
||||||
|
@ -16,12 +16,12 @@
|
||||||
#include <sys/statvfs.h> // statvfs
|
#include <sys/statvfs.h> // statvfs
|
||||||
#include <utility> // std::move
|
#include <utility> // std::move
|
||||||
|
|
||||||
|
#include "src/core/package.hpp"
|
||||||
#include "src/util/defs.hpp"
|
#include "src/util/defs.hpp"
|
||||||
#include "src/util/error.hpp"
|
#include "src/util/error.hpp"
|
||||||
#include "src/util/helpers.hpp"
|
#include "src/util/helpers.hpp"
|
||||||
#include "src/util/logging.hpp"
|
#include "src/util/logging.hpp"
|
||||||
#include "src/util/types.hpp"
|
#include "src/util/types.hpp"
|
||||||
#include "src/wrappers/dbus.hpp"
|
|
||||||
|
|
||||||
#include "os.hpp"
|
#include "os.hpp"
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -69,134 +69,7 @@ namespace os {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetNowPlaying() -> Result<MediaInfo, DracError> {
|
fn GetNowPlaying() -> Result<MediaInfo, DracError> {
|
||||||
using namespace dbus;
|
return Err(DracError(DracErrorCode::NotSupported, "Now playing is not supported on Haiku"));
|
||||||
|
|
||||||
Result<Connection, DracError> connectionResult = Connection::busGet(DBUS_BUS_SESSION);
|
|
||||||
if (!connectionResult)
|
|
||||||
return Err(connectionResult.error());
|
|
||||||
|
|
||||||
const Connection& connection = *connectionResult;
|
|
||||||
|
|
||||||
Option<String> activePlayer = None;
|
|
||||||
|
|
||||||
{
|
|
||||||
Result<Message, DracError> listNamesResult =
|
|
||||||
Message::newMethodCall("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames");
|
|
||||||
if (!listNamesResult)
|
|
||||||
return Err(listNamesResult.error());
|
|
||||||
|
|
||||||
Result<Message, DracError> listNamesReplyResult = connection.sendWithReplyAndBlock(*listNamesResult, 100);
|
|
||||||
if (!listNamesReplyResult)
|
|
||||||
return Err(listNamesReplyResult.error());
|
|
||||||
|
|
||||||
MessageIter iter = listNamesReplyResult->iterInit();
|
|
||||||
if (!iter.isValid() || iter.getArgType() != DBUS_TYPE_ARRAY)
|
|
||||||
return Err(DracError(DracErrorCode::ParseError, "Invalid DBus ListNames reply format: Expected array"));
|
|
||||||
|
|
||||||
MessageIter subIter = iter.recurse();
|
|
||||||
if (!subIter.isValid())
|
|
||||||
return Err(
|
|
||||||
DracError(DracErrorCode::ParseError, "Invalid DBus ListNames reply format: Could not recurse into array")
|
|
||||||
);
|
|
||||||
|
|
||||||
while (subIter.getArgType() != DBUS_TYPE_INVALID) {
|
|
||||||
if (Option<String> name = subIter.getString())
|
|
||||||
if (name->starts_with("org.mpris.MediaPlayer2.")) {
|
|
||||||
activePlayer = std::move(*name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!subIter.next())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!activePlayer)
|
|
||||||
return Err(DracError(DracErrorCode::NotFound, "No active MPRIS players found"));
|
|
||||||
|
|
||||||
Result<Message, DracError> msgResult = Message::newMethodCall(
|
|
||||||
activePlayer->c_str(), "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "Get"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!msgResult)
|
|
||||||
return Err(msgResult.error());
|
|
||||||
|
|
||||||
Message& msg = *msgResult;
|
|
||||||
|
|
||||||
if (!msg.appendArgs("org.mpris.MediaPlayer2.Player", "Metadata"))
|
|
||||||
return Err(DracError(DracErrorCode::InternalError, "Failed to append arguments to Properties.Get message"));
|
|
||||||
|
|
||||||
Result<Message, DracError> replyResult = connection.sendWithReplyAndBlock(msg, 100);
|
|
||||||
|
|
||||||
if (!replyResult)
|
|
||||||
return Err(replyResult.error());
|
|
||||||
|
|
||||||
Option<String> title = None;
|
|
||||||
Option<String> artist = None;
|
|
||||||
|
|
||||||
MessageIter propIter = replyResult->iterInit();
|
|
||||||
if (!propIter.isValid())
|
|
||||||
return Err(DracError(DracErrorCode::ParseError, "Properties.Get reply has no arguments or invalid iterator"));
|
|
||||||
|
|
||||||
if (propIter.getArgType() != DBUS_TYPE_VARIANT)
|
|
||||||
return Err(DracError(DracErrorCode::ParseError, "Properties.Get reply argument is not a variant"));
|
|
||||||
|
|
||||||
MessageIter variantIter = propIter.recurse();
|
|
||||||
if (!variantIter.isValid())
|
|
||||||
return Err(DracError(DracErrorCode::ParseError, "Could not recurse into variant"));
|
|
||||||
|
|
||||||
if (variantIter.getArgType() != DBUS_TYPE_ARRAY || variantIter.getElementType() != DBUS_TYPE_DICT_ENTRY)
|
|
||||||
return Err(DracError(DracErrorCode::ParseError, "Metadata variant content is not a dictionary array (a{sv})"));
|
|
||||||
|
|
||||||
MessageIter dictIter = variantIter.recurse();
|
|
||||||
if (!dictIter.isValid())
|
|
||||||
return Err(DracError(DracErrorCode::ParseError, "Could not recurse into metadata dictionary array"));
|
|
||||||
|
|
||||||
while (dictIter.getArgType() == DBUS_TYPE_DICT_ENTRY) {
|
|
||||||
MessageIter entryIter = dictIter.recurse();
|
|
||||||
if (!entryIter.isValid()) {
|
|
||||||
debug_log("Warning: Could not recurse into dict entry, skipping.");
|
|
||||||
if (!dictIter.next())
|
|
||||||
break;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Option<String> key = entryIter.getString();
|
|
||||||
if (!key) {
|
|
||||||
debug_log("Warning: Could not get key string from dict entry, skipping.");
|
|
||||||
if (!dictIter.next())
|
|
||||||
break;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entryIter.next() || entryIter.getArgType() != DBUS_TYPE_VARIANT) {
|
|
||||||
if (!dictIter.next())
|
|
||||||
break;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageIter valueVariantIter = entryIter.recurse();
|
|
||||||
if (!valueVariantIter.isValid()) {
|
|
||||||
if (!dictIter.next())
|
|
||||||
break;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*key == "xesam:title") {
|
|
||||||
title = valueVariantIter.getString();
|
|
||||||
} else if (*key == "xesam:artist") {
|
|
||||||
if (valueVariantIter.getArgType() == DBUS_TYPE_ARRAY && valueVariantIter.getElementType() == DBUS_TYPE_STRING) {
|
|
||||||
if (MessageIter artistArrayIter = valueVariantIter.recurse(); artistArrayIter.isValid())
|
|
||||||
artist = artistArrayIter.getString();
|
|
||||||
} else {
|
|
||||||
debug_log("Warning: Artist value was not an array of strings as expected.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dictIter.next())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return MediaInfo(std::move(title), std::move(artist));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetWindowManager() -> Result<String, DracError> { return "app_server"; }
|
fn GetWindowManager() -> Result<String, DracError> { return "app_server"; }
|
||||||
|
@ -261,4 +134,18 @@ namespace os {
|
||||||
}
|
}
|
||||||
} // namespace os
|
} // namespace os
|
||||||
|
|
||||||
|
namespace package {
|
||||||
|
fn GetHaikuCount() -> Result<u64, DracError> {
|
||||||
|
BPackageKit::BPackageRoster roster;
|
||||||
|
BPackageKit::BPackageInfoSet packageList;
|
||||||
|
|
||||||
|
const status_t status = roster.GetActivePackages(BPackageKit::B_PACKAGE_INSTALLATION_LOCATION_SYSTEM, packageList);
|
||||||
|
|
||||||
|
if (status != B_OK)
|
||||||
|
return Err(DracError(DracErrorCode::ApiUnavailable, "Failed to get active package list"));
|
||||||
|
|
||||||
|
return static_cast<u64>(packageList.CountInfos());
|
||||||
|
}
|
||||||
|
} // namespace package
|
||||||
|
|
||||||
#endif // __HAIKU__
|
#endif // __HAIKU__
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
#ifdef __HAIKU__
|
|
||||||
// clang-format off
|
|
||||||
#include "src/core/package.hpp"
|
|
||||||
|
|
||||||
#include <os/package/PackageDefs.h> // BPackageKit::BPackageInfoSet
|
|
||||||
#include <os/package/PackageInfoSet.h> // BPackageKit::BPackageInfo
|
|
||||||
#include <os/package/PackageRoster.h> // BPackageKit::BPackageRoster
|
|
||||||
|
|
||||||
#include "src/util/defs.hpp"
|
|
||||||
#include "src/util/error.hpp"
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
namespace package {
|
|
||||||
using util::error::DracError, util::error::DracErrorCode;
|
|
||||||
using util::types::Err;
|
|
||||||
|
|
||||||
fn GetHaikuCount() -> Result<u64, DracError> {
|
|
||||||
BPackageKit::BPackageRoster roster;
|
|
||||||
BPackageKit::BPackageInfoSet packageList;
|
|
||||||
|
|
||||||
const status_t status = roster.GetActivePackages(BPackageKit::B_PACKAGE_INSTALLATION_LOCATION_SYSTEM, packageList);
|
|
||||||
|
|
||||||
if (status != B_OK)
|
|
||||||
return Err(DracError(DracErrorCode::ApiUnavailable, "Failed to get active package list"));
|
|
||||||
|
|
||||||
return static_cast<u64>(packageList.CountInfos());
|
|
||||||
}
|
|
||||||
} // namespace package
|
|
||||||
|
|
||||||
#endif // __HAIKU__
|
|
|
@ -16,7 +16,9 @@
|
||||||
#include <sys/types.h> // uid_t
|
#include <sys/types.h> // uid_t
|
||||||
#include <sys/utsname.h> // utsname, uname
|
#include <sys/utsname.h> // utsname, uname
|
||||||
#include <unistd.h> // getuid, gethostname
|
#include <unistd.h> // getuid, gethostname
|
||||||
|
#include <unordered_set> // std::unordered_set
|
||||||
|
|
||||||
|
#include "src/core/package.hpp"
|
||||||
#include "src/util/defs.hpp"
|
#include "src/util/defs.hpp"
|
||||||
#include "src/util/error.hpp"
|
#include "src/util/error.hpp"
|
||||||
#include "src/util/helpers.hpp"
|
#include "src/util/helpers.hpp"
|
||||||
|
@ -47,6 +49,22 @@ namespace {
|
||||||
};
|
};
|
||||||
// NOLINTEND(readability-identifier-naming)
|
// NOLINTEND(readability-identifier-naming)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fn CountUniquePackages(const String& dbPath) -> Result<u64, DracError> {
|
||||||
|
std::ifstream dbFile(dbPath);
|
||||||
|
|
||||||
|
if (!dbFile.is_open())
|
||||||
|
return Err(DracError(DracErrorCode::NotFound, std::format("Failed to open file: {}", dbPath)));
|
||||||
|
|
||||||
|
std::unordered_set<String> uniquePackages;
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while (std::getline(dbFile, line))
|
||||||
|
if (line.starts_with("manual ") || line.starts_with("auto "))
|
||||||
|
uniquePackages.insert(line);
|
||||||
|
|
||||||
|
return uniquePackages.size();
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace os {
|
namespace os {
|
||||||
|
@ -147,4 +165,8 @@ namespace os {
|
||||||
}
|
}
|
||||||
} // namespace os
|
} // namespace os
|
||||||
|
|
||||||
|
namespace package {
|
||||||
|
fn GetSerenityCount() -> Result<u64, DracError> { return CountUniquePackages("/usr/Ports/installed.db"); }
|
||||||
|
} // namespace package
|
||||||
|
|
||||||
#endif // __serenity__
|
#endif // __serenity__
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
#ifdef __serenity__
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
#include "src/core/package.hpp"
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
#include "src/util/defs.hpp"
|
|
||||||
#include "src/util/error.hpp"
|
|
||||||
#include "src/util/types.hpp"
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
using util::error::DracError, util::error::DracErrorCode;
|
|
||||||
using util::types::u64, util::types::String, util::types::Result, util::types::Err;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
fn CountUniquePackages(const String& dbPath) -> Result<u64, DracError> {
|
|
||||||
std::ifstream dbFile(dbPath);
|
|
||||||
|
|
||||||
if (!dbFile.is_open())
|
|
||||||
return Err(DracError(DracErrorCode::NotFound, std::format("Failed to open file: {}", dbPath)));
|
|
||||||
|
|
||||||
std::unordered_set<String> uniquePackages;
|
|
||||||
String line;
|
|
||||||
|
|
||||||
while (std::getline(dbFile, line))
|
|
||||||
if (line.starts_with("manual ") || line.starts_with("auto "))
|
|
||||||
uniquePackages.insert(line);
|
|
||||||
|
|
||||||
return uniquePackages.size();
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
namespace package {
|
|
||||||
fn GetSerenityCount() -> Result<u64, DracError> { return CountUniquePackages("/usr/Ports/installed.db"); }
|
|
||||||
} // namespace package
|
|
||||||
|
|
||||||
#endif // __serenity__
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__HAIKU__)
|
#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -280,8 +280,8 @@ namespace dbus {
|
||||||
using DecayedT = std::decay_t<T>;
|
using DecayedT = std::decay_t<T>;
|
||||||
|
|
||||||
if constexpr (std::is_convertible_v<DecayedT, const char*>) {
|
if constexpr (std::is_convertible_v<DecayedT, const char*>) {
|
||||||
const char* valuePtr = static_cast<const char*>(arg);
|
const char* valuePtr = static_cast<const char*>(std::forward<T>(arg));
|
||||||
return dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &valuePtr);
|
return dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, static_cast<const void*>(&valuePtr));
|
||||||
} else {
|
} else {
|
||||||
static_assert(!sizeof(T*), "Unsupported type passed to appendArgs");
|
static_assert(!sizeof(T*), "Unsupported type passed to appendArgs");
|
||||||
return false;
|
return false;
|
||||||
|
@ -386,4 +386,4 @@ namespace dbus {
|
||||||
};
|
};
|
||||||
} // namespace dbus
|
} // namespace dbus
|
||||||
|
|
||||||
#endif // __linux__ || __FreeBSD__ || __DragonFly__ || __NetBSD__ || __HAIKU__
|
#endif // __linux__ || __FreeBSD__ || __DragonFly__ || __NetBSD__
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue