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

Side by Side Diff: third_party/zlib/google/zip.cc

Issue 106663006: Followup for bug when zipping a folder with non-ascii chars in its name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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 | « no previous file | third_party/zlib/google/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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "third_party/zlib/google/zip.h" 5 #include "third_party/zlib/google/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/files/file_enumerator.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return false; 44 return false;
45 } 45 }
46 } 46 }
47 } while (num_bytes > 0); 47 } while (num_bytes > 0);
48 48
49 return true; 49 return true;
50 } 50 }
51 51
52 bool AddEntryToZip(zipFile zip_file, const base::FilePath& path, 52 bool AddEntryToZip(zipFile zip_file, const base::FilePath& path,
53 const base::FilePath& root_path) { 53 const base::FilePath& root_path) {
54 std::string str_path = 54 base::FilePath relative_path;
55 path.AsUTF8Unsafe().substr(root_path.AsUTF8Unsafe().length() + 1); 55 bool result = root_path.AppendRelativePath(path, &relative_path);
56 DCHECK(result);
57 std::string str_path = relative_path.AsUTF8Unsafe();
56 #if defined(OS_WIN) 58 #if defined(OS_WIN)
57 ReplaceSubstringsAfterOffset(&str_path, 0u, "\\", "/"); 59 ReplaceSubstringsAfterOffset(&str_path, 0u, "\\", "/");
58 #endif 60 #endif
59 61
60 bool is_directory = base::DirectoryExists(path); 62 bool is_directory = base::DirectoryExists(path);
61 if (is_directory) 63 if (is_directory)
62 str_path += "/"; 64 str_path += "/";
63 65
64 if (ZIP_OK != zipOpenNewFileInZip( 66 if (ZIP_OK != zipOpenNewFileInZip(
65 zip_file, str_path.c_str(), 67 zip_file, str_path.c_str(),
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (ZIP_OK != zipClose(zip_file, NULL)) { 200 if (ZIP_OK != zipClose(zip_file, NULL)) {
199 DLOG(ERROR) << "Error closing zip file for fd " << dest_fd; 201 DLOG(ERROR) << "Error closing zip file for fd " << dest_fd;
200 success = false; 202 success = false;
201 } 203 }
202 204
203 return success; 205 return success;
204 } 206 }
205 #endif // defined(OS_POSIX) 207 #endif // defined(OS_POSIX)
206 208
207 } // namespace zip 209 } // namespace zip
OLDNEW
« no previous file with comments | « no previous file | third_party/zlib/google/zip_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698