Mercurial > minori
annotate dep/animone/src/fd.cc @ 299:246017a7907a
dep/animone: clean up OS X code
GetProcessName() really belongs in fd.cc after removing the
stupid unnecessary LaunchServices code that was stolen from...
some library :)
| author | Paper <paper@paper.us.eu.org> | 
|---|---|
| date | Mon, 13 May 2024 14:15:47 -0400 | 
| parents | 1a6a5d3a94cd | 
| children | b1f625b0227c | 
| rev | line source | 
|---|---|
| 258 | 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 #endif | |
| 14 | |
| 266 
1a6a5d3a94cd
dep/animone: make bsd.cc and x11.cc actually work
 Paper <paper@paper.us.eu.org> parents: 
258diff
changeset | 15 #ifdef BSD | 
| 
1a6a5d3a94cd
dep/animone: make bsd.cc and x11.cc actually work
 Paper <paper@paper.us.eu.org> parents: 
258diff
changeset | 16 # include "animone/fd/bsd.h" | 
| 258 | 17 #endif | 
| 18 | |
| 19 namespace animone::internal { | |
| 20 | |
| 21 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) { | |
| 22 bool success = false; | |
| 23 | |
| 24 #ifdef WIN32 | |
| 25 success ^= win32::EnumerateOpenFiles(pids, open_file_proc); | |
| 26 #endif | |
| 27 | |
| 28 #ifdef LINUX | |
| 29 success ^= proc::EnumerateOpenFiles(pids, open_file_proc); | |
| 30 #endif | |
| 31 | |
| 32 #ifdef MACOSX | |
| 33 success ^= xnu::EnumerateOpenFiles(pids, open_file_proc); | |
| 34 #endif | |
| 35 | |
| 266 
1a6a5d3a94cd
dep/animone: make bsd.cc and x11.cc actually work
 Paper <paper@paper.us.eu.org> parents: 
258diff
changeset | 36 #ifdef BSD | 
| 
1a6a5d3a94cd
dep/animone: make bsd.cc and x11.cc actually work
 Paper <paper@paper.us.eu.org> parents: 
258diff
changeset | 37 success ^= bsd::EnumerateOpenFiles(pids, open_file_proc); | 
| 258 | 38 #endif | 
| 39 | |
| 40 return success; | |
| 41 } | |
| 42 | |
| 43 bool EnumerateOpenProcesses(process_proc_t process_proc) { | |
| 44 bool success = false; | |
| 45 | |
| 46 #ifdef WIN32 | |
| 47 success ^= win32::EnumerateOpenProcesses(process_proc); | |
| 48 #endif | |
| 49 | |
| 50 #ifdef LINUX | |
| 51 success ^= proc::EnumerateOpenProcesses(process_proc); | |
| 52 #endif | |
| 53 | |
| 54 #ifdef MACOSX | |
| 55 success ^= xnu::EnumerateOpenProcesses(process_proc); | |
| 56 #endif | |
| 57 | |
| 266 
1a6a5d3a94cd
dep/animone: make bsd.cc and x11.cc actually work
 Paper <paper@paper.us.eu.org> parents: 
258diff
changeset | 58 #ifdef BSD | 
| 
1a6a5d3a94cd
dep/animone: make bsd.cc and x11.cc actually work
 Paper <paper@paper.us.eu.org> parents: 
258diff
changeset | 59 success ^= bsd::EnumerateOpenProcesses(process_proc); | 
| 258 | 60 #endif | 
| 61 | |
| 62 return success; | |
| 63 } | |
| 64 | |
| 65 bool GetProcessName(pid_t pid, std::string& name) { | |
| 66 bool success = false; | |
| 67 | |
| 68 #ifdef WIN32 | |
| 69 success ^= win32::GetProcessName(pid, name); | |
| 70 #endif | |
| 71 | |
| 72 #ifdef LINUX | |
| 73 success ^= proc::GetProcessName(pid, name); | |
| 74 #endif | |
| 75 | |
| 76 #ifdef MACOSX | |
| 299 
246017a7907a
dep/animone: clean up OS X code
 Paper <paper@paper.us.eu.org> parents: 
266diff
changeset | 77 success ^= xnu::GetProcessName(pid, name); | 
| 258 | 78 #endif | 
| 79 | |
| 266 
1a6a5d3a94cd
dep/animone: make bsd.cc and x11.cc actually work
 Paper <paper@paper.us.eu.org> parents: 
258diff
changeset | 80 #ifdef BSD | 
| 
1a6a5d3a94cd
dep/animone: make bsd.cc and x11.cc actually work
 Paper <paper@paper.us.eu.org> parents: 
258diff
changeset | 81 success ^= bsd::GetProcessName(pid, name); | 
| 258 | 82 #endif | 
| 83 | |
| 84 return success; | |
| 85 } | |
| 86 | |
| 87 } // namespace animone::internal | 
