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

Side by Side Diff: runtime/bin/file_android.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.cc ('k') | runtime/bin/file_linux.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_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 bool File::DeleteLink(const char* name) { 185 bool File::DeleteLink(const char* name) {
186 File::Type type = File::GetType(name, false); 186 File::Type type = File::GetType(name, false);
187 if (type == kIsLink) { 187 if (type == kIsLink) {
188 return TEMP_FAILURE_RETRY(unlink(name)) == 0; 188 return TEMP_FAILURE_RETRY(unlink(name)) == 0;
189 } 189 }
190 errno = EINVAL; 190 errno = EINVAL;
191 return false; 191 return false;
192 } 192 }
193 193
194 194
195 bool File::Rename(const char* old_path, const char* new_path) {
196 File::Type type = File::GetType(old_path, true);
197 if (type == kIsFile) {
198 return TEMP_FAILURE_RETRY(rename(old_path, new_path)) == 0;
199 } else if (type == kIsDirectory) {
200 errno = EISDIR;
201 } else {
202 errno = ENOENT;
203 }
204 return false;
205 }
206
207
195 off_t File::LengthFromPath(const char* name) { 208 off_t File::LengthFromPath(const char* name) {
196 struct stat st; 209 struct stat st;
197 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { 210 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
198 return st.st_size; 211 return st.st_size;
199 } 212 }
200 return -1; 213 return -1;
201 } 214 }
202 215
203 216
204 void File::Stat(const char* name, int64_t* data) { 217 void File::Stat(const char* name, int64_t* data) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 return (file_1_info.st_ino == file_2_info.st_ino && 340 return (file_1_info.st_ino == file_2_info.st_ino &&
328 file_1_info.st_dev == file_2_info.st_dev) ? 341 file_1_info.st_dev == file_2_info.st_dev) ?
329 File::kIdentical : 342 File::kIdentical :
330 File::kDifferent; 343 File::kDifferent;
331 } 344 }
332 345
333 } // namespace bin 346 } // namespace bin
334 } // namespace dart 347 } // namespace dart
335 348
336 #endif // defined(TARGET_OS_ANDROID) 349 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/file.cc ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698