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

Unified Diff: third_party/openvr/src/src/vrcommon/envvartools_public.cpp

Issue 2754253003: Add OpenVR SDK to third_party (Closed)
Patch Set: feedback 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 side-by-side diff with in-line comments
Download patch
Index: third_party/openvr/src/src/vrcommon/envvartools_public.cpp
diff --git a/third_party/openvr/src/src/vrcommon/envvartools_public.cpp b/third_party/openvr/src/src/vrcommon/envvartools_public.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..987bceb0257e41501f86b607cf792199fbe9081a
--- /dev/null
+++ b/third_party/openvr/src/src/vrcommon/envvartools_public.cpp
@@ -0,0 +1,46 @@
+//========= Copyright Valve Corporation ============//
+#include "envvartools_public.h"
+#include <stdlib.h>
+
+#if defined(_WIN32)
+#include <Windows.h>
+
+#undef GetEnvironmentVariable
+#undef SetEnvironmentVariable
+#endif
+
+
+std::string GetEnvironmentVariable( const char *pchVarName )
+{
+#if defined(_WIN32)
+ char rchValue[32767]; // max size for an env var on Windows
+ DWORD cChars = GetEnvironmentVariableA( pchVarName, rchValue, sizeof( rchValue ) );
+ if( cChars == 0 )
+ return "";
+ else
+ return rchValue;
+#elif defined(POSIX)
+ char *pchValue = getenv( pchVarName );
+ if( pchValue )
+ return pchValue;
+ else
+ return "";
+#else
+#error "Unsupported Platform"
+#endif
+}
+
+
+bool SetEnvironmentVariable( const char *pchVarName, const char *pchVarValue )
+{
+#if defined(_WIN32)
+ return 0 != SetEnvironmentVariableA( pchVarName, pchVarValue );
+#elif defined(POSIX)
+ if( pchVarValue == NULL )
+ return 0 == unsetenv( pchVarName );
+ else
+ return 0 == setenv( pchVarName, pchVarValue, 1 );
+#else
+#error "Unsupported Platform"
+#endif
+}
« no previous file with comments | « third_party/openvr/src/src/vrcommon/envvartools_public.h ('k') | third_party/openvr/src/src/vrcommon/hmderrors_public.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698