|
18 | 18 | #include <windows.h>
|
19 | 19 | #include <shlobj.h>
|
20 | 20 | #else
|
21 |
| -#include <cstdlib> |
22 | 21 | #include <sys/types.h>
|
23 | 22 | #include <pwd.h>
|
24 | 23 | #endif
|
@@ -170,7 +169,7 @@ std::string Telemetry::generateData(std::string event_name, std::map<std::string
|
170 | 169 | // check ENV for test variable FLAMEGPU_TEST_ENVIRONMENT
|
171 | 170 | std::string testmode = isTestMode() ? "true" : "false";
|
172 | 171 | std::string appID = TELEMETRY_APP_ID;
|
173 |
| - std::string telemetryRandomID = Telemetry::getUserId(); // Obtain a unique user ID |
| 172 | + std::string telemetryRandomID = Telemetry::getUserId(); // Obtain a unique user ID |
174 | 173 |
|
175 | 174 | // Differentiate pyflamegpu in the payload via the SWIG compiler macro, which we only define when building for pyflamegpu.
|
176 | 175 | // A user could potentially static link against a build using that macro, but that's not a use-case we are currently concerned with.
|
@@ -320,7 +319,7 @@ std::string Telemetry::getConfigDirectory() {
|
320 | 319 | return std::string(home) + "/.config";
|
321 | 320 | }
|
322 | 321 | else {
|
323 |
| - struct passwd* pwd = getpwuid(getuid()); |
| 322 | + struct passwd* pwd = getpwuid_r(getuid()); |
324 | 323 | if (pwd) {
|
325 | 324 | return std::string(pwd->pw_dir) + "/.config";
|
326 | 325 | }
|
@@ -354,16 +353,16 @@ std::string Telemetry::getUserId() {
|
354 | 353 | try {
|
355 | 354 | // Determine config file location
|
356 | 355 | std::string configDir = Telemetry::getConfigDirectory() + "/FLAMEGPU";
|
357 |
| - std::filesystem::create_directories(configDir); // Ensure the directory exists |
| 356 | + std::filesystem::create_directories(configDir); // Ensure the directory exists |
358 | 357 | std::string filePath = configDir + "/flamegpu_user.cfg";
|
359 | 358 |
|
360 | 359 | // Check if the file exists
|
361 | 360 | if (std::filesystem::exists(filePath)) {
|
362 | 361 | std::ifstream file(filePath);
|
363 | 362 | if (file.is_open()) {
|
364 |
| - std::getline(file, userId); // overwrite existing Id |
| 363 | + std::getline(file, userId); // overwrite existing Id |
365 | 364 | file.close();
|
366 |
| - return userId; // Config file and user id found so return it |
| 365 | + return userId; // Config file and user id found so return it |
367 | 366 | }
|
368 | 367 | else {
|
369 | 368 | throw std::runtime_error("Unable to open user ID file for reading");
|
|
0 commit comments