|
3 | 3 |
|
4 | 4 | #include "download.h" |
5 | 5 |
|
6 | | -#include <cpp-httplib/httplib.h> |
| 6 | +#include <cpp-httplib/httplib.h> // TODO: remove this once we use HTTP client from download.h |
7 | 7 | #include <sheredom/subprocess.h> |
8 | 8 |
|
9 | 9 | #include <functional> |
|
23 | 23 | #include <unistd.h> |
24 | 24 | #endif |
25 | 25 |
|
26 | | -#if defined(__APPLE__) && defined(__MACH__) |
27 | | -// macOS: use _NSGetExecutablePath to get the executable path |
28 | | -#include <mach-o/dyld.h> |
29 | | -#include <limits.h> |
30 | | -#endif |
31 | | - |
32 | 26 | #define CMD_EXIT "exit" |
33 | 27 |
|
34 | | -static std::filesystem::path get_server_exec_path() { |
35 | | -#if defined(_WIN32) |
36 | | - wchar_t buf[32768] = { 0 }; // Large buffer to handle long paths |
37 | | - DWORD len = GetModuleFileNameW(nullptr, buf, _countof(buf)); |
38 | | - if (len == 0 || len >= _countof(buf)) { |
39 | | - throw std::runtime_error("GetModuleFileNameW failed or path too long"); |
40 | | - } |
41 | | - return std::filesystem::path(buf); |
42 | | -#elif defined(__APPLE__) && defined(__MACH__) |
43 | | - char small_path[PATH_MAX]; |
44 | | - uint32_t size = sizeof(small_path); |
45 | | - |
46 | | - if (_NSGetExecutablePath(small_path, &size) == 0) { |
47 | | - // resolve any symlinks to get absolute path |
48 | | - try { |
49 | | - return std::filesystem::canonical(std::filesystem::path(small_path)); |
50 | | - } catch (...) { |
51 | | - return std::filesystem::path(small_path); |
52 | | - } |
53 | | - } else { |
54 | | - // buffer was too small, allocate required size and call again |
55 | | - std::vector<char> buf(size); |
56 | | - if (_NSGetExecutablePath(buf.data(), &size) == 0) { |
57 | | - try { |
58 | | - return std::filesystem::canonical(std::filesystem::path(buf.data())); |
59 | | - } catch (...) { |
60 | | - return std::filesystem::path(buf.data()); |
61 | | - } |
62 | | - } |
63 | | - throw std::runtime_error("_NSGetExecutablePath failed after buffer resize"); |
64 | | - } |
65 | | -#else |
66 | | - char path[FILENAME_MAX]; |
67 | | - ssize_t count = readlink("/proc/self/exe", path, FILENAME_MAX); |
68 | | - if (count <= 0) { |
69 | | - throw std::runtime_error("failed to resolve /proc/self/exe"); |
70 | | - } |
71 | | - return std::filesystem::path(std::string(path, count)); |
72 | | -#endif |
73 | | -} |
74 | | - |
75 | 28 | struct local_model { |
76 | 29 | std::string name; |
77 | 30 | std::string path; |
@@ -364,7 +317,6 @@ void server_models::load(const std::string & name, bool auto_load) { |
364 | 317 |
|
365 | 318 | inst.subproc = std::make_shared<subprocess_s>(); |
366 | 319 | { |
367 | | - //std::string exec_path = get_server_exec_path().string(); |
368 | 320 | SRV_INF("spawning server instance with name=%s on port %d\n", inst.meta.name.c_str(), inst.meta.port); |
369 | 321 |
|
370 | 322 | std::vector<std::string> child_args; |
|
0 commit comments