Remove Linux sys_ExecutablePathname fallback

The fallback is of little value and blocks making cxxtest an optional
build dependency. While at it use realpath instead of readlink.

Refs: #8618
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser 2025-12-20 14:00:13 +01:00
parent 6fc47e2997
commit 349478aa6b
No known key found for this signature in database
2 changed files with 6 additions and 28 deletions

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -23,37 +23,15 @@
#include "precompiled.h"
#include "lib/os_path.h"
#include "lib/posix/posix_types.h"
#include "lib/sysdep/os/unix/unix_executable_pathname.h"
#include "lib/sysdep/sysdep.h"
#include <climits>
#include <cstring>
static bool getPathFromProc(char* buffer, size_t length)
{
int pos = readlink("/proc/self/exe", buffer, length-1);
if (pos <= 0)
return false;
buffer[pos] = '\0';
char* endOfPath = strrchr(buffer, '/');
if (endOfPath == NULL)
return false;
++endOfPath;
*endOfPath = '\0';
return true;
}
#include <stdlib.h>
OsPath sys_ExecutablePathname()
{
// Check /proc for the path
char pathBuffer[PATH_MAX];
if (getPathFromProc(pathBuffer, sizeof(pathBuffer)))
return pathBuffer;
return unix_ExecutablePathname();
if (realpath("/proc/self/exe", pathBuffer) == nullptr)
return {};
return pathBuffer;
}

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the