| Index: runtime/bin/directory_macos.cc
|
| diff --git a/runtime/bin/directory_macos.cc b/runtime/bin/directory_macos.cc
|
| index 48a7088dc9765f154ab3c6416221a232a9e34eea..8fe39782773c602322282da81f8785737bc701be 100644
|
| --- a/runtime/bin/directory_macos.cc
|
| +++ b/runtime/bin/directory_macos.cc
|
| @@ -26,34 +26,28 @@ PathBuffer::PathBuffer() : length_(0) {
|
| data_ = calloc(PATH_MAX + 1, sizeof(char)); // NOLINT
|
| }
|
|
|
| -
|
| PathBuffer::~PathBuffer() {
|
| free(data_);
|
| }
|
|
|
| -
|
| bool PathBuffer::AddW(const wchar_t* name) {
|
| UNREACHABLE();
|
| return false;
|
| }
|
|
|
| -
|
| char* PathBuffer::AsString() const {
|
| return reinterpret_cast<char*>(data_);
|
| }
|
|
|
| -
|
| wchar_t* PathBuffer::AsStringW() const {
|
| UNREACHABLE();
|
| return NULL;
|
| }
|
|
|
| -
|
| const char* PathBuffer::AsScopedString() const {
|
| return DartUtils::ScopedCopyCString(AsString());
|
| }
|
|
|
| -
|
| bool PathBuffer::Add(const char* name) {
|
| char* data = AsString();
|
| int written = snprintf(data + length_, PATH_MAX - length_, "%s", name);
|
| @@ -68,13 +62,11 @@ bool PathBuffer::Add(const char* name) {
|
| }
|
| }
|
|
|
| -
|
| void PathBuffer::Reset(intptr_t new_length) {
|
| length_ = new_length;
|
| AsString()[length_] = '\0';
|
| }
|
|
|
| -
|
| // A linked list of symbolic links, with their unique file system identifiers.
|
| // These are scanned to detect loops while doing a recursive directory listing.
|
| struct LinkList {
|
| @@ -83,7 +75,6 @@ struct LinkList {
|
| LinkList* next;
|
| };
|
|
|
| -
|
| ListType DirectoryListingEntry::Next(DirectoryListing* listing) {
|
| if (done_) {
|
| return kListDone;
|
| @@ -217,7 +208,6 @@ ListType DirectoryListingEntry::Next(DirectoryListing* listing) {
|
| return kListDone;
|
| }
|
|
|
| -
|
| DirectoryListingEntry::~DirectoryListingEntry() {
|
| ResetLink();
|
| if (lister_ != 0) {
|
| @@ -225,7 +215,6 @@ DirectoryListingEntry::~DirectoryListingEntry() {
|
| }
|
| }
|
|
|
| -
|
| void DirectoryListingEntry::ResetLink() {
|
| if ((link_ != NULL) && ((parent_ == NULL) || (parent_->link_ != link_))) {
|
| delete link_;
|
| @@ -236,15 +225,12 @@ void DirectoryListingEntry::ResetLink() {
|
| }
|
| }
|
|
|
| -
|
| static bool DeleteRecursively(PathBuffer* path);
|
|
|
| -
|
| static bool DeleteFile(char* file_name, PathBuffer* path) {
|
| return path->Add(file_name) && (unlink(path->AsString()) == 0);
|
| }
|
|
|
| -
|
| static bool DeleteDir(char* dir_name, PathBuffer* path) {
|
| if ((strcmp(dir_name, ".") == 0) || (strcmp(dir_name, "..") == 0)) {
|
| return true;
|
| @@ -252,7 +238,6 @@ static bool DeleteDir(char* dir_name, PathBuffer* path) {
|
| return path->Add(dir_name) && DeleteRecursively(path);
|
| }
|
|
|
| -
|
| static bool DeleteRecursively(PathBuffer* path) {
|
| // Do not recurse into links for deletion. Instead delete the link.
|
| // If it's a file, delete it.
|
| @@ -343,7 +328,6 @@ static bool DeleteRecursively(PathBuffer* path) {
|
| return false;
|
| }
|
|
|
| -
|
| Directory::ExistsResult Directory::Exists(const char* dir_name) {
|
| struct stat entry_info;
|
| int success = NO_RETRY_EXPECTED(stat(dir_name, &entry_info));
|
| @@ -370,12 +354,10 @@ Directory::ExistsResult Directory::Exists(const char* dir_name) {
|
| }
|
| }
|
|
|
| -
|
| char* Directory::CurrentNoScope() {
|
| return getcwd(NULL, 0);
|
| }
|
|
|
| -
|
| const char* Directory::Current() {
|
| char buffer[PATH_MAX];
|
| if (getcwd(buffer, PATH_MAX) == NULL) {
|
| @@ -384,13 +366,11 @@ const char* Directory::Current() {
|
| return DartUtils::ScopedCopyCString(buffer);
|
| }
|
|
|
| -
|
| bool Directory::SetCurrent(const char* path) {
|
| int result = NO_RETRY_EXPECTED(chdir(path));
|
| return (result == 0);
|
| }
|
|
|
| -
|
| bool Directory::Create(const char* dir_name) {
|
| // Create the directory with the permissions specified by the
|
| // process umask.
|
| @@ -402,7 +382,6 @@ bool Directory::Create(const char* dir_name) {
|
| return (result == 0);
|
| }
|
|
|
| -
|
| const char* Directory::SystemTemp() {
|
| PathBuffer path;
|
| const char* temp_dir = getenv("TMPDIR");
|
| @@ -424,7 +403,6 @@ const char* Directory::SystemTemp() {
|
| return path.AsScopedString();
|
| }
|
|
|
| -
|
| const char* Directory::CreateTemp(const char* prefix) {
|
| // Returns a new, unused directory name, adding characters to the end
|
| // of prefix. Creates the directory with the permissions specified
|
| @@ -448,7 +426,6 @@ const char* Directory::CreateTemp(const char* prefix) {
|
| return path.AsScopedString();
|
| }
|
|
|
| -
|
| bool Directory::Delete(const char* dir_name, bool recursive) {
|
| if (!recursive) {
|
| if ((File::GetType(dir_name, false) == File::kIsLink) &&
|
| @@ -465,7 +442,6 @@ bool Directory::Delete(const char* dir_name, bool recursive) {
|
| }
|
| }
|
|
|
| -
|
| bool Directory::Rename(const char* path, const char* new_path) {
|
| ExistsResult exists = Exists(path);
|
| if (exists != EXISTS) {
|
|
|