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

Side by Side Diff: chrome/test/chromedriver/chrome/zip.cc

Issue 13165005: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge, fixes Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/automation/proxy_launcher.cc ('k') | chrome/test/chromedriver/util.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/test/chromedriver/chrome/zip.h" 5 #include "chrome/test/chromedriver/chrome/zip.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_enumerator.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/string16.h" 11 #include "base/string16.h"
11 #include "base/string_util.h" 12 #include "base/string_util.h"
12 #include "chrome/test/chromedriver/chrome/zip_internal.h" 13 #include "chrome/test/chromedriver/chrome/zip_internal.h"
13 #include "chrome/test/chromedriver/chrome/zip_reader.h" 14 #include "chrome/test/chromedriver/chrome/zip_reader.h"
14 #include "net/base/file_stream.h" 15 #include "net/base/file_stream.h"
15 16
16 #if defined(USE_SYSTEM_MINIZIP) 17 #if defined(USE_SYSTEM_MINIZIP)
17 #include <minizip/unzip.h> 18 #include <minizip/unzip.h>
18 #include <minizip/zip.h> 19 #include <minizip/zip.h>
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 131
131 zipFile zip_file = internal::OpenForZipping(dest_file.AsUTF8Unsafe(), 132 zipFile zip_file = internal::OpenForZipping(dest_file.AsUTF8Unsafe(),
132 APPEND_STATUS_CREATE); 133 APPEND_STATUS_CREATE);
133 134
134 if (!zip_file) { 135 if (!zip_file) {
135 DLOG(WARNING) << "couldn't create file " << dest_file.value(); 136 DLOG(WARNING) << "couldn't create file " << dest_file.value();
136 return false; 137 return false;
137 } 138 }
138 139
139 bool success = true; 140 bool success = true;
140 file_util::FileEnumerator file_enumerator(src_dir, true /* recursive */, 141 base::FileEnumerator file_enumerator(src_dir, true /* recursive */,
141 file_util::FileEnumerator::FILES | 142 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES);
142 file_util::FileEnumerator::DIRECTORIES);
143 for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); 143 for (base::FilePath path = file_enumerator.Next(); !path.value().empty();
144 path = file_enumerator.Next()) { 144 path = file_enumerator.Next()) {
145 if (!filter_cb.Run(path)) { 145 if (!filter_cb.Run(path)) {
146 continue; 146 continue;
147 } 147 }
148 148
149 if (!AddEntryToZip(zip_file, path, src_dir)) { 149 if (!AddEntryToZip(zip_file, path, src_dir)) {
150 success = false; 150 success = false;
151 return false; 151 return false;
152 } 152 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (ZIP_OK != zipClose(zip_file, NULL)) { 198 if (ZIP_OK != zipClose(zip_file, NULL)) {
199 DLOG(ERROR) << "Error closing zip file for fd " << dest_fd; 199 DLOG(ERROR) << "Error closing zip file for fd " << dest_fd;
200 success = false; 200 success = false;
201 } 201 }
202 202
203 return success; 203 return success;
204 } 204 }
205 #endif // defined(OS_POSIX) 205 #endif // defined(OS_POSIX)
206 206
207 } // namespace zip 207 } // namespace zip
OLDNEW
« no previous file with comments | « chrome/test/automation/proxy_launcher.cc ('k') | chrome/test/chromedriver/util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698