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

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

Issue 17848003: dart:io | Add rename to Link (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix again Created 7 years, 6 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 | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_patch.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_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 return TEMP_FAILURE_RETRY(rename(old_path, new_path)) == 0; 201 return TEMP_FAILURE_RETRY(rename(old_path, new_path)) == 0;
202 } else if (type == kIsDirectory) { 202 } else if (type == kIsDirectory) {
203 errno = EISDIR; 203 errno = EISDIR;
204 } else { 204 } else {
205 errno = ENOENT; 205 errno = ENOENT;
206 } 206 }
207 return false; 207 return false;
208 } 208 }
209 209
210 210
211 bool File::RenameLink(const char* old_path, const char* new_path) {
212 File::Type type = File::GetType(old_path, false);
213 if (type == kIsLink) {
214 return TEMP_FAILURE_RETRY(rename(old_path, new_path)) == 0;
215 } else if (type == kIsDirectory) {
216 errno = EISDIR;
217 } else {
218 errno = EINVAL;
219 }
220 return false;
221 }
222
223
211 off_t File::LengthFromPath(const char* name) { 224 off_t File::LengthFromPath(const char* name) {
212 struct stat st; 225 struct stat st;
213 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { 226 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
214 return st.st_size; 227 return st.st_size;
215 } 228 }
216 return -1; 229 return -1;
217 } 230 }
218 231
219 232
220 void File::Stat(const char* name, int64_t* data) { 233 void File::Stat(const char* name, int64_t* data) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 return (file_1_info.st_ino == file_2_info.st_ino && 355 return (file_1_info.st_ino == file_2_info.st_ino &&
343 file_1_info.st_dev == file_2_info.st_dev) ? 356 file_1_info.st_dev == file_2_info.st_dev) ?
344 File::kIdentical : 357 File::kIdentical :
345 File::kDifferent; 358 File::kDifferent;
346 } 359 }
347 360
348 } // namespace bin 361 } // namespace bin
349 } // namespace dart 362 } // namespace dart
350 363
351 #endif // defined(TARGET_OS_MACOS) 364 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698