| 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/directory.h" | 8 #include "bin/directory.h" |
| 9 | 9 |
| 10 #include <dirent.h> // NOLINT | 10 #include <dirent.h> // NOLINT |
| 11 #include <errno.h> // NOLINT | 11 #include <errno.h> // NOLINT |
| 12 #include <string.h> // NOLINT | 12 #include <string.h> // NOLINT |
| 13 #include <sys/param.h> // NOLINT | 13 #include <sys/param.h> // NOLINT |
| 14 #include <sys/stat.h> // NOLINT | 14 #include <sys/stat.h> // NOLINT |
| 15 #include <unistd.h> // NOLINT | 15 #include <unistd.h> // NOLINT |
| 16 | 16 |
| 17 #include "bin/file.h" | 17 #include "bin/file.h" |
| 18 #include "bin/platform.h" | 18 #include "bin/platform.h" |
| 19 | 19 |
| 20 | 20 |
| 21 namespace dart { | 21 namespace dart { |
| 22 namespace bin { | 22 namespace bin { |
| 23 | 23 |
| 24 | 24 |
| 25 PathBuffer::PathBuffer() : length_(0) { | 25 PathBuffer::PathBuffer() : length_(0) { |
| 26 data_ = new char[PATH_MAX + 1]; | 26 data_ = calloc(PATH_MAX + 1, sizeof(char)); // NOLINT |
| 27 } | 27 } |
| 28 | 28 |
| 29 bool PathBuffer::AddW(const wchar_t* name) { | 29 bool PathBuffer::AddW(const wchar_t* name) { |
| 30 UNREACHABLE(); | 30 UNREACHABLE(); |
| 31 return false; | 31 return false; |
| 32 } | 32 } |
| 33 | 33 |
| 34 char* PathBuffer::AsString() const { | 34 char* PathBuffer::AsString() const { |
| 35 return reinterpret_cast<char*>(data_); | 35 return reinterpret_cast<char*>(data_); |
| 36 } | 36 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 188 } |
| 189 | 189 |
| 190 if (closedir(reinterpret_cast<DIR*>(lister_)) == -1) { | 190 if (closedir(reinterpret_cast<DIR*>(lister_)) == -1) { |
| 191 return kListError; | 191 return kListError; |
| 192 } | 192 } |
| 193 | 193 |
| 194 return kListDone; | 194 return kListDone; |
| 195 } | 195 } |
| 196 | 196 |
| 197 | 197 |
| 198 void DirectoryListingEntry::ResetLink() { |
| 199 if (link_ != NULL && (parent_ == NULL || parent_->link_ != link_)) { |
| 200 delete link_; |
| 201 link_ = NULL; |
| 202 } |
| 203 if (parent_ != NULL) { |
| 204 link_ = parent_->link_; |
| 205 } |
| 206 } |
| 207 |
| 208 |
| 198 static bool DeleteRecursively(PathBuffer* path); | 209 static bool DeleteRecursively(PathBuffer* path); |
| 199 | 210 |
| 200 | 211 |
| 201 static bool DeleteFile(char* file_name, | 212 static bool DeleteFile(char* file_name, |
| 202 PathBuffer* path) { | 213 PathBuffer* path) { |
| 203 return path->Add(file_name) && unlink(path->AsString()) == 0; | 214 return path->Add(file_name) && unlink(path->AsString()) == 0; |
| 204 } | 215 } |
| 205 | 216 |
| 206 | 217 |
| 207 static bool DeleteDir(char* dir_name, | 218 static bool DeleteDir(char* dir_name, |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 bool Directory::Rename(const char* path, const char* new_path) { | 423 bool Directory::Rename(const char* path, const char* new_path) { |
| 413 ExistsResult exists = Exists(path); | 424 ExistsResult exists = Exists(path); |
| 414 if (exists != EXISTS) return false; | 425 if (exists != EXISTS) return false; |
| 415 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); | 426 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); |
| 416 } | 427 } |
| 417 | 428 |
| 418 } // namespace bin | 429 } // namespace bin |
| 419 } // namespace dart | 430 } // namespace dart |
| 420 | 431 |
| 421 #endif // defined(TARGET_OS_LINUX) | 432 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |