aboutsummaryrefslogtreecommitdiff
path: root/src/remove_pkg.cc
diff options
context:
space:
mode:
authordacctal <dacctalyt@gmail.com>2026-04-03 14:56:05 +0000
committerdacctal <dacctalyt@gmail.com>2026-04-03 14:56:05 +0000
commited78991edc4755c0276dcb4eb454b43fa38296fc (patch)
tree460da5399e34e1dce7a293cb22578da15977d895 /src/remove_pkg.cc
parent2a6b92ed130ade1ea7542ee210e6957427a0aa81 (diff)
countless changes
Diffstat (limited to 'src/remove_pkg.cc')
-rw-r--r--src/remove_pkg.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/remove_pkg.cc b/src/remove_pkg.cc
new file mode 100644
index 0000000..fa41bbc
--- /dev/null
+++ b/src/remove_pkg.cc
@@ -0,0 +1,25 @@
+#include <filesystem>
+#include <iostream>
+#include <string>
+#include <unistd.h>
+
+#include "remove_pkg.hh"
+#include "vars.hh"
+
+void remove_pkg(Pkg pkg) {
+ for (auto const& dir_entry : std::filesystem::recursive_directory_iterator(pkg.src)) {
+ if (dir_entry.path().extension().string().rfind(".so", 0) == 0) {
+ std::filesystem::remove(lib+"/"+dir_entry.path().filename().string());
+ std::cout << print_pkgit << "removed library: " << dir_entry << "\n";
+
+ } else if (!access(dir_entry.path().c_str(), X_OK) && !is_directory(dir_entry.path())) {
+ std::filesystem::remove(bin+"/"+dir_entry.path().filename().string());
+ std::cout << print_pkgit << "removed executable: " << dir_entry << "\n";
+
+ } else if (dir_entry.path().extension() == ".h") {
+ std::filesystem::remove(include+"/"+dir_entry.path().filename().string());
+ std::cout << print_pkgit << "removed include: " << dir_entry << "\n";
+ }
+ }
+ remove_all(pkg.src.parent_path());
+}