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

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

Issue 12437017: dart:io | Make broken links report NOT_FOUND from FileSystemEntity.typeSync on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove TODO comment. Created 7 years, 9 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 | tests/standalone/io/windows_file_system_links_test.dart » ('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 "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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 File::Type File::GetType(const char* pathname, bool follow_links) { 376 File::Type File::GetType(const char* pathname, bool follow_links) {
377 const wchar_t* name = StringUtils::Utf8ToWide(pathname); 377 const wchar_t* name = StringUtils::Utf8ToWide(pathname);
378 WIN32_FIND_DATAW file_data; 378 WIN32_FIND_DATAW file_data;
379 HANDLE find_handle = FindFirstFileW(name, &file_data); 379 HANDLE find_handle = FindFirstFileW(name, &file_data);
380 if (find_handle == INVALID_HANDLE_VALUE) { 380 if (find_handle == INVALID_HANDLE_VALUE) {
381 // TODO(whesse): Distinguish other errors from does not exist. 381 // TODO(whesse): Distinguish other errors from does not exist.
382 return File::kDoesNotExist; 382 return File::kDoesNotExist;
383 } 383 }
384 FindClose(find_handle); 384 FindClose(find_handle);
385 DWORD attributes = file_data.dwFileAttributes; 385 DWORD attributes = file_data.dwFileAttributes;
386 if (!follow_links && (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { 386 if ((attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
387 DWORD reparse_tag = file_data.dwReserved0; 387 if (follow_links) {
388 if (reparse_tag == IO_REPARSE_TAG_SYMLINK || 388 HANDLE dir_handle = CreateFileW(
389 reparse_tag == IO_REPARSE_TAG_MOUNT_POINT) { 389 name,
390 return File::kIsLink; 390 0,
391 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
392 NULL,
393 OPEN_EXISTING,
394 FILE_FLAG_BACKUP_SEMANTICS,
395 NULL);
396 if (dir_handle == INVALID_HANDLE_VALUE) {
397 // TODO(whesse): Distinguish other errors from does not exist.
398 return File::kDoesNotExist;
399 } else {
400 CloseHandle(dir_handle);
401 return File::kIsDirectory;
402 }
391 } else { 403 } else {
392 return File::kDoesNotExist; 404 DWORD reparse_tag = file_data.dwReserved0;
405 if (reparse_tag == IO_REPARSE_TAG_SYMLINK ||
406 reparse_tag == IO_REPARSE_TAG_MOUNT_POINT) {
407 return File::kIsLink;
408 } else {
409 return File::kDoesNotExist;
410 }
393 } 411 }
394 } else if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { 412 } else if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
395 return File::kIsDirectory; 413 return File::kIsDirectory;
396 } else { 414 } else {
397 return File::kIsFile; 415 return File::kIsFile;
398 } 416 }
399 } 417 }
400 418
401 #endif // defined(TARGET_OS_WINDOWS) 419 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/windows_file_system_links_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698