comparison system/System.cpp @ 1477:b60cb1637634 plugin-path-config

Setenv is nicer here
author Chris Cannam
date Thu, 07 Jun 2018 16:39:58 +0100
parents bd1a2cacd1e7
children 5ac102155409
comparison
equal deleted inserted replaced
1476:5afbac960a30 1477:b60cb1637634
392 } 392 }
393 393
394 bool 394 bool
395 putEnvUtf8(std::string variable, std::string value) 395 putEnvUtf8(std::string variable, std::string value)
396 { 396 {
397 #ifdef _WIN32
397 std::string entry = variable + "=" + value; 398 std::string entry = variable + "=" + value;
398 399
399 #ifdef _WIN32
400 int wentlen = MultiByteToWideChar(CP_UTF8, 0, 400 int wentlen = MultiByteToWideChar(CP_UTF8, 0,
401 entry.c_str(), int(entry.length()), 401 entry.c_str(), int(entry.length()),
402 0, 0); 402 0, 0);
403 if (wentlen < 0) { 403 if (wentlen < 0) {
404 SVCERR << "WARNING: Unable to convert environment entry to " 404 SVCERR << "WARNING: Unable to convert environment entry to "
422 } 422 }
423 return true; 423 return true;
424 424
425 #else 425 #else
426 426
427 int rv = putenv(entry.c_str()); 427 int rv = setenv(variable.c_str(), value.c_str(), 1);
428
429 if (rv != 0) { 428 if (rv != 0) {
430 SVCERR << "WARNING: Failed to set environment entry" << endl; 429 SVCERR << "WARNING: Failed to set environment entry" << endl;
431 return false; 430 return false;
432 } 431 }
433 return true; 432 return true;