Skip to content

Commit f2dbe9c

Browse files
committed
rm unused fn
1 parent d182544 commit f2dbe9c

File tree

1 file changed

+1
-49
lines changed

1 file changed

+1
-49
lines changed

tools/server/server-models.cpp

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "download.h"
55

6-
#include <cpp-httplib/httplib.h>
6+
#include <cpp-httplib/httplib.h> // TODO: remove this once we use HTTP client from download.h
77
#include <sheredom/subprocess.h>
88

99
#include <functional>
@@ -23,55 +23,8 @@
2323
#include <unistd.h>
2424
#endif
2525

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-
3226
#define CMD_EXIT "exit"
3327

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-
7528
struct local_model {
7629
std::string name;
7730
std::string path;
@@ -364,7 +317,6 @@ void server_models::load(const std::string & name, bool auto_load) {
364317

365318
inst.subproc = std::make_shared<subprocess_s>();
366319
{
367-
//std::string exec_path = get_server_exec_path().string();
368320
SRV_INF("spawning server instance with name=%s on port %d\n", inst.meta.name.c_str(), inst.meta.port);
369321

370322
std::vector<std::string> child_args;

0 commit comments

Comments
 (0)