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

Side by Side Diff: runtime/bin/process.cc

Issue 11558012: Use FormatMessageW for Windows error messages to handle internationalized messages correctly. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/process.h ('k') | runtime/bin/process_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 #include "bin/io_buffer.h" 6 #include "bin/io_buffer.h"
7 #include "bin/process.h" 7 #include "bin/process.h"
8 #include "bin/socket.h" 8 #include "bin/socket.h"
9 9
10 #include "include/dart_api.h" 10 #include "include/dart_api.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 Dart_SetReturnValue(args, Dart_NewBoolean(false)); 115 Dart_SetReturnValue(args, Dart_NewBoolean(false));
116 Dart_ExitScope(); 116 Dart_ExitScope();
117 return; 117 return;
118 } 118 }
119 } 119 }
120 Dart_Handle in_handle = Dart_GetNativeArgument(args, 5); 120 Dart_Handle in_handle = Dart_GetNativeArgument(args, 5);
121 Dart_Handle out_handle = Dart_GetNativeArgument(args, 6); 121 Dart_Handle out_handle = Dart_GetNativeArgument(args, 6);
122 Dart_Handle err_handle = Dart_GetNativeArgument(args, 7); 122 Dart_Handle err_handle = Dart_GetNativeArgument(args, 7);
123 Dart_Handle exit_handle = Dart_GetNativeArgument(args, 8); 123 Dart_Handle exit_handle = Dart_GetNativeArgument(args, 8);
124 intptr_t pid = -1; 124 intptr_t pid = -1;
125 static const int kMaxChildOsErrorMessageLength = 256; 125 char* os_error_message = NULL;
126 char os_error_message[kMaxChildOsErrorMessageLength];
127 126
128 int error_code = Process::Start(path, 127 int error_code = Process::Start(path,
129 string_args, 128 string_args,
130 args_length, 129 args_length,
131 working_directory, 130 working_directory,
132 string_environment, 131 string_environment,
133 environment_length, 132 environment_length,
134 &in, 133 &in,
135 &out, 134 &out,
136 &err, 135 &err,
137 &pid, 136 &pid,
138 &exit_event, 137 &exit_event,
139 os_error_message, kMaxChildOsErrorMessageLength); 138 &os_error_message);
140 if (error_code == 0) { 139 if (error_code == 0) {
141 Socket::SetSocketIdNativeField(in_handle, in); 140 Socket::SetSocketIdNativeField(in_handle, in);
142 Socket::SetSocketIdNativeField(out_handle, out); 141 Socket::SetSocketIdNativeField(out_handle, out);
143 Socket::SetSocketIdNativeField(err_handle, err); 142 Socket::SetSocketIdNativeField(err_handle, err);
144 Socket::SetSocketIdNativeField(exit_handle, exit_event); 143 Socket::SetSocketIdNativeField(exit_handle, exit_event);
145 Process::SetProcessIdNativeField(process, pid); 144 Process::SetProcessIdNativeField(process, pid);
146 } else { 145 } else {
147 DartUtils::SetIntegerField( 146 DartUtils::SetIntegerField(
148 status_handle, "_errorCode", error_code); 147 status_handle, "_errorCode", error_code);
149 DartUtils::SetStringField( 148 DartUtils::SetStringField(
150 status_handle, "_errorMessage", os_error_message); 149 status_handle, "_errorMessage", os_error_message);
151 } 150 }
152 delete[] string_args; 151 delete[] string_args;
153 delete[] string_environment; 152 delete[] string_environment;
153 free(os_error_message);
154 Dart_SetReturnValue(args, Dart_NewBoolean(error_code == 0)); 154 Dart_SetReturnValue(args, Dart_NewBoolean(error_code == 0));
155 Dart_ExitScope(); 155 Dart_ExitScope();
156 } 156 }
157 157
158 158
159 void FUNCTION_NAME(Process_Kill)(Dart_NativeArguments args) { 159 void FUNCTION_NAME(Process_Kill)(Dart_NativeArguments args) {
160 Dart_EnterScope(); 160 Dart_EnterScope();
161 Dart_Handle process = Dart_GetNativeArgument(args, 1); 161 Dart_Handle process = Dart_GetNativeArgument(args, 1);
162 intptr_t pid = -1; 162 intptr_t pid = -1;
163 Process::GetProcessIdNativeField(process, &pid); 163 Process::GetProcessIdNativeField(process, &pid);
(...skipping 23 matching lines...) Expand all
187 Dart_Handle result = Dart_ListLength(bytes, &bytes_length); 187 Dart_Handle result = Dart_ListLength(bytes, &bytes_length);
188 if (Dart_IsError(result)) Dart_PropagateError(result); 188 if (Dart_IsError(result)) Dart_PropagateError(result);
189 uint8_t* buffer = new uint8_t[bytes_length + 1]; 189 uint8_t* buffer = new uint8_t[bytes_length + 1];
190 result = Dart_ListGetAsBytes(bytes, 0, buffer, bytes_length); 190 result = Dart_ListGetAsBytes(bytes, 0, buffer, bytes_length);
191 buffer[bytes_length] = '\0'; 191 buffer[bytes_length] = '\0';
192 if (Dart_IsError(result)) { 192 if (Dart_IsError(result)) {
193 delete[] buffer; 193 delete[] buffer;
194 Dart_PropagateError(result); 194 Dart_PropagateError(result);
195 } 195 }
196 char* str = 196 char* str =
197 StringUtils::SystemStringToUtf8(reinterpret_cast<char*>(buffer)); 197 StringUtils::ConsoleStringToUtf8(reinterpret_cast<char*>(buffer));
198 Dart_SetReturnValue(args, DartUtils::NewString(str)); 198 Dart_SetReturnValue(args, DartUtils::NewString(str));
199 if (str != reinterpret_cast<char*>(buffer)) free(str); 199 if (str != reinterpret_cast<char*>(buffer)) free(str);
200 Dart_ExitScope(); 200 Dart_ExitScope();
201 } 201 }
202 202
203 203
204 void FUNCTION_NAME(StringToSystemEncoding)(Dart_NativeArguments args) { 204 void FUNCTION_NAME(StringToSystemEncoding)(Dart_NativeArguments args) {
205 Dart_EnterScope(); 205 Dart_EnterScope();
206 Dart_Handle str = Dart_GetNativeArgument(args, 0); 206 Dart_Handle str = Dart_GetNativeArgument(args, 0);
207 const char* utf8 = DartUtils::GetStringValue(str); 207 const char* utf8 = DartUtils::GetStringValue(str);
208 const char* system_string = StringUtils::Utf8ToSystemString(utf8); 208 const char* system_string = StringUtils::Utf8ToConsoleString(utf8);
209 int external_length = strlen(system_string); 209 int external_length = strlen(system_string);
210 uint8_t* buffer = NULL; 210 uint8_t* buffer = NULL;
211 Dart_Handle external_array = IOBuffer::Allocate(external_length, &buffer); 211 Dart_Handle external_array = IOBuffer::Allocate(external_length, &buffer);
212 memmove(buffer, system_string, external_length); 212 memmove(buffer, system_string, external_length);
213 if (utf8 != system_string) free(const_cast<char*>(system_string)); 213 if (utf8 != system_string) free(const_cast<char*>(system_string));
214 Dart_SetReturnValue(args, external_array); 214 Dart_SetReturnValue(args, external_array);
215 Dart_ExitScope(); 215 Dart_ExitScope();
216 } 216 }
OLDNEW
« no previous file with comments | « runtime/bin/process.h ('k') | runtime/bin/process_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698