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

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

Issue 17033003: dart:io | Add File.rename (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 bool File::DeleteLink(const char* name) { 188 bool File::DeleteLink(const char* name) {
189 File::Type type = File::GetType(name, false); 189 File::Type type = File::GetType(name, false);
190 if (type == kIsLink) { 190 if (type == kIsLink) {
191 return TEMP_FAILURE_RETRY(unlink(name)) == 0; 191 return TEMP_FAILURE_RETRY(unlink(name)) == 0;
192 } 192 }
193 errno = EINVAL; 193 errno = EINVAL;
194 return false; 194 return false;
195 } 195 }
196 196
197 197
198 bool File::Rename(const char* old_path, const char* new_path) {
199 File::Type type = File::GetType(old_path, true);
200 if (type == kIsFile) {
201 return TEMP_FAILURE_RETRY(rename(old_path, new_path)) == 0;
202 } else if (type == kIsDirectory) {
203 errno = EISDIR;
204 } else {
205 errno = ENOENT;
206 }
207 return false;
208 }
209
210
198 off_t File::LengthFromPath(const char* name) { 211 off_t File::LengthFromPath(const char* name) {
199 struct stat st; 212 struct stat st;
200 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { 213 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
201 return st.st_size; 214 return st.st_size;
202 } 215 }
203 return -1; 216 return -1;
204 } 217 }
205 218
206 219
207 void File::Stat(const char* name, int64_t* data) { 220 void File::Stat(const char* name, int64_t* data) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 return (file_1_info.st_ino == file_2_info.st_ino && 342 return (file_1_info.st_ino == file_2_info.st_ino &&
330 file_1_info.st_dev == file_2_info.st_dev) ? 343 file_1_info.st_dev == file_2_info.st_dev) ?
331 File::kIdentical : 344 File::kIdentical :
332 File::kDifferent; 345 File::kDifferent;
333 } 346 }
334 347
335 } // namespace bin 348 } // namespace bin
336 } // namespace dart 349 } // namespace dart
337 350
338 #endif // defined(TARGET_OS_MACOS) 351 #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