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

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

Issue 2715463003: Add option to gen_snapshot for creating a Makefile describing a snapshot's dependencies. (Closed)
Patch Set: . Created 3 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
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_win.cc » ('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_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <copyfile.h> // NOLINT 10 #include <copyfile.h> // NOLINT
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); 115 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes));
116 } 116 }
117 117
118 118
119 int64_t File::Write(const void* buffer, int64_t num_bytes) { 119 int64_t File::Write(const void* buffer, int64_t num_bytes) {
120 ASSERT(handle_->fd() >= 0); 120 ASSERT(handle_->fd() >= 0);
121 return TEMP_FAILURE_RETRY(write(handle_->fd(), buffer, num_bytes)); 121 return TEMP_FAILURE_RETRY(write(handle_->fd(), buffer, num_bytes));
122 } 122 }
123 123
124 124
125 bool File::VPrint(const char* format, va_list args) {
126 // Measure.
127 va_list measure_args;
128 va_copy(measure_args, args);
129 intptr_t len = vsnprintf(NULL, 0, format, measure_args);
130 va_end(measure_args);
131
132 char* buffer = reinterpret_cast<char*>(malloc(len + 1));
133
134 // Print.
135 va_list print_args;
136 va_copy(print_args, args);
137 vsnprintf(buffer, len + 1, format, print_args);
138 va_end(print_args);
139
140 bool result = WriteFully(buffer, len);
141 free(buffer);
142 return result;
143 }
144
125 int64_t File::Position() { 145 int64_t File::Position() {
126 ASSERT(handle_->fd() >= 0); 146 ASSERT(handle_->fd() >= 0);
127 return lseek(handle_->fd(), 0, SEEK_CUR); 147 return lseek(handle_->fd(), 0, SEEK_CUR);
128 } 148 }
129 149
130 150
131 bool File::SetPosition(int64_t position) { 151 bool File::SetPosition(int64_t position) {
132 ASSERT(handle_->fd() >= 0); 152 ASSERT(handle_->fd() >= 0);
133 return lseek(handle_->fd(), position, SEEK_SET) >= 0; 153 return lseek(handle_->fd(), position, SEEK_SET) >= 0;
134 } 154 }
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 return ((file_1_info.st_ino == file_2_info.st_ino) && 576 return ((file_1_info.st_ino == file_2_info.st_ino) &&
557 (file_1_info.st_dev == file_2_info.st_dev)) 577 (file_1_info.st_dev == file_2_info.st_dev))
558 ? File::kIdentical 578 ? File::kIdentical
559 : File::kDifferent; 579 : File::kDifferent;
560 } 580 }
561 581
562 } // namespace bin 582 } // namespace bin
563 } // namespace dart 583 } // namespace dart
564 584
565 #endif // defined(TARGET_OS_MACOS) 585 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698