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/directory.h" | 8 #include "bin/directory.h" |
9 | 9 |
10 #include <dirent.h> // NOLINT | 10 #include <dirent.h> // NOLINT |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 break; | 180 break; |
181 } | 181 } |
182 } | 182 } |
183 done_ = true; | 183 done_ = true; |
184 | 184 |
185 if (status != 0) { | 185 if (status != 0) { |
186 errno = status; | 186 errno = status; |
187 return kListError; | 187 return kListError; |
188 } | 188 } |
189 | 189 |
190 if (closedir(reinterpret_cast<DIR*>(lister_)) == -1) { | |
191 return kListError; | |
192 } | |
193 | |
194 return kListDone; | 190 return kListDone; |
195 } | 191 } |
196 | 192 |
197 | 193 |
| 194 DirectoryListingEntry::~DirectoryListingEntry() { |
| 195 ResetLink(); |
| 196 if (lister_ != 0) { |
| 197 closedir(reinterpret_cast<DIR*>(lister_)); |
| 198 } |
| 199 } |
| 200 |
| 201 |
198 void DirectoryListingEntry::ResetLink() { | 202 void DirectoryListingEntry::ResetLink() { |
199 if (link_ != NULL && (parent_ == NULL || parent_->link_ != link_)) { | 203 if (link_ != NULL && (parent_ == NULL || parent_->link_ != link_)) { |
200 delete link_; | 204 delete link_; |
201 link_ = NULL; | 205 link_ = NULL; |
202 } | 206 } |
203 if (parent_ != NULL) { | 207 if (parent_ != NULL) { |
204 link_ = parent_->link_; | 208 link_ = parent_->link_; |
205 } | 209 } |
206 } | 210 } |
207 | 211 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 bool Directory::Rename(const char* path, const char* new_path) { | 445 bool Directory::Rename(const char* path, const char* new_path) { |
442 ExistsResult exists = Exists(path); | 446 ExistsResult exists = Exists(path); |
443 if (exists != EXISTS) return false; | 447 if (exists != EXISTS) return false; |
444 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); | 448 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); |
445 } | 449 } |
446 | 450 |
447 } // namespace bin | 451 } // namespace bin |
448 } // namespace dart | 452 } // namespace dart |
449 | 453 |
450 #endif // defined(TARGET_OS_ANDROID) | 454 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |