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