| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return handle_->fd(); | 68 return handle_->fd(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 | 71 |
| 72 bool File::IsClosed() { | 72 bool File::IsClosed() { |
| 73 return handle_->fd() == kClosedFd; | 73 return handle_->fd() == kClosedFd; |
| 74 } | 74 } |
| 75 | 75 |
| 76 | 76 |
| 77 void* File::Map(MapType type, int64_t position, int64_t length) { | 77 void* File::Map(MapType type, int64_t position, int64_t length) { |
| 78 UNIMPLEMENTED(); | 78 ASSERT(handle_->fd() >= 0); |
| 79 return NULL; | 79 int flags; |
| 80 switch (type) { |
| 81 case kReadOnly: |
| 82 flags = PAGE_READONLY; |
| 83 break; |
| 84 case KReadExecute: |
| 85 flags = PAGE_EXECUTE_READ: |
| 86 break; |
| 87 default: |
| 88 return NULL; |
| 89 } |
| 90 HANDLE mapping = CreateFileMapping(handle_->fd(), NULL, flags, 0, 0, NULL); |
| 91 return MapViewOfFile(mapping, |
| 92 FILE_MAP_READ, |
| 93 Utils::High32Bits(position), |
| 94 Utils::Low32Bits(position), |
| 95 length); |
| 80 } | 96 } |
| 81 | 97 |
| 82 | 98 |
| 83 int64_t File::Read(void* buffer, int64_t num_bytes) { | 99 int64_t File::Read(void* buffer, int64_t num_bytes) { |
| 84 ASSERT(handle_->fd() >= 0); | 100 ASSERT(handle_->fd() >= 0); |
| 85 return read(handle_->fd(), buffer, num_bytes); | 101 return read(handle_->fd(), buffer, num_bytes); |
| 86 } | 102 } |
| 87 | 103 |
| 88 | 104 |
| 89 int64_t File::Write(const void* buffer, int64_t num_bytes) { | 105 int64_t File::Write(const void* buffer, int64_t num_bytes) { |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 return kIdentical; | 716 return kIdentical; |
| 701 } else { | 717 } else { |
| 702 return kDifferent; | 718 return kDifferent; |
| 703 } | 719 } |
| 704 } | 720 } |
| 705 | 721 |
| 706 } // namespace bin | 722 } // namespace bin |
| 707 } // namespace dart | 723 } // namespace dart |
| 708 | 724 |
| 709 #endif // defined(TARGET_OS_WINDOWS) | 725 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |