Mercurial > minori
comparison dep/animia/src/strategist.cc @ 139:478f3b366199
dep/animia: separate lots of things, use base class for OS stuff
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 12 Nov 2023 16:43:07 -0500 |
parents | 28842a8d0c6b |
children | 1e696863b54c |
comparison
equal
deleted
inserted
replaced
138:28842a8d0c6b | 139:478f3b366199 |
---|---|
1 #include "animia/strategies.h" | 1 #include "animia/strategies.h" |
2 #include "animia/util.h" | 2 #include "animia/util.h" |
3 #include "animia/fd.h" | |
3 #include "animia.h" | 4 #include "animia.h" |
4 #include <iostream> | 5 #include <iostream> |
5 | |
6 #ifdef ANIMIA_ON_WIN32 | |
7 # include "animia/fd/win32.h" | |
8 #elif defined(ANIMIA_ON_LINUX) | |
9 # include "animia/fd/linux.h" | |
10 #elif defined(ANIMIA_ON_UNIX) | |
11 # include "animia/fd/bsd.h" | |
12 #endif | |
13 | 6 |
14 namespace animia::internal { | 7 namespace animia::internal { |
15 | 8 |
16 class Strategist { | 9 class Strategist { |
17 public: | 10 public: |
58 bool success = false; | 51 bool success = false; |
59 | 52 |
60 const std::set<pid_t> pids{result_.process.pid}; | 53 const std::set<pid_t> pids{result_.process.pid}; |
61 std::vector<std::tuple<pid_t, std::string>> files; | 54 std::vector<std::tuple<pid_t, std::string>> files; |
62 | 55 |
63 #ifdef ANIMIA_ON_WIN32 | 56 fd.EnumerateOpenFiles(pids, files); |
64 win32::EnumerateOpenFiles(pids, files); | |
65 #elif defined(ANIMIA_ON_LINUX) | |
66 linux::EnumerateOpenFiles(pids, files); | |
67 #elif defined(ANIMIA_ON_UNIX) | |
68 unix::EnumerateOpenFiles(pids, files); | |
69 #endif | |
70 | 57 |
71 for (const auto& [pid, file] : files) { | 58 for (const auto& [pid, file] : files) { |
72 success |= AddMedia({MediaInfoType::File, file}); | 59 success |= AddMedia({MediaInfoType::File, file}); |
73 } | 60 } |
74 | 61 |