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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 bool File::Create(const char* name) { | 153 bool File::Create(const char* name) { |
154 int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CREAT | O_CLOEXEC, 0666)); | 154 int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CREAT | O_CLOEXEC, 0666)); |
155 if (fd < 0) { | 155 if (fd < 0) { |
156 return false; | 156 return false; |
157 } | 157 } |
158 return (close(fd) == 0); | 158 return (close(fd) == 0); |
159 } | 159 } |
160 | 160 |
161 | 161 |
| 162 bool File::CreateLink(const char* name, const char* target) { |
| 163 int status = TEMP_FAILURE_RETRY(symlink(target, name)); |
| 164 return (status == 0); |
| 165 } |
| 166 |
| 167 |
162 bool File::Delete(const char* name) { | 168 bool File::Delete(const char* name) { |
163 int status = TEMP_FAILURE_RETRY(remove(name)); | 169 int status = TEMP_FAILURE_RETRY(remove(name)); |
164 if (status == -1) { | 170 if (status == -1) { |
165 return false; | 171 return false; |
166 } | 172 } |
167 return true; | 173 return true; |
168 } | 174 } |
169 | 175 |
170 | 176 |
171 off_t File::LengthFromPath(const char* name) { | 177 off_t File::LengthFromPath(const char* name) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 stat_success = TEMP_FAILURE_RETRY(lstat(pathname, &entry_info)); | 262 stat_success = TEMP_FAILURE_RETRY(lstat(pathname, &entry_info)); |
257 } | 263 } |
258 if (stat_success == -1) return File::kDoesNotExist; | 264 if (stat_success == -1) return File::kDoesNotExist; |
259 if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory; | 265 if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory; |
260 if (S_ISREG(entry_info.st_mode)) return File::kIsFile; | 266 if (S_ISREG(entry_info.st_mode)) return File::kIsFile; |
261 if (S_ISLNK(entry_info.st_mode)) return File::kIsLink; | 267 if (S_ISLNK(entry_info.st_mode)) return File::kIsLink; |
262 return File::kDoesNotExist; | 268 return File::kDoesNotExist; |
263 } | 269 } |
264 | 270 |
265 #endif // defined(TARGET_OS_ANDROID) | 271 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |