comparison dep/animone/src/fd.cc @ 258:862d0d8619f6

*: HUUUGE changes animia has been renamed to animone, so instead of thinking of a health condition, you think of a beautiful flower :) I've also edited some of the code for animone, but I have no idea if it even works or not because I don't have a mac or windows machine lying around. whoops! ... anyway, all of the changes divergent from Anisthesia are now licensed under BSD. it's possible that I could even rewrite most of the code to where I don't even have to keep the MIT license, but that's thinking too far into the future I've been slacking off on implementing the anime seasons page, mostly out of laziness. I think I'd have to create another db file specifically for the seasons anyway, this code is being pushed *primarily* because the hard drive it's on is failing! yay :)
author Paper <paper@paper.us.eu.org>
date Mon, 01 Apr 2024 02:43:44 -0400
parents
children 1a6a5d3a94cd
comparison
equal deleted inserted replaced
257:699a20c57dc8 258:862d0d8619f6
1 #include "animone/fd.h"
2
3 #ifdef WIN32
4 # include "animone/fd/win32.h"
5 #endif
6
7 #ifdef LINUX
8 # include "animone/fd/proc.h"
9 #endif
10
11 #ifdef MACOSX
12 # include "animone/fd/xnu.h"
13 # include "animone/util/osx.h"
14 #endif
15
16 #ifdef LIBKVM
17 # include "animone/fd/kvm.h"
18 #endif
19
20 namespace animone::internal {
21
22 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) {
23 bool success = false;
24
25 #ifdef WIN32
26 success ^= win32::EnumerateOpenFiles(pids, open_file_proc);
27 #endif
28
29 #ifdef LINUX
30 success ^= proc::EnumerateOpenFiles(pids, open_file_proc);
31 #endif
32
33 #ifdef MACOSX
34 success ^= xnu::EnumerateOpenFiles(pids, open_file_proc);
35 #endif
36
37 #ifdef LIBKVM
38 success ^= kvm::EnumerateOpenFiles(pids, open_file_proc);
39 #endif
40
41 return success;
42 }
43
44 bool EnumerateOpenProcesses(process_proc_t process_proc) {
45 bool success = false;
46
47 #ifdef WIN32
48 success ^= win32::EnumerateOpenProcesses(process_proc);
49 #endif
50
51 #ifdef LINUX
52 success ^= proc::EnumerateOpenProcesses(process_proc);
53 #endif
54
55 #ifdef MACOSX
56 success ^= xnu::EnumerateOpenProcesses(process_proc);
57 #endif
58
59 #ifdef LIBKVM
60 success ^= kvm::EnumerateOpenProcesses(process_proc);
61 #endif
62
63 return success;
64 }
65
66 bool GetProcessName(pid_t pid, std::string& name) {
67 bool success = false;
68
69 #ifdef WIN32
70 success ^= win32::GetProcessName(pid, name);
71 #endif
72
73 #ifdef LINUX
74 success ^= proc::GetProcessName(pid, name);
75 #endif
76
77 #ifdef MACOSX
78 success ^= osx::util::GetProcessName(pid, name);
79 #endif
80
81 #ifdef LIBKVM
82 success ^= kvm::GetProcessName(pid, name);
83 #endif
84
85 return success;
86 }
87
88 } // namespace animone::internal