1 //
2 // Copyright 2018 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // system_utils.cpp: Implementation of common functions
8 
9 #include "system_utils.h"
10 
11 namespace angle
12 {
13 
PrependPathToEnvironmentVar(const char * variableName,const char * path)14 bool PrependPathToEnvironmentVar(const char *variableName, const char *path)
15 {
16     std::string oldValue = GetEnvironmentVar(variableName);
17     const char *newValue = nullptr;
18     std::string buf;
19     if (oldValue.empty())
20     {
21         newValue = path;
22     }
23     else
24     {
25         buf = path;
26         buf += GetPathSeparator();
27         buf += oldValue;
28         newValue = buf.c_str();
29     }
30     return SetEnvironmentVar(variableName, newValue);
31 }
32 
33 }  // namespace angle
34