diff --git a/source/lib/sysdep/os/linux/linux.cpp b/source/lib/sysdep/os/linux/linux.cpp index 44e9afc61b..2bb6d5ed1f 100644 --- a/source/lib/sysdep/os/linux/linux.cpp +++ b/source/lib/sysdep/os/linux/linux.cpp @@ -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 -#include - -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 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; } diff --git a/source/lib/sysdep/tests/test_sysdep.h b/source/lib/sysdep/tests/test_sysdep.h index 5ed9b1f8cc..a217f30d7f 100644 --- a/source/lib/sysdep/tests/test_sysdep.h +++ b/source/lib/sysdep/tests/test_sysdep.h @@ -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