blob: 8248f58d972c1798dcd32f593afa2e7b962af101 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "fix-argv0.hpp"
#include <cstring>
namespace floormat {
char* fix_argv0(char* argv0) noexcept
{
#ifdef _WIN32
if (auto* c = std::strrchr(argv0, '\\'); c && c[1])
{
if (auto* s = std::strrchr(c, '.'); s && !std::strcmp(".exe", s))
*s = '\0';
return c+1;
}
#else
if (auto* c = std::strrchr(argv0, '/'); c && c[1])
return c+1;
#endif
return argv0;
}
} // namespace floormat
|