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

Side by Side Diff: chrome/common/zip.cc

Issue 6246036: FilePath: Remove most of ToWStringHack, adding a LossyDisplayName() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bug link Created 9 years, 10 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/common/zip.h" 5 #include "chrome/common/zip.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 unzClose(zip_file); 200 unzClose(zip_file);
201 return ret; 201 return ret;
202 } 202 }
203 203
204 static bool AddFileToZip(zipFile zip_file, const FilePath& src_dir) { 204 static bool AddFileToZip(zipFile zip_file, const FilePath& src_dir) {
205 net::FileStream stream; 205 net::FileStream stream;
206 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; 206 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ;
207 if (stream.Open(src_dir, flags) != 0) { 207 if (stream.Open(src_dir, flags) != 0) {
208 LOG(ERROR) << "Could not open stream for path " 208 LOG(ERROR) << "Could not open stream for path "
209 << WideToASCII(src_dir.ToWStringHack()); 209 << src_dir.value();
210 return false; 210 return false;
211 } 211 }
212 212
213 int num_bytes; 213 int num_bytes;
214 char buf[kZipBufSize]; 214 char buf[kZipBufSize];
215 do { 215 do {
216 num_bytes = stream.Read(buf, kZipBufSize, NULL); 216 num_bytes = stream.Read(buf, kZipBufSize, NULL);
217 if (num_bytes > 0) { 217 if (num_bytes > 0) {
218 if (ZIP_OK != zipWriteInFileInZip(zip_file, buf, num_bytes)) { 218 if (ZIP_OK != zipWriteInFileInZip(zip_file, buf, num_bytes)) {
219 LOG(ERROR) << "Could not write data to zip for path " 219 LOG(ERROR) << "Could not write data to zip for path "
220 << WideToASCII(src_dir.ToWStringHack()); 220 << src_dir.value();
221 return false; 221 return false;
222 } 222 }
223 } 223 }
224 } while (num_bytes > 0); 224 } while (num_bytes > 0);
225 225
226 return true; 226 return true;
227 } 227 }
228 228
229 static bool AddEntryToZip(zipFile zip_file, const FilePath& path, 229 static bool AddEntryToZip(zipFile zip_file, const FilePath& path,
230 const FilePath& root_path) { 230 const FilePath& root_path) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 289 }
290 290
291 bool success = true; 291 bool success = true;
292 file_util::FileEnumerator file_enumerator( 292 file_util::FileEnumerator file_enumerator(
293 src_dir, true, // recursive 293 src_dir, true, // recursive
294 static_cast<file_util::FileEnumerator::FILE_TYPE>( 294 static_cast<file_util::FileEnumerator::FILE_TYPE>(
295 file_util::FileEnumerator::FILES | 295 file_util::FileEnumerator::FILES |
296 file_util::FileEnumerator::DIRECTORIES)); 296 file_util::FileEnumerator::DIRECTORIES));
297 for (FilePath path = file_enumerator.Next(); !path.value().empty(); 297 for (FilePath path = file_enumerator.Next(); !path.value().empty();
298 path = file_enumerator.Next()) { 298 path = file_enumerator.Next()) {
299 if (!include_hidden_files && path.BaseName().ToWStringHack()[0] == L'.') 299 if (!include_hidden_files && path.BaseName().value()[0] == '.')
300 continue; 300 continue;
301 301
302 if (!AddEntryToZip(zip_file, path, src_dir)) { 302 if (!AddEntryToZip(zip_file, path, src_dir)) {
303 success = false; 303 success = false;
304 return false; 304 return false;
305 } 305 }
306 } 306 }
307 307
308 if (ZIP_OK != zipClose(zip_file, NULL)) { // global comment 308 if (ZIP_OK != zipClose(zip_file, NULL)) { // global comment
309 LOG(ERROR) << "Error closing zip file " << dest_file_str; 309 LOG(ERROR) << "Error closing zip file " << dest_file_str;
310 return false; 310 return false;
311 } 311 }
312 312
313 return success; 313 return success;
314 } 314 }
OLDNEW
« no previous file with comments | « chrome/common/sandbox_policy.cc ('k') | chrome/test/mini_installer_test/chrome_mini_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698