comparison dep/animone/src/fd/proc.cc @ 373:fbc8c617de80

dep/animone: exception handling is the worst c++ anti-feature
author Paper <paper@tflc.us>
date Fri, 25 Jul 2025 11:03:05 -0400
parents f81bed4e04ac
children
comparison
equal deleted inserted replaced
372:a65a43766b22 373:fbc8c617de80
153 return false; 153 return false;
154 154
155 for (const auto& pid : pids) { 155 for (const auto& pid : pids) {
156 const std::filesystem::path path = std::filesystem::path(PROC_LOCATION) / std::to_string(pid) / "fd"; 156 const std::filesystem::path path = std::filesystem::path(PROC_LOCATION) / std::to_string(pid) / "fd";
157 157
158 for (const auto& dir : std::filesystem::directory_iterator{path}) { 158 try {
159 if (!AreFlagsOk(pid, util::StringToInt(dir.path().stem()))) 159 for (const auto& dir : std::filesystem::directory_iterator{path}) {
160 continue; 160 if (!AreFlagsOk(pid, util::StringToInt(dir.path().stem())))
161 continue;
161 162
162 std::string name; 163 std::string name;
163 if (!GetFilenameFromFd(dir.path(), name)) 164 if (!GetFilenameFromFd(dir.path(), name))
164 continue; 165 continue;
165 166
166 if (!IsRegularFile(name)) 167 if (!IsRegularFile(name))
167 continue; 168 continue;
168 169
169 if (IsSystemFile(name)) 170 if (IsSystemFile(name))
170 continue; 171 continue;
171 172
172 if (!open_file_proc({pid, name})) 173 if (!open_file_proc({pid, name}))
173 return false; 174 return false;
175 }
176 } catch (std::filesystem::filesystem_error &fs_error) {
177 /* I hate C++ */
178 continue;
174 } 179 }
175 } 180 }
176 return true; 181 return true;
177 } 182 }
178 183