| OLD | NEW |
| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 265 |
| 266 | 266 |
| 267 File::StdioHandleType File::GetStdioHandleType(int fd) { | 267 File::StdioHandleType File::GetStdioHandleType(int fd) { |
| 268 // Treat all stdio handles as pipes. The Windows event handler and | 268 // Treat all stdio handles as pipes. The Windows event handler and |
| 269 // socket code will handle the different handle types. | 269 // socket code will handle the different handle types. |
| 270 return kPipe; | 270 return kPipe; |
| 271 } | 271 } |
| 272 | 272 |
| 273 | 273 |
| 274 File::Type File::GetType(const char* pathname, bool follow_links) { | 274 File::Type File::GetType(const char* pathname, bool follow_links) { |
| 275 return File::kDoesNotExist; | 275 const wchar_t* name = StringUtils::Utf8ToWide(pathname); |
| 276 WIN32_FIND_DATAW file_data; |
| 277 HANDLE find_handle = FindFirstFileW(name, &file_data); |
| 278 if (find_handle == INVALID_HANDLE_VALUE) { |
| 279 // TODO(whesse): Distinguish other errors from does not exist. |
| 280 return File::kDoesNotExist; |
| 281 } |
| 282 DWORD attributes = file_data.dwFileAttributes; |
| 283 if (!follow_links && (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { |
| 284 DWORD reparse_tag = file_data.dwReserved0; |
| 285 if (reparse_tag == IO_REPARSE_TAG_SYMLINK || |
| 286 reparse_tag == IO_REPARSE_TAG_MOUNT_POINT) { |
| 287 return File::kIsLink; |
| 288 } else { |
| 289 return File::kDoesNotExist; |
| 290 } |
| 291 } else if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { |
| 292 return File::kIsDirectory; |
| 293 } else { |
| 294 return File::kIsFile; |
| 295 } |
| 276 } | 296 } |
| 277 | 297 |
| 278 #endif // defined(TARGET_OS_WINDOWS) | 298 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |