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_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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 return TEMP_FAILURE_RETRY(rename(old_path, new_path)) == 0; | 198 return TEMP_FAILURE_RETRY(rename(old_path, new_path)) == 0; |
199 } else if (type == kIsDirectory) { | 199 } else if (type == kIsDirectory) { |
200 errno = EISDIR; | 200 errno = EISDIR; |
201 } else { | 201 } else { |
202 errno = ENOENT; | 202 errno = ENOENT; |
203 } | 203 } |
204 return false; | 204 return false; |
205 } | 205 } |
206 | 206 |
207 | 207 |
| 208 bool File::RenameLink(const char* old_path, const char* new_path) { |
| 209 File::Type type = File::GetType(old_path, false); |
| 210 if (type == kIsLink) { |
| 211 return TEMP_FAILURE_RETRY(rename(old_path, new_path)) == 0; |
| 212 } else if (type == kIsDirectory) { |
| 213 errno = EISDIR; |
| 214 } else { |
| 215 errno = EINVAL; |
| 216 } |
| 217 return false; |
| 218 } |
| 219 |
| 220 |
208 off_t File::LengthFromPath(const char* name) { | 221 off_t File::LengthFromPath(const char* name) { |
209 struct stat st; | 222 struct stat st; |
210 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { | 223 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
211 return st.st_size; | 224 return st.st_size; |
212 } | 225 } |
213 return -1; | 226 return -1; |
214 } | 227 } |
215 | 228 |
216 | 229 |
217 void File::Stat(const char* name, int64_t* data) { | 230 void File::Stat(const char* name, int64_t* data) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 return (file_1_info.st_ino == file_2_info.st_ino && | 353 return (file_1_info.st_ino == file_2_info.st_ino && |
341 file_1_info.st_dev == file_2_info.st_dev) ? | 354 file_1_info.st_dev == file_2_info.st_dev) ? |
342 File::kIdentical : | 355 File::kIdentical : |
343 File::kDifferent; | 356 File::kDifferent; |
344 } | 357 } |
345 | 358 |
346 } // namespace bin | 359 } // namespace bin |
347 } // namespace dart | 360 } // namespace dart |
348 | 361 |
349 #endif // defined(TARGET_OS_ANDROID) | 362 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |