Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: services/files/directory_impl.cc

Issue 1397133002: Remove callers of mojo::Array<size_t> constructor in favor of ::New (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/clipboard/clipboard_standalone_impl.cc ('k') | services/files/file_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/files/directory_impl.h" 5 #include "services/files/directory_impl.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 callback.Run(ErrnoToError(errno), Array<DirectoryEntryPtr>()); 118 callback.Run(ErrnoToError(errno), Array<DirectoryEntryPtr>());
119 return; 119 return;
120 } 120 }
121 121
122 ScopedDIR dir(fdopendir(fd.release())); 122 ScopedDIR dir(fdopendir(fd.release()));
123 if (!dir) { 123 if (!dir) {
124 callback.Run(ErrnoToError(errno), Array<DirectoryEntryPtr>()); 124 callback.Run(ErrnoToError(errno), Array<DirectoryEntryPtr>());
125 return; 125 return;
126 } 126 }
127 127
128 Array<DirectoryEntryPtr> result(0); 128 auto result = Array<DirectoryEntryPtr>::New(0);
129 129
130 // Warning: This is not portable (per POSIX.1 -- |buffer| may not be large 130 // Warning: This is not portable (per POSIX.1 -- |buffer| may not be large
131 // enough), but it's fine for Linux. 131 // enough), but it's fine for Linux.
132 #if !defined(OS_ANDROID) && !defined(OS_LINUX) 132 #if !defined(OS_ANDROID) && !defined(OS_LINUX)
133 #error "Use of struct dirent for readdir_r() buffer not portable; please check." 133 #error "Use of struct dirent for readdir_r() buffer not portable; please check."
134 #endif 134 #endif
135 struct dirent buffer; 135 struct dirent buffer;
136 for (size_t n = 0;;) { 136 for (size_t n = 0;;) {
137 struct dirent* entry = nullptr; 137 struct dirent* entry = nullptr;
138 if (int error = readdir_r(dir.get(), &buffer, &entry)) { 138 if (int error = readdir_r(dir.get(), &buffer, &entry)) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 if (unlinkat(dir_fd_.get(), path.get().c_str(), AT_REMOVEDIR) == 0) { 353 if (unlinkat(dir_fd_.get(), path.get().c_str(), AT_REMOVEDIR) == 0) {
354 callback.Run(Error::OK); 354 callback.Run(Error::OK);
355 return; 355 return;
356 } 356 }
357 357
358 callback.Run(ErrnoToError(errno)); 358 callback.Run(ErrnoToError(errno));
359 } 359 }
360 360
361 } // namespace files 361 } // namespace files
362 } // namespace mojo 362 } // namespace mojo
OLDNEW
« no previous file with comments | « services/clipboard/clipboard_standalone_impl.cc ('k') | services/files/file_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698