Chromium Code Reviews| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 return read(handle_->fd(), buffer, num_bytes); | 65 return read(handle_->fd(), buffer, num_bytes); |
| 66 } | 66 } |
| 67 | 67 |
| 68 | 68 |
| 69 int64_t File::Write(const void* buffer, int64_t num_bytes) { | 69 int64_t File::Write(const void* buffer, int64_t num_bytes) { |
| 70 ASSERT(handle_->fd() >= 0); | 70 ASSERT(handle_->fd() >= 0); |
| 71 return write(handle_->fd(), buffer, num_bytes); | 71 return write(handle_->fd(), buffer, num_bytes); |
| 72 } | 72 } |
| 73 | 73 |
| 74 | 74 |
| 75 off_t File::Position() { | 75 off64_t File::Position() { |
| 76 ASSERT(handle_->fd() >= 0); | 76 ASSERT(handle_->fd() >= 0); |
| 77 return lseek(handle_->fd(), 0, SEEK_CUR); | 77 return lseek(handle_->fd(), 0, SEEK_CUR); |
|
Søren Gjesse
2013/11/19 10:15:49
Looking in the Windows docs (http://msdn.microsoft
Anders Johnsen
2013/11/19 10:43:39
Done.
| |
| 78 } | 78 } |
| 79 | 79 |
| 80 | 80 |
| 81 bool File::SetPosition(int64_t position) { | 81 bool File::SetPosition(off64_t position) { |
| 82 ASSERT(handle_->fd() >= 0); | 82 ASSERT(handle_->fd() >= 0); |
| 83 return (lseek(handle_->fd(), position, SEEK_SET) != -1); | 83 return (lseek(handle_->fd(), position, SEEK_SET) != -1); |
|
Søren Gjesse
2013/11/19 10:15:49
ditto
Anders Johnsen
2013/11/19 10:43:39
Done.
| |
| 84 } | 84 } |
| 85 | 85 |
| 86 | 86 |
| 87 bool File::Truncate(int64_t length) { | 87 bool File::Truncate(off64_t length) { |
| 88 ASSERT(handle_->fd() >= 0); | 88 ASSERT(handle_->fd() >= 0); |
| 89 return (chsize(handle_->fd(), length) != -1); | 89 return (chsize(handle_->fd(), length) != -1); |
|
Søren Gjesse
2013/11/19 10:15:49
Use _chsize_s here (http://msdn.microsoft.com/en-u
Anders Johnsen
2013/11/19 10:43:39
Done.
| |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 bool File::Flush() { | 93 bool File::Flush() { |
| 94 ASSERT(handle_->fd()); | 94 ASSERT(handle_->fd()); |
| 95 return _commit(handle_->fd()) != -1; | 95 return _commit(handle_->fd()) != -1; |
| 96 } | 96 } |
| 97 | 97 |
| 98 | 98 |
| 99 off_t File::Length() { | 99 off64_t File::Length() { |
| 100 ASSERT(handle_->fd() >= 0); | 100 ASSERT(handle_->fd() >= 0); |
| 101 struct stat st; | 101 struct stat st; |
| 102 if (fstat(handle_->fd(), &st) == 0) { | 102 if (fstat(handle_->fd(), &st) == 0) { |
|
Søren Gjesse
2013/11/19 10:15:49
And _fstat64 (http://msdn.microsoft.com/en-us/libr
Anders Johnsen
2013/11/19 10:43:39
Done.
| |
| 103 return st.st_size; | 103 return st.st_size; |
| 104 } | 104 } |
| 105 return -1; | 105 return -1; |
| 106 } | 106 } |
| 107 | 107 |
| 108 | 108 |
| 109 File* File::Open(const char* name, FileOpenMode mode) { | 109 File* File::Open(const char* name, FileOpenMode mode) { |
| 110 int flags = O_RDONLY | O_BINARY | O_NOINHERIT; | 110 int flags = O_RDONLY | O_BINARY | O_NOINHERIT; |
| 111 if ((mode & kWrite) != 0) { | 111 if ((mode & kWrite) != 0) { |
| 112 flags = (O_RDWR | O_CREAT | O_BINARY | O_NOINHERIT); | 112 flags = (O_RDWR | O_CREAT | O_BINARY | O_NOINHERIT); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 free(const_cast<wchar_t*>(system_old_path)); | 315 free(const_cast<wchar_t*>(system_old_path)); |
| 316 free(const_cast<wchar_t*>(system_new_path)); | 316 free(const_cast<wchar_t*>(system_new_path)); |
| 317 return (move_status != 0); | 317 return (move_status != 0); |
| 318 } else { | 318 } else { |
| 319 SetLastError(ERROR_FILE_NOT_FOUND); | 319 SetLastError(ERROR_FILE_NOT_FOUND); |
| 320 } | 320 } |
| 321 return false; | 321 return false; |
| 322 } | 322 } |
| 323 | 323 |
| 324 | 324 |
| 325 off_t File::LengthFromPath(const char* name) { | 325 off64_t File::LengthFromPath(const char* name) { |
| 326 struct _stat st; | 326 struct _stat st; |
| 327 const wchar_t* system_name = StringUtils::Utf8ToWide(name); | 327 const wchar_t* system_name = StringUtils::Utf8ToWide(name); |
| 328 int stat_status = _wstat(system_name, &st); | 328 int stat_status = _wstat(system_name, &st); |
|
Søren Gjesse
2013/11/19 10:15:49
_wstat64
Anders Johnsen
2013/11/19 10:43:39
Done.
| |
| 329 free(const_cast<wchar_t*>(system_name)); | 329 free(const_cast<wchar_t*>(system_name)); |
| 330 if (stat_status == 0) { | 330 if (stat_status == 0) { |
| 331 return st.st_size; | 331 return st.st_size; |
| 332 } | 332 } |
| 333 return -1; | 333 return -1; |
| 334 } | 334 } |
| 335 | 335 |
| 336 | 336 |
| 337 char* File::LinkTarget(const char* pathname) { | 337 char* File::LinkTarget(const char* pathname) { |
| 338 const wchar_t* name = StringUtils::Utf8ToWide(pathname); | 338 const wchar_t* name = StringUtils::Utf8ToWide(pathname); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 606 return kIdentical; | 606 return kIdentical; |
| 607 } else { | 607 } else { |
| 608 return kDifferent; | 608 return kDifferent; |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 | 611 |
| 612 } // namespace bin | 612 } // namespace bin |
| 613 } // namespace dart | 613 } // namespace dart |
| 614 | 614 |
| 615 #endif // defined(TARGET_OS_WINDOWS) | 615 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |