| Index: runtime/bin/directory_win.cc
|
| diff --git a/runtime/bin/directory_win.cc b/runtime/bin/directory_win.cc
|
| index a8050b9fc0e054d5943a1261c7c658aa611e9ee4..094c4bfd2beed2b9061d73f5a15b94135c3bc8d9 100644
|
| --- a/runtime/bin/directory_win.cc
|
| +++ b/runtime/bin/directory_win.cc
|
| @@ -27,34 +27,28 @@ PathBuffer::PathBuffer() : length_(0) {
|
| data_ = calloc(MAX_LONG_PATH + 1, sizeof(wchar_t)); // NOLINT
|
| }
|
|
|
| -
|
| PathBuffer::~PathBuffer() {
|
| free(data_);
|
| }
|
|
|
| -
|
| char* PathBuffer::AsString() const {
|
| UNREACHABLE();
|
| return NULL;
|
| }
|
|
|
| -
|
| wchar_t* PathBuffer::AsStringW() const {
|
| return reinterpret_cast<wchar_t*>(data_);
|
| }
|
|
|
| -
|
| const char* PathBuffer::AsScopedString() const {
|
| return StringUtilsWin::WideToUtf8(AsStringW());
|
| }
|
|
|
| -
|
| bool PathBuffer::Add(const char* name) {
|
| Utf8ToWideScope wide_name(name);
|
| return AddW(wide_name.wide());
|
| }
|
|
|
| -
|
| bool PathBuffer::AddW(const wchar_t* name) {
|
| wchar_t* data = AsStringW();
|
| int written =
|
| @@ -70,13 +64,11 @@ bool PathBuffer::AddW(const wchar_t* name) {
|
| }
|
| }
|
|
|
| -
|
| void PathBuffer::Reset(intptr_t new_length) {
|
| length_ = new_length;
|
| AsStringW()[length_] = L'\0';
|
| }
|
|
|
| -
|
| // If link_name points to a link, IsBrokenLink will return true if link_name
|
| // points to an invalid target.
|
| static bool IsBrokenLink(const wchar_t* link_name) {
|
| @@ -91,7 +83,6 @@ static bool IsBrokenLink(const wchar_t* link_name) {
|
| }
|
| }
|
|
|
| -
|
| // A linked list structure holding a link target's unique file system ID.
|
| // Used to detect loops in the file system when listing recursively.
|
| struct LinkList {
|
| @@ -104,7 +95,6 @@ struct LinkList {
|
| // Forward declarations.
|
| static bool DeleteRecursively(PathBuffer* path);
|
|
|
| -
|
| static ListType HandleFindFile(DirectoryListing* listing,
|
| DirectoryListingEntry* entry,
|
| const WIN32_FIND_DATAW& find_file_data) {
|
| @@ -170,7 +160,6 @@ static ListType HandleFindFile(DirectoryListing* listing,
|
| }
|
| }
|
|
|
| -
|
| ListType DirectoryListingEntry::Next(DirectoryListing* listing) {
|
| if (done_) {
|
| return kListDone;
|
| @@ -219,7 +208,6 @@ ListType DirectoryListingEntry::Next(DirectoryListing* listing) {
|
| return kListDone;
|
| }
|
|
|
| -
|
| DirectoryListingEntry::~DirectoryListingEntry() {
|
| ResetLink();
|
| if (lister_ != 0) {
|
| @@ -227,7 +215,6 @@ DirectoryListingEntry::~DirectoryListingEntry() {
|
| }
|
| }
|
|
|
| -
|
| void DirectoryListingEntry::ResetLink() {
|
| if ((link_ != NULL) && ((parent_ == NULL) || (parent_->link_ != link_))) {
|
| delete link_;
|
| @@ -238,7 +225,6 @@ void DirectoryListingEntry::ResetLink() {
|
| }
|
| }
|
|
|
| -
|
| static bool DeleteFile(wchar_t* file_name, PathBuffer* path) {
|
| if (!path->AddW(file_name)) {
|
| return false;
|
| @@ -271,7 +257,6 @@ static bool DeleteFile(wchar_t* file_name, PathBuffer* path) {
|
| return false;
|
| }
|
|
|
| -
|
| static bool DeleteDir(wchar_t* dir_name, PathBuffer* path) {
|
| if ((wcscmp(dir_name, L".") == 0) || (wcscmp(dir_name, L"..") == 0)) {
|
| return true;
|
| @@ -279,7 +264,6 @@ static bool DeleteDir(wchar_t* dir_name, PathBuffer* path) {
|
| return path->AddW(dir_name) && DeleteRecursively(path);
|
| }
|
|
|
| -
|
| static bool DeleteEntry(LPWIN32_FIND_DATAW find_file_data, PathBuffer* path) {
|
| DWORD attributes = find_file_data->dwFileAttributes;
|
|
|
| @@ -290,7 +274,6 @@ static bool DeleteEntry(LPWIN32_FIND_DATAW find_file_data, PathBuffer* path) {
|
| }
|
| }
|
|
|
| -
|
| static bool DeleteRecursively(PathBuffer* path) {
|
| DWORD attributes = GetFileAttributesW(path->AsStringW());
|
| if (attributes == INVALID_FILE_ATTRIBUTES) {
|
| @@ -342,7 +325,6 @@ static bool DeleteRecursively(PathBuffer* path) {
|
| return RemoveDirectoryW(path->AsStringW()) != 0;
|
| }
|
|
|
| -
|
| static Directory::ExistsResult ExistsHelper(const wchar_t* dir_name) {
|
| DWORD attributes = GetFileAttributesW(dir_name);
|
| if (attributes == INVALID_FILE_ATTRIBUTES) {
|
| @@ -362,13 +344,11 @@ static Directory::ExistsResult ExistsHelper(const wchar_t* dir_name) {
|
| return exists ? Directory::EXISTS : Directory::DOES_NOT_EXIST;
|
| }
|
|
|
| -
|
| Directory::ExistsResult Directory::Exists(const char* dir_name) {
|
| Utf8ToWideScope system_name(dir_name);
|
| return ExistsHelper(system_name.wide());
|
| }
|
|
|
| -
|
| char* Directory::CurrentNoScope() {
|
| int length = GetCurrentDirectoryW(0, NULL);
|
| if (length == 0) {
|
| @@ -384,7 +364,6 @@ char* Directory::CurrentNoScope() {
|
| return result;
|
| }
|
|
|
| -
|
| const char* Directory::Current() {
|
| int length = GetCurrentDirectoryW(0, NULL);
|
| if (length == 0) {
|
| @@ -397,14 +376,12 @@ const char* Directory::Current() {
|
| return StringUtilsWin::WideToUtf8(current);
|
| }
|
|
|
| -
|
| bool Directory::SetCurrent(const char* path) {
|
| Utf8ToWideScope system_path(path);
|
| bool result = SetCurrentDirectoryW(system_path.wide()) != 0;
|
| return result;
|
| }
|
|
|
| -
|
| bool Directory::Create(const char* dir_name) {
|
| Utf8ToWideScope system_name(dir_name);
|
| int create_status = CreateDirectoryW(system_name.wide(), NULL);
|
| @@ -416,7 +393,6 @@ bool Directory::Create(const char* dir_name) {
|
| return (create_status != 0);
|
| }
|
|
|
| -
|
| const char* Directory::SystemTemp() {
|
| PathBuffer path;
|
| // Remove \ at end.
|
| @@ -424,7 +400,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.
|
| @@ -464,7 +439,6 @@ const char* Directory::CreateTemp(const char* prefix) {
|
| return path.AsScopedString();
|
| }
|
|
|
| -
|
| bool Directory::Delete(const char* dir_name, bool recursive) {
|
| bool result = false;
|
| Utf8ToWideScope system_dir_name(dir_name);
|
| @@ -483,7 +457,6 @@ bool Directory::Delete(const char* dir_name, bool recursive) {
|
| return result;
|
| }
|
|
|
| -
|
| bool Directory::Rename(const char* path, const char* new_path) {
|
| Utf8ToWideScope system_path(path);
|
| Utf8ToWideScope system_new_path(new_path);
|
|
|