MCPcopy Create free account
hub / github.com/SFML/SFML / findExecutableName

Function findExecutableName

src/SFML/Window/Unix/WindowImplX11.cpp:120–151  ·  view source on GitHub ↗

Find the name of the current executable

Source from the content-addressed store, hash-verified

118
119// Find the name of the current executable
120std::filesystem::path findExecutableName()
121{
122 // We use /proc/self/cmdline to get the command line
123 // the user used to invoke this instance of the application
124 const int file = ::open("/proc/self/cmdline", O_RDONLY | O_NONBLOCK);
125
126 if (file < 0)
127 return "sfml";
128
129 std::vector<char> buffer(256, 0);
130 std::size_t offset = 0;
131 ssize_t result = 0;
132
133 while ((result = read(file, &buffer[offset], 256)) > 0)
134 {
135 buffer.resize(buffer.size() + static_cast<std::size_t>(result), 0);
136 offset += static_cast<std::size_t>(result);
137 }
138
139 ::close(file);
140
141 if (offset)
142 {
143 buffer[offset] = 0;
144
145 // Remove the path to keep the executable name only
146 return basename(buffer.data());
147 }
148
149 // Default fallback name
150 return "sfml";
151}
152
153// Get features supported by the current window manager
154const std::vector<std::string>& getSupportedFeatures()

Callers 1

WindowImplX11Method · 0.85

Calls 3

closeFunction · 0.85
readFunction · 0.50
resizeMethod · 0.45

Tested by

no test coverage detected