OLD | NEW |
---|---|
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include "tools/tool_support.h" | 15 #include "tools/tool_support.h" |
16 | 16 |
17 #include <stdio.h> | 17 #include <stdio.h> |
18 | 18 |
19 #include <vector> | |
20 | |
19 #include "package.h" | 21 #include "package.h" |
22 #include "base/memory/scoped_ptr.h" | |
23 #include "base/strings/utf_string_conversions.h" | |
20 | 24 |
21 namespace crashpad { | 25 namespace crashpad { |
22 | 26 |
23 // static | 27 // static |
24 void ToolSupport::Version(const base::FilePath& me) { | 28 void ToolSupport::Version(const base::FilePath& me) { |
25 fprintf(stderr, | 29 fprintf(stderr, |
26 "%s" PRFilePath " (%s) %s\n%s\n", | 30 "%s" PRFilePath " (%s) %s\n%s\n", |
27 me.value().c_str(), | 31 me.value().c_str(), |
28 PACKAGE_NAME, | 32 PACKAGE_NAME, |
29 PACKAGE_VERSION, | 33 PACKAGE_VERSION, |
(...skipping 30 matching lines...) Expand all Loading... | |
60 void ToolSupport::UsageTail(const std::string& me) { | 64 void ToolSupport::UsageTail(const std::string& me) { |
61 UsageTail(base::FilePath(me)); | 65 UsageTail(base::FilePath(me)); |
62 } | 66 } |
63 | 67 |
64 // static | 68 // static |
65 void ToolSupport::UsageHint(const std::string& me, const char* hint) { | 69 void ToolSupport::UsageHint(const std::string& me, const char* hint) { |
66 UsageHint(base::FilePath(me), hint); | 70 UsageHint(base::FilePath(me), hint); |
67 } | 71 } |
68 #endif // OS_POSIX | 72 #endif // OS_POSIX |
69 | 73 |
74 #if defined(OS_WIN) | |
75 // static | |
76 int ToolSupport::Wmain(int argc, wchar_t* argv[], int (*entry)(int, char*[])) { | |
77 scoped_ptr<char*[]> argv_as_utf8(new char*[argc + 1]); | |
78 std::vector<std::string> storage; | |
79 storage.reserve(argc); | |
80 for (int i = 0; i < argc; ++i) { | |
81 storage.push_back(base::UTF16ToUTF8(argv[i])); | |
82 argv_as_utf8[i] = &storage[i][0]; | |
83 } | |
84 argv_as_utf8[argc] = nullptr; | |
85 return entry(argc, argv_as_utf8.get()); | |
86 } | |
87 #endif // OS_WIN | |
88 | |
89 #if defined(OS_POSIX) | |
90 // static | |
91 base::FilePath::StringType ToolSupport::UTF8ToFilePathStringType( | |
92 const char* path) { | |
93 return path; | |
Mark Mentovai
2015/05/05 22:41:36
The #ifs can go inside the function body for this
scottmg
2015/05/05 23:23:52
Done.
| |
94 } | |
95 #elif defined(OS_WIN) | |
96 // static | |
97 base::FilePath::StringType ToolSupport::UTF8ToFilePathStringType( | |
98 const char* path) { | |
99 return base::UTF8ToUTF16(path); | |
100 } | |
101 #endif // OS_POSIX | |
102 | |
70 } // namespace crashpad | 103 } // namespace crashpad |
OLD | NEW |