| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 bool File::DeleteLink(const char* name) { | 186 bool File::DeleteLink(const char* name) { |
| 187 File::Type type = File::GetType(name, false); | 187 File::Type type = File::GetType(name, false); |
| 188 if (type == kIsLink) { | 188 if (type == kIsLink) { |
| 189 return TEMP_FAILURE_RETRY(unlink(name)) == 0; | 189 return TEMP_FAILURE_RETRY(unlink(name)) == 0; |
| 190 } | 190 } |
| 191 errno = EINVAL; | 191 errno = EINVAL; |
| 192 return false; | 192 return false; |
| 193 } | 193 } |
| 194 | 194 |
| 195 | 195 |
| 196 bool File::Rename(const char* old_path, const char* new_path) { |
| 197 File::Type type = File::GetType(old_path, true); |
| 198 if (type == kIsFile) { |
| 199 return TEMP_FAILURE_RETRY(rename(old_path, new_path)) == 0; |
| 200 } else if (type == kIsDirectory) { |
| 201 errno = EISDIR; |
| 202 } else { |
| 203 errno = ENOENT; |
| 204 } |
| 205 return false; |
| 206 } |
| 207 |
| 208 |
| 196 off_t File::LengthFromPath(const char* name) { | 209 off_t File::LengthFromPath(const char* name) { |
| 197 struct stat st; | 210 struct stat st; |
| 198 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { | 211 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
| 199 return st.st_size; | 212 return st.st_size; |
| 200 } | 213 } |
| 201 return -1; | 214 return -1; |
| 202 } | 215 } |
| 203 | 216 |
| 204 | 217 |
| 205 void File::Stat(const char* name, int64_t* data) { | 218 void File::Stat(const char* name, int64_t* data) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 return (file_1_info.st_ino == file_2_info.st_ino && | 334 return (file_1_info.st_ino == file_2_info.st_ino && |
| 322 file_1_info.st_dev == file_2_info.st_dev) ? | 335 file_1_info.st_dev == file_2_info.st_dev) ? |
| 323 File::kIdentical : | 336 File::kIdentical : |
| 324 File::kDifferent; | 337 File::kDifferent; |
| 325 } | 338 } |
| 326 | 339 |
| 327 } // namespace bin | 340 } // namespace bin |
| 328 } // namespace dart | 341 } // namespace dart |
| 329 | 342 |
| 330 #endif // defined(TARGET_OS_LINUX) | 343 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |