Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: third_party/openvr/src/src/vrcommon/envvartools_public.cpp

Issue 2754253003: Add OpenVR SDK to third_party (Closed)
Patch Set: rebase and fix copyright Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 //========= Copyright Valve Corporation ============//
2 #include "envvartools_public.h"
3 #include <stdlib.h>
4
5 #if defined(_WIN32)
6 #include <Windows.h>
7
8 #undef GetEnvironmentVariable
9 #undef SetEnvironmentVariable
10 #endif
11
12
13 std::string GetEnvironmentVariable( const char *pchVarName )
14 {
15 #if defined(_WIN32)
16 char rchValue[32767]; // max size for an env var on Windows
17 DWORD cChars = GetEnvironmentVariableA( pchVarName, rchValue, sizeof( rc hValue ) );
18 if( cChars == 0 )
19 return "";
20 else
21 return rchValue;
22 #elif defined(POSIX)
23 char *pchValue = getenv( pchVarName );
24 if( pchValue )
25 return pchValue;
26 else
27 return "";
28 #else
29 #error "Unsupported Platform"
30 #endif
31 }
32
33
34 bool SetEnvironmentVariable( const char *pchVarName, const char *pchVarValue )
35 {
36 #if defined(_WIN32)
37 return 0 != SetEnvironmentVariableA( pchVarName, pchVarValue );
38 #elif defined(POSIX)
39 if( pchVarValue == NULL )
40 return 0 == unsetenv( pchVarName );
41 else
42 return 0 == setenv( pchVarName, pchVarValue, 1 );
43 #else
44 #error "Unsupported Platform"
45 #endif
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698