| 53 | |
| 54 | private: |
| 55 | bool GetVarImpl(const char* variable_name, std::string* result) { |
| 56 | #if defined(OS_POSIX) |
| 57 | const char* env_value = getenv(variable_name); |
| 58 | if (!env_value) |
| 59 | return false; |
| 60 | // Note that the variable may be defined but empty. |
| 61 | if (result) |
| 62 | *result = env_value; |
| 63 | return true; |
| 64 | #elif defined(OS_WIN) |
| 65 | DWORD value_length = ::GetEnvironmentVariable( |
| 66 | UTF8ToWide(variable_name).c_str(), NULL, 0); |
| 67 | if (value_length == 0) |
| 68 | return false; |
| 69 | if (result) { |
| 70 | scoped_ptr<wchar_t[]> value(new wchar_t[value_length]); |
| 71 | ::GetEnvironmentVariable(UTF8ToWide(variable_name).c_str(), value.get(), |
| 72 | value_length); |
| 73 | *result = WideToUTF8(value.get()); |
| 74 | } |
| 75 | return true; |
| 76 | #else |
| 77 | #error need to port |
| 78 | #endif |
| 79 | } |
| 80 | |
| 81 | bool SetVarImpl(const char* variable_name, const std::string& new_value) { |
| 82 | #if defined(OS_POSIX) |
nothing calls this directly
no test coverage detected