SDK Windows: more ways to find java.
Also properly redirect command-line output
to the parent shell console.
This is experimental. This CL removes "android.exe"
from the Windows tools and only keeps android.bat.
However in a next CL android.bat will be changed
to use 'find_java' to locate the best Java exe around
(this is currently done in a bat script)
Change-Id: I6e5485fdf59fde9838cf929ff333e1c611ea7bb4
diff --git a/sdkmanager/win_android/utils.h b/sdkmanager/win_android/utils.h
index 8c5cdb7..4530380 100755
--- a/sdkmanager/win_android/utils.h
+++ b/sdkmanager/win_android/utils.h
@@ -19,6 +19,8 @@
#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS 1
+
#include <direct.h>
#include <stdio.h>
#include <stdarg.h>
@@ -68,14 +70,20 @@
char *mStr;
public:
CString() { mStr = NULL; }
- CString(const CString &str) { mStr = str.mStr == NULL ? NULL : _strdup(str.mStr); }
+ CString(const CString &str) { mStr = NULL; set(str.mStr); }
explicit CString(const char *str) { mStr = NULL; set(str); }
CString(const char *start, int length) { mStr = NULL; set(start, length); }
+ CString& operator=(const CString &str) {
+ return set(str.cstr());
+ }
+
CString& set(const char *str) {
- _free();
- if (str != NULL) {
- mStr = _strdup(str);
+ if (str != mStr) {
+ _free();
+ if (str != NULL) {
+ mStr = _strdup(str);
+ }
}
return *this;
}
@@ -211,10 +219,16 @@
class CPath : public CString {
public:
CPath() : CString() { }
+ CPath(const CString &str) : CString(str) { }
CPath(const CPath &str) : CString(str) { }
explicit CPath(const char *str) : CString(str) { }
CPath(const char *start, int length) : CString(start, length) { }
+ CPath& operator=(const CPath &str) {
+ set(str.cstr());
+ return *this;
+ }
+
// Appends a path segment, adding a \ as necessary.
CPath& addPath(const CString &s) {
return addPath(s.cstr());