Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 #include "platform/globals.h" | |
| 6 #if defined(TARGET_OS_FUCHSIA) | |
| 7 | |
| 8 #include "bin/directory.h" | |
| 9 | |
| 10 #include <errno.h> // NOLINT | |
| 11 #include <stdlib.h> // NOLINT | |
| 12 #include <string.h> // NOLINT | |
| 13 #include <unistd.h> // NOLINT | |
| 14 | |
| 15 namespace dart { | |
| 16 namespace bin { | |
| 17 | |
| 18 PathBuffer::PathBuffer() : length_(0) { | |
| 19 data_ = calloc(PATH_MAX + 1, sizeof(char)); // NOLINT | |
| 20 } | |
| 21 | |
| 22 | |
| 23 PathBuffer::~PathBuffer() { | |
| 24 free(data_); | |
| 25 } | |
| 26 | |
| 27 | |
| 28 bool PathBuffer::AddW(const wchar_t* name) { | |
| 29 UNREACHABLE(); | |
| 30 return false; | |
| 31 } | |
| 32 | |
| 33 | |
| 34 char* PathBuffer::AsString() const { | |
| 35 return reinterpret_cast<char*>(data_); | |
| 36 } | |
| 37 | |
| 38 | |
| 39 wchar_t* PathBuffer::AsStringW() const { | |
| 40 UNREACHABLE(); | |
| 41 return NULL; | |
| 42 } | |
| 43 | |
| 44 | |
| 45 const char* PathBuffer::AsScopedString() const { | |
| 46 return DartUtils::ScopedCopyCString(AsString()); | |
| 47 } | |
| 48 | |
| 49 | |
| 50 bool PathBuffer::Add(const char* name) { | |
| 51 char* data = AsString(); | |
| 52 int written = snprintf(data + length_, | |
| 53 PATH_MAX - length_, | |
| 54 "%s", | |
| 55 name); | |
| 56 data[PATH_MAX] = '\0'; | |
| 57 if ((written <= PATH_MAX - length_) && | |
|
siva
2016/07/22 19:18:22
(PATH_MAX - length_)
zra
2016/07/22 20:07:08
Done.
| |
| 58 (written >= 0) && | |
|
siva
2016/07/22 19:18:22
When would written be 0?
zra
2016/07/22 20:07:08
It could be zero when name is "", but that would p
| |
| 59 (static_cast<size_t>(written) == strnlen(name, PATH_MAX + 1))) { | |
| 60 length_ += written; | |
| 61 return true; | |
| 62 } else { | |
| 63 errno = ENAMETOOLONG; | |
| 64 return false; | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 | |
| 69 void PathBuffer::Reset(intptr_t new_length) { | |
| 70 length_ = new_length; | |
| 71 AsString()[length_] = '\0'; | |
| 72 } | |
| 73 | |
| 74 | |
| 75 ListType DirectoryListingEntry::Next(DirectoryListing* listing) { | |
| 76 UNIMPLEMENTED(); | |
| 77 return kListError; | |
| 78 } | |
| 79 | |
| 80 | |
| 81 DirectoryListingEntry::~DirectoryListingEntry() { | |
| 82 UNIMPLEMENTED(); | |
| 83 } | |
| 84 | |
| 85 | |
| 86 void DirectoryListingEntry::ResetLink() { | |
| 87 UNIMPLEMENTED(); | |
| 88 } | |
| 89 | |
| 90 | |
| 91 Directory::ExistsResult Directory::Exists(const char* dir_name) { | |
| 92 UNIMPLEMENTED(); | |
| 93 return UNKNOWN; | |
| 94 } | |
| 95 | |
| 96 | |
| 97 char* Directory::CurrentNoScope() { | |
| 98 return getcwd(NULL, 0); | |
| 99 } | |
| 100 | |
| 101 | |
| 102 const char* Directory::Current() { | |
| 103 char buffer[PATH_MAX]; | |
| 104 if (getcwd(buffer, PATH_MAX) == NULL) { | |
| 105 return NULL; | |
| 106 } | |
| 107 return DartUtils::ScopedCopyCString(buffer); | |
| 108 } | |
| 109 | |
| 110 | |
| 111 bool Directory::SetCurrent(const char* path) { | |
| 112 UNIMPLEMENTED(); | |
| 113 return false; | |
| 114 } | |
| 115 | |
| 116 | |
| 117 bool Directory::Create(const char* dir_name) { | |
| 118 UNIMPLEMENTED(); | |
| 119 return false; | |
| 120 } | |
| 121 | |
| 122 | |
| 123 const char* Directory::SystemTemp() { | |
| 124 UNIMPLEMENTED(); | |
| 125 return NULL; | |
| 126 } | |
| 127 | |
| 128 | |
| 129 const char* Directory::CreateTemp(const char* prefix) { | |
| 130 UNIMPLEMENTED(); | |
| 131 return NULL; | |
| 132 } | |
| 133 | |
| 134 | |
| 135 bool Directory::Delete(const char* dir_name, bool recursive) { | |
| 136 UNIMPLEMENTED(); | |
| 137 return false; | |
| 138 } | |
| 139 | |
| 140 | |
| 141 bool Directory::Rename(const char* path, const char* new_path) { | |
| 142 UNIMPLEMENTED(); | |
| 143 return false; | |
| 144 } | |
| 145 | |
| 146 } // namespace bin | |
| 147 } // namespace dart | |
| 148 | |
| 149 #endif // defined(TARGET_OS_LINUX) | |
| OLD | NEW |