Differences From Artifact [e75a0d88c9]:
- File
src/OFStdIOStream_Win32Console.m
— part of check-in
[4f36894ce7]
at
2017-06-05 17:36:28
on branch trunk
— Clean up exceptions a little
This removes several initializers that omitted the errNo. Removing those
forces to think about whether there is a meaningful errNo to set instead
of just omitting it. (user: js, size: 8084) [annotate] [blame] [check-ins using]
To Artifact [451d779be8]:
- File
src/OFStdIOStream_Win32Console.m
— part of check-in
[2ae01218ef]
at
2017-06-12 22:29:41
on branch trunk
— OFWriteFailedException: Add -[bytesWritten]
This allows retrieving the number of bytes already written before the
write failed, allowing to retry without writing data that has already
been written. (user: js, size: 8471) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
229 230 231 232 233 234 235 | @throw [OFOutOfRangeException exception]; if (_incompleteUTF8SurrogateLen > 0) { of_unichar_t c; char16_t UTF16[2]; ssize_t UTF8Len; size_t toCopy; | | | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | @throw [OFOutOfRangeException exception]; if (_incompleteUTF8SurrogateLen > 0) { of_unichar_t c; char16_t UTF16[2]; ssize_t UTF8Len; size_t toCopy; DWORD UTF16Len, bytesWritten; UTF8Len = -of_string_utf8_decode( _incompleteUTF8Surrogate, _incompleteUTF8SurrogateLen, &c); OF_ENSURE(UTF8Len > 0); toCopy = UTF8Len - _incompleteUTF8SurrogateLen; |
︙ | ︙ | |||
267 268 269 270 271 272 273 | UTF16Len = 2; } else { UTF16[0] = c; UTF16Len = 1; } } | | > > > > > > > | > | | | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | UTF16Len = 2; } else { UTF16[0] = c; UTF16Len = 1; } } if (!WriteConsoleW(_handle, UTF16, UTF16Len, &bytesWritten, NULL)) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: UTF16Len * 2 bytesWritten: 0 errNo: EIO]; if (bytesWritten != UTF16Len) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: UTF16Len * 2 bytesWritten: bytesWritten * 2 errNo: 0]; _incompleteUTF8SurrogateLen = 0; i += toCopy; } tmp = [self allocMemoryWithSize: sizeof(char16_t) count: length * 2]; @try { DWORD bytesWritten; while (i < length) { of_unichar_t c; ssize_t UTF8Len; UTF8Len = of_string_utf8_decode(buffer + i, length - i, &c); |
︙ | ︙ | |||
319 320 321 322 323 324 325 | i += UTF8Len; } if (j > UINT32_MAX) @throw [OFOutOfRangeException exception]; | | > > > > > > | > | | 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | i += UTF8Len; } if (j > UINT32_MAX) @throw [OFOutOfRangeException exception]; if (!WriteConsoleW(_handle, tmp, (DWORD)j, &bytesWritten, NULL)) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: j * 2 bytesWritten: 0 errNo: EIO]; if (bytesWritten != j) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: j * 2 bytesWritten: bytesWritten * 2 errNo: 0]; } @finally { [self freeMemory: tmp]; } } @end |