# HG changeset patch # User Paper # Date 1699986433 18000 # Node ID aa4df5a8433859160ceb55683f90a668df13d3fb # Parent 6fdf0632c003085235b8c7459d1323f3462ef95d dep/animia: use std::pair instead of std::tuple diff -r 6fdf0632c003 -r aa4df5a84338 dep/animia/include/animia/fd.h --- a/dep/animia/include/animia/fd.h Tue Nov 14 13:19:40 2023 -0500 +++ b/dep/animia/include/animia/fd.h Tue Nov 14 13:27:13 2023 -0500 @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include @@ -15,7 +15,7 @@ public: virtual bool GetAllPids(std::set& pids) { return false; } virtual bool GetProcessName(pid_t pid, std::string& result) { return false; } - virtual bool EnumerateOpenFiles(const std::set& pids, std::vector>& files) { return false; } + virtual bool EnumerateOpenFiles(const std::set& pids, std::vector>& files) { return false; } }; extern BaseFdTools& fd; // defined in fd.cc diff -r 6fdf0632c003 -r aa4df5a84338 dep/animia/include/animia/fd/bsd.h --- a/dep/animia/include/animia/fd/bsd.h Tue Nov 14 13:19:40 2023 -0500 +++ b/dep/animia/include/animia/fd/bsd.h Tue Nov 14 13:27:13 2023 -0500 @@ -2,7 +2,7 @@ #define __animia__animia__fd__linux_h #include -#include +#include #include #include @@ -19,7 +19,7 @@ public: bool GetAllPids(std::set& pids) override; bool GetProcessName(pid_t pid, std::string& result) override; - bool EnumerateOpenFiles(const std::set& pids, std::vector>& files) override; + bool EnumerateOpenFiles(const std::set& pids, std::vector>& files) override; }; } diff -r 6fdf0632c003 -r aa4df5a84338 dep/animia/include/animia/fd/linux.h --- a/dep/animia/include/animia/fd/linux.h Tue Nov 14 13:19:40 2023 -0500 +++ b/dep/animia/include/animia/fd/linux.h Tue Nov 14 13:27:13 2023 -0500 @@ -2,7 +2,7 @@ #define __animia__animia__fd__linux_h #include -#include +#include #include #include @@ -20,7 +20,7 @@ public: bool GetAllPids(std::set& pids) override; bool GetProcessName(pid_t pid, std::string& result) override; - bool EnumerateOpenFiles(const std::set& pids, std::vector>& files) override; + bool EnumerateOpenFiles(const std::set& pids, std::vector>& files) override; }; } diff -r 6fdf0632c003 -r aa4df5a84338 dep/animia/include/animia/fd/win32.h --- a/dep/animia/include/animia/fd/win32.h Tue Nov 14 13:19:40 2023 -0500 +++ b/dep/animia/include/animia/fd/win32.h Tue Nov 14 13:27:13 2023 -0500 @@ -2,7 +2,7 @@ #define __animia__animia__fd__win32_h #include -#include +#include #include #include #include @@ -25,7 +25,7 @@ public: bool GetAllPids(std::set& pids) override; bool GetProcessName(pid_t pid, std::string& result) override; - bool EnumerateOpenFiles(const std::set& pids, std::vector>& files) override; + bool EnumerateOpenFiles(const std::set& pids, std::vector>& files) override; }; } diff -r 6fdf0632c003 -r aa4df5a84338 dep/animia/src/animia.cc --- a/dep/animia/src/animia.cc Tue Nov 14 13:19:40 2023 -0500 +++ b/dep/animia/src/animia.cc Tue Nov 14 13:27:13 2023 -0500 @@ -9,10 +9,17 @@ namespace animia { -static bool ProcessInPlayers(const std::vector& players, const std::string& name, Player& player_) { +static bool ProcessInPlayers(const std::vector& players, std::string name, Player& player_) { for (const auto& player : players) { for (const auto& exe : player.executables) { - if (exe == name.substr(0, name.rfind(".exe"))) { + /* this is only really relevant on Windows, and even then + executables can end in any number of extensions, so we should + really remove them all... */ + auto pos = name.rfind(".exe"); + if (pos != std::string::npos) + name = name.substr(0, pos); + + if (exe == name) { player_ = player; return true; } diff -r 6fdf0632c003 -r aa4df5a84338 dep/animia/src/fd/bsd.cc --- a/dep/animia/src/fd/bsd.cc Tue Nov 14 13:19:40 2023 -0500 +++ b/dep/animia/src/fd/bsd.cc Tue Nov 14 13:27:13 2023 -0500 @@ -84,7 +84,7 @@ } /* this only works on OS X :( */ -bool UnixFdTools::EnumerateOpenFiles(const std::set& pids, std::vector>& files) { +bool UnixFdTools::EnumerateOpenFiles(const std::set& pids, std::vector>& files) { for (const auto& pid : pids) { int bufsz = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0); if (bufsz == -1) diff -r 6fdf0632c003 -r aa4df5a84338 dep/animia/src/fd/linux.cc --- a/dep/animia/src/fd/linux.cc Tue Nov 14 13:19:40 2023 -0500 +++ b/dep/animia/src/fd/linux.cc Tue Nov 14 13:27:13 2023 -0500 @@ -124,7 +124,7 @@ return true; } -bool LinuxFdTools::EnumerateOpenFiles(const std::set& pids, std::vector>& files) { +bool LinuxFdTools::EnumerateOpenFiles(const std::set& pids, std::vector>& files) { for (const auto& pid : pids) { const std::string path = PROC_LOCATION "/" + std::to_string(pid) + "/fd"; diff -r 6fdf0632c003 -r aa4df5a84338 dep/animia/src/fd/win32.cc --- a/dep/animia/src/fd/win32.cc Tue Nov 14 13:19:40 2023 -0500 +++ b/dep/animia/src/fd/win32.cc Tue Nov 14 13:27:13 2023 -0500 @@ -243,7 +243,7 @@ } /* this could be changed to being a callback, but... I'm too lazy right now :) */ -bool Win32FdTools::EnumerateOpenFiles(const std::set& pids, std::vector>& files) { +bool Win32FdTools::EnumerateOpenFiles(const std::set& pids, std::vector>& files) { std::unordered_map proc_handles; for (const pid_t& pid : pids) { diff -r 6fdf0632c003 -r aa4df5a84338 dep/animia/src/strategist.cc --- a/dep/animia/src/strategist.cc Tue Nov 14 13:19:40 2023 -0500 +++ b/dep/animia/src/strategist.cc Tue Nov 14 13:27:13 2023 -0500 @@ -50,7 +50,7 @@ bool success = false; const std::set pids{result_.process.pid}; - std::vector> files; + std::vector> files; fd.EnumerateOpenFiles(pids, files);