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

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

Issue 340018: Filter out hidden files, both when loading extensions and when (Closed)
Patch Set: Created 11 years, 1 month 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 | « chrome/common/zip.h ('k') | chrome/common/zip_unittest.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) 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/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/file_stream.h" 9 #include "net/base/file_stream.h"
10 #include "third_party/zlib/contrib/minizip/unzip.h" 10 #include "third_party/zlib/contrib/minizip/unzip.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 252
253 if (ZIP_OK != zipCloseFileInZip(zip_file)) { 253 if (ZIP_OK != zipCloseFileInZip(zip_file)) {
254 LOG(ERROR) << "Could not close zip file entry " << str_path; 254 LOG(ERROR) << "Could not close zip file entry " << str_path;
255 return false; 255 return false;
256 } 256 }
257 257
258 return success; 258 return success;
259 } 259 }
260 260
261 bool Zip(const FilePath& src_dir, const FilePath& dest_file) { 261 bool Zip(const FilePath& src_dir, const FilePath& dest_file,
262 bool include_hidden_files) {
262 DCHECK(file_util::DirectoryExists(src_dir)); 263 DCHECK(file_util::DirectoryExists(src_dir));
263 264
264 #if defined(OS_WIN) 265 #if defined(OS_WIN)
265 zlib_filefunc_def zip_funcs; 266 zlib_filefunc_def zip_funcs;
266 fill_win32_filefunc(&zip_funcs); 267 fill_win32_filefunc(&zip_funcs);
267 zip_funcs.zopen_file = ZipOpenFunc; 268 zip_funcs.zopen_file = ZipOpenFunc;
268 #endif 269 #endif
269 270
270 #if defined(OS_POSIX) 271 #if defined(OS_POSIX)
271 std::string dest_file_str = dest_file.value(); 272 std::string dest_file_str = dest_file.value();
(...skipping 12 matching lines...) Expand all
284 } 285 }
285 286
286 bool success = true; 287 bool success = true;
287 file_util::FileEnumerator file_enumerator( 288 file_util::FileEnumerator file_enumerator(
288 src_dir, true, // recursive 289 src_dir, true, // recursive
289 static_cast<file_util::FileEnumerator::FILE_TYPE>( 290 static_cast<file_util::FileEnumerator::FILE_TYPE>(
290 file_util::FileEnumerator::FILES | 291 file_util::FileEnumerator::FILES |
291 file_util::FileEnumerator::DIRECTORIES)); 292 file_util::FileEnumerator::DIRECTORIES));
292 for (FilePath path = file_enumerator.Next(); !path.value().empty(); 293 for (FilePath path = file_enumerator.Next(); !path.value().empty();
293 path = file_enumerator.Next()) { 294 path = file_enumerator.Next()) {
295 if (!include_hidden_files && path.BaseName().ToWStringHack()[0] == L'.')
296 continue;
297
294 if (!AddEntryToZip(zip_file, path, src_dir)) { 298 if (!AddEntryToZip(zip_file, path, src_dir)) {
295 success = false; 299 success = false;
296 return false; 300 return false;
297 } 301 }
298 } 302 }
299 303
300 if (ZIP_OK != zipClose(zip_file, NULL)) { // global comment 304 if (ZIP_OK != zipClose(zip_file, NULL)) { // global comment
301 LOG(ERROR) << "Error closing zip file " << dest_file_str; 305 LOG(ERROR) << "Error closing zip file " << dest_file_str;
302 return false; 306 return false;
303 } 307 }
304 308
305 return success; 309 return success;
306 } 310 }
OLDNEW
« no previous file with comments | « chrome/common/zip.h ('k') | chrome/common/zip_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698