From 5872ee26a6b94911b5fb8f0dd13a92f0d37653a2 Mon Sep 17 00:00:00 2001 From: Mars Date: Fri, 9 May 2025 17:53:56 -0400 Subject: [PATCH] meo --- meson.build | 2 +- src/os/macos.cpp | 26 ++++---------------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/meson.build b/meson.build index 50a2df7..64dc827 100644 --- a/meson.build +++ b/meson.build @@ -201,4 +201,4 @@ executable( link_args: link_args, dependencies: deps, install: true, -) \ No newline at end of file +) diff --git a/src/os/macos.cpp b/src/os/macos.cpp index a8d7181..b37c593 100644 --- a/src/os/macos.cpp +++ b/src/os/macos.cpp @@ -328,16 +328,15 @@ namespace package { "/usr/local/Cellar", }; - for (const auto& cellarPath : cellarPaths) { + for (const fs::path& cellarPath : cellarPaths) { if (std::error_code errc; !fs::exists(cellarPath, errc) || errc) { if (errc && errc != std::errc::no_such_file_or_directory) return Err(DracError(errc)); - return Err(DracError(DracErrorCode::NotFound, "Homebrew Cellar directory not found at: " + cellarPath.string()) - ); + return Err(DracError(DracErrorCode::NotFound, "Homebrew Cellar directory not found at: " + cellarPath.string())); } - Result dirCount = GetCountFromDirectory("homebrew", cellarPath, true); + Result dirCount = GetCountFromDirectory("homebrew", cellarPath, true); if (!dirCount) { if (dirCount.error().code != DracErrorCode::NotFound) @@ -353,24 +352,7 @@ namespace package { } fn GetMacPortsCount() -> Result { - const PackageManagerInfo macPortsInfo = { - .id = "macports", - .dbPath = "/opt/local/var/macports/registry/registry.db", - .countQuery = "SELECT COUNT(*) FROM ports WHERE state='installed';", - }; - - // Check if the database file exists before trying to query - std::error_code errc; - if (!fs::exists(macPortsInfo.dbPath, errc) || errc) { - if (errc && errc != std::errc::no_such_file_or_directory) - return Err(DracError(errc)); - - return Err( - DracError(DracErrorCode::NotFound, "MacPorts registry database not found at: " + macPortsInfo.dbPath.string()) - ); - } - - return GetCountFromDb(macPortsInfo); + return GetCountFromDb("macports", "/opt/local/var/macports/registry/registry.db", "SELECT COUNT(*) FROM ports WHERE state='installed';"); } } // namespace package