more pkg stuff

This commit is contained in:
Mars 2025-05-04 00:15:28 -04:00
parent 7d5d7b488a
commit 71f9c1ce63
Signed by: pupbrained
GPG key ID: 0FF5B8826803F895
5 changed files with 4 additions and 29 deletions

View file

@ -261,8 +261,6 @@ namespace os {
} }
fn GetPackageCount() -> Result<u64, DracError> { fn GetPackageCount() -> Result<u64, DracError> {
u64 count = 0;
BPackageKit::BPackageRoster roster; BPackageKit::BPackageRoster roster;
BPackageKit::BPackageInfoSet packageList; BPackageKit::BPackageInfoSet packageList;
@ -271,14 +269,7 @@ namespace os {
if (status != B_OK) if (status != B_OK)
return Err(DracError(DracErrorCode::ApiUnavailable, "Failed to get active package list")); return Err(DracError(DracErrorCode::ApiUnavailable, "Failed to get active package list"));
count += static_cast<u64>(packageList.CountInfos()); return static_cast<u64>(packageList.CountInfos());
if (Result<u64, DracError> sharedCount = shared::GetPackageCount())
count += *sharedCount;
else
debug_at(sharedCount.error());
return count;
} }
} // namespace os } // namespace os

View file

@ -480,11 +480,6 @@ namespace os {
else else
debug_at(linuxCount.error()); debug_at(linuxCount.error());
if (Result<u64, DracError> sharedCount = shared::GetPackageCount())
count += *sharedCount;
else
debug_at(sharedCount.error());
return count; return count;
} }
} // namespace os } // namespace os

View file

@ -9,10 +9,7 @@
#include <chrono> // std::chrono::{duration_cast, seconds, system_clock} #include <chrono> // std::chrono::{duration_cast, seconds, system_clock}
#include <filesystem> // std::filesystem::{current_path, directory_entry, directory_iterator, etc.} #include <filesystem> // std::filesystem::{current_path, directory_entry, directory_iterator, etc.}
#include <format> // std::format #include <format> // std::format
#include <fstream> // std::{ifstream, ofstream}
#include <future> // std::{async, launch} #include <future> // std::{async, launch}
#include <ios> // std::ios::{binary, trunc}, std::ios_base
#include <iterator> // std::istreambuf_iterator
#include <glaze/beve/read.hpp> // glz::read_beve #include <glaze/beve/read.hpp> // glz::read_beve
#include <glaze/beve/write.hpp> // glz::write_beve #include <glaze/beve/write.hpp> // glz::write_beve
#include <system_error> // std::error_code #include <system_error> // std::error_code

View file

@ -222,7 +222,9 @@ fn os::GetDiskUsage() -> Result<DiskSpace, DracError> {
.total_bytes = vfs.f_blocks * vfs.f_frsize }; .total_bytes = vfs.f_blocks * vfs.f_frsize };
} }
fn os::GetPackageCount() -> Result<u64, DracError> { return shared::GetPackageCount(); } fn os::GetPackageCount() -> Result<u64, DracError> {
return Err(DracError(DracErrorCode::NotSupported, "Package count is not supported on macOS")); // TODO: Implement
}
fn os::GetShell() -> Result<String, DracError> { fn os::GetShell() -> Result<String, DracError> {
return "Fish"; // TODO: Implement return "Fish"; // TODO: Implement

View file

@ -100,14 +100,4 @@ namespace os {
* or a DracError on failure (e.g., filesystem not found, permission error). * or a DracError on failure (e.g., filesystem not found, permission error).
*/ */
fn GetDiskUsage() -> Result<DiskSpace, DracError>; fn GetDiskUsage() -> Result<DiskSpace, DracError>;
namespace shared {
/**
* @brief Gets the number of installed packages from OS-agnostic package managers.
* @details Currently only supports Cargo package manager.
* @return A Result containing the package count (u64) on success,
* or a DracError on failure (e.g., permission errors, command not found).
*/
fn GetPackageCount() -> Result<u64, DracError>;
} // namespace shared
} // namespace os } // namespace os