Mercurial > minori
comparison dep/animia/src/fd/proc.cc @ 198:bc1ae1810855
dep/animia: switch from using classes to global functions
the old idea was ok, but sort of hackish; this method doesn't use classes
at all, and this way (especially important!) we can do wayland stuff AND x11
at the same time, which wasn't really possible without stupid workarounds in
the other method
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 24 Dec 2023 02:59:42 -0500 |
parents | c413e475f496 |
children | 031a257ee019 |
comparison
equal
deleted
inserted
replaced
197:c4ca035c565d | 198:bc1ae1810855 |
---|---|
98 result.erase(std::remove(result.begin(), result.end(), '\n'), result.end()); | 98 result.erase(std::remove(result.begin(), result.end(), '\n'), result.end()); |
99 | 99 |
100 return result; | 100 return result; |
101 } | 101 } |
102 | 102 |
103 bool ProcFdTools::EnumerateOpenProcesses(process_proc_t process_proc) { | 103 bool EnumerateOpenProcesses(process_proc_t process_proc) { |
104 bool success = false; | 104 bool success = false; |
105 for (const auto& dir : GetAllFilesInDir(std::string(PROC_LOCATION))) { | 105 for (const auto& dir : GetAllFilesInDir(std::string(PROC_LOCATION))) { |
106 pid_t pid; | 106 pid_t pid; |
107 try { | 107 try { |
108 pid = std::stoul(Basename(dir)); | 108 pid = std::stoul(Basename(dir)); |
114 return false; | 114 return false; |
115 } | 115 } |
116 return success; | 116 return success; |
117 } | 117 } |
118 | 118 |
119 bool ProcFdTools::EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) { | 119 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) { |
120 if (!open_file_proc) | 120 if (!open_file_proc) |
121 return false; | 121 return false; |
122 | 122 |
123 for (const auto& pid : pids) { | 123 for (const auto& pid : pids) { |
124 const std::string path = std::string(PROC_LOCATION) + "/" + std::to_string(pid) + "/fd"; | 124 const std::string path = std::string(PROC_LOCATION) + "/" + std::to_string(pid) + "/fd"; |