Index: base/environment.h |
diff --git a/base/environment.h b/base/environment.h |
index 5160ff2469f974786d089af4cc0dc07caa494b20..1f2b8f469c71e65a4c14baf8569405eec526764c 100644 |
--- a/base/environment.h |
+++ b/base/environment.h |
@@ -5,9 +5,12 @@ |
#ifndef BASE_ENVIRONMENT_H_ |
#define BASE_ENVIRONMENT_H_ |
+#include <map> |
#include <string> |
#include "base/base_export.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/strings/string16.h" |
#include "build/build_config.h" |
namespace base { |
@@ -43,6 +46,45 @@ class BASE_EXPORT Environment { |
virtual bool UnSetVar(const char* variable_name) = 0; |
}; |
+ |
+#if defined(OS_WIN) |
+ |
+typedef string16 NativeEnvironmentString; |
+typedef std::map<NativeEnvironmentString, NativeEnvironmentString> |
+ EnvironmentMap; |
+ |
+// Returns a modified environment vector constructed from the given environment |
+// and the list of changes given in |changes|. Each key in the environment is |
+// matched against the first element of the pairs. In the event of a match, the |
+// value is replaced by the second of the pair, unless the second is empty, in |
+// which case the key-value is removed. |
+// |
+// This Windows version takes and returns a Windows-style environment block |
+// which is a concatenated list of null-terminated 16-bit strings. The end is |
+// marked by a double-null terminator. The size of the returned string will |
+// include the terminators. |
+BASE_EXPORT string16 AlterEnvironment(const wchar_t* env, |
+ const EnvironmentMap& changes); |
+ |
+#elif defined(OS_POSIX) |
+ |
+typedef std::string NativeEnvironmentString; |
+typedef std::map<NativeEnvironmentString, NativeEnvironmentString> |
+ EnvironmentMap; |
+ |
+// See general comments for the Windows version above. |
+// |
+// This Posix version takes and returns a Posix-stle environment block, which |
viettrungluu
2013/08/09 19:27:11
s/stle/style/
|
+// is a null-terminated list of pointers to null-terminated strings. The |
+// returned array will have appended to it the storage for the array itself so |
+// there is only one pointer to manage, but this means that you can't copy the |
+// array without keeping the original around. |
+BASE_EXPORT scoped_ptr<char*[]> AlterEnvironment( |
+ const char* const* const env, |
viettrungluu
2013/08/09 19:27:11
Isn't the last (rightmost) const rather unusual/po
|
+ const EnvironmentMap& changes); |
+ |
+#endif |
+ |
} // namespace base |
#endif // BASE_ENVIRONMENT_H_ |