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

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

Issue 13828005: dart:io | Remove some unneeded global error save/restore pairs on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months 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 | « no previous file | no next file » | 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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <fcntl.h> // NOLINT 10 #include <fcntl.h> // NOLINT
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 FSCTL_GET_REPARSE_POINT, 318 FSCTL_GET_REPARSE_POINT,
319 NULL, 319 NULL,
320 0, 320 0,
321 buffer, 321 buffer,
322 buffer_size, 322 buffer_size,
323 &received_bytes, 323 &received_bytes,
324 NULL); 324 NULL);
325 if (result == 0) { 325 if (result == 0) {
326 DWORD error = GetLastError(); 326 DWORD error = GetLastError();
327 CloseHandle(dir_handle); 327 CloseHandle(dir_handle);
328 SetLastError(error);
328 free(buffer); 329 free(buffer);
329 SetLastError(error);
330 return NULL; 330 return NULL;
331 } 331 }
332 if (CloseHandle(dir_handle) == 0) { 332 if (CloseHandle(dir_handle) == 0) {
333 DWORD error = GetLastError();
334 free(buffer); 333 free(buffer);
335 SetLastError(error);
336 return NULL; 334 return NULL;
337 } 335 }
338 336
339 wchar_t* target; 337 wchar_t* target;
340 size_t target_offset; 338 size_t target_offset;
341 size_t target_length; 339 size_t target_length;
342 if (buffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { 340 if (buffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
343 target = buffer->MountPointReparseBuffer.PathBuffer; 341 target = buffer->MountPointReparseBuffer.PathBuffer;
344 target_offset = buffer->MountPointReparseBuffer.SubstituteNameOffset; 342 target_offset = buffer->MountPointReparseBuffer.SubstituteNameOffset;
345 target_length = buffer->MountPointReparseBuffer.SubstituteNameLength; 343 target_length = buffer->MountPointReparseBuffer.SubstituteNameLength;
(...skipping 25 matching lines...) Expand all
371 NULL); 369 NULL);
372 char* utf8_target = reinterpret_cast<char*>(malloc(utf8_length + 1)); 370 char* utf8_target = reinterpret_cast<char*>(malloc(utf8_length + 1));
373 if (0 == WideCharToMultiByte(CP_UTF8, 371 if (0 == WideCharToMultiByte(CP_UTF8,
374 0, 372 0,
375 target, 373 target,
376 target_length, 374 target_length,
377 utf8_target, 375 utf8_target,
378 utf8_length, 376 utf8_length,
379 NULL, 377 NULL,
380 NULL)) { 378 NULL)) {
381 DWORD error = GetLastError();
382 free(buffer); 379 free(buffer);
383 free(utf8_target); 380 free(utf8_target);
384 SetLastError(error);
385 return NULL; 381 return NULL;
386 } 382 }
387 utf8_target[utf8_length] = '\0'; 383 utf8_target[utf8_length] = '\0';
388 free(buffer); 384 free(buffer);
389 return utf8_target; 385 return utf8_target;
390 } 386 }
391 387
392 388
393 time_t File::LastModified(const char* name) { 389 time_t File::LastModified(const char* name) {
394 struct _stat st; 390 struct _stat st;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 const wchar_t* wide_name = StringUtils::Utf8ToWide(file_names[i]); 520 const wchar_t* wide_name = StringUtils::Utf8ToWide(file_names[i]);
525 HANDLE file_handle = CreateFileW( 521 HANDLE file_handle = CreateFileW(
526 wide_name, 522 wide_name,
527 0, 523 0,
528 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 524 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
529 NULL, 525 NULL,
530 OPEN_EXISTING, 526 OPEN_EXISTING,
531 FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, 527 FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT,
532 NULL); 528 NULL);
533 if (file_handle == INVALID_HANDLE_VALUE) { 529 if (file_handle == INVALID_HANDLE_VALUE) {
534 DWORD error = GetLastError();
535 free(const_cast<wchar_t*>(wide_name)); 530 free(const_cast<wchar_t*>(wide_name));
536 SetLastError(error);
537 return File::kError; 531 return File::kError;
538 } 532 }
539 free(const_cast<wchar_t*>(wide_name)); 533 free(const_cast<wchar_t*>(wide_name));
540 int result = GetFileInformationByHandle(file_handle, &file_info[i]); 534 int result = GetFileInformationByHandle(file_handle, &file_info[i]);
541 if (result == 0) { 535 if (result == 0) {
542 DWORD error = GetLastError(); 536 DWORD error = GetLastError();
543 CloseHandle(file_handle); 537 CloseHandle(file_handle);
544 SetLastError(error); 538 SetLastError(error);
545 return File::kError; 539 return File::kError;
546 } 540 }
547 if (CloseHandle(file_handle) == 0) { 541 if (CloseHandle(file_handle) == 0) {
548 return File::kError; 542 return File::kError;
549 } 543 }
550 } 544 }
551 if (file_info[0].dwVolumeSerialNumber == file_info[1].dwVolumeSerialNumber && 545 if (file_info[0].dwVolumeSerialNumber == file_info[1].dwVolumeSerialNumber &&
552 file_info[0].nFileIndexHigh == file_info[1].nFileIndexHigh && 546 file_info[0].nFileIndexHigh == file_info[1].nFileIndexHigh &&
553 file_info[0].nFileIndexLow == file_info[1].nFileIndexLow) { 547 file_info[0].nFileIndexLow == file_info[1].nFileIndexLow) {
554 return kIdentical; 548 return kIdentical;
555 } else { 549 } else {
556 return kDifferent; 550 return kDifferent;
557 } 551 }
558 } 552 }
559 553
560 #endif // defined(TARGET_OS_WINDOWS) 554 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698