OLD | NEW |
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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 zip_info.tmz_date.tm_min = file_time_parts.minute; | 46 zip_info.tmz_date.tm_min = file_time_parts.minute; |
47 zip_info.tmz_date.tm_sec = file_time_parts.second; | 47 zip_info.tmz_date.tm_sec = file_time_parts.second; |
48 } | 48 } |
49 | 49 |
50 return zip_info; | 50 return zip_info; |
51 } | 51 } |
52 | 52 |
53 // Returns a zip_fileinfo with the last modification date of |path| set. | 53 // Returns a zip_fileinfo with the last modification date of |path| set. |
54 zip_fileinfo GetFileInfoForZipping(const base::FilePath& path) { | 54 zip_fileinfo GetFileInfoForZipping(const base::FilePath& path) { |
55 base::Time file_time; | 55 base::Time file_time; |
56 base::PlatformFileInfo file_info; | 56 base::File::Info file_info; |
57 if (base::GetFileInfo(path, &file_info)) | 57 if (base::GetFileInfo(path, &file_info)) |
58 file_time = file_info.last_modified; | 58 file_time = file_info.last_modified; |
59 return TimeToZipFileInfo(file_time); | 59 return TimeToZipFileInfo(file_time); |
60 } | 60 } |
61 | 61 |
62 bool AddFileToZip(zipFile zip_file, const base::FilePath& src_dir) { | 62 bool AddFileToZip(zipFile zip_file, const base::FilePath& src_dir) { |
63 net::FileStream stream(NULL); | 63 net::FileStream stream(NULL); |
64 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; | 64 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; |
65 if (stream.OpenSync(src_dir, flags) != 0) { | 65 if (stream.OpenSync(src_dir, flags) != 0) { |
66 DLOG(ERROR) << "Could not open stream for path " | 66 DLOG(ERROR) << "Could not open stream for path " |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 if (ZIP_OK != zipClose(zip_file, NULL)) { | 255 if (ZIP_OK != zipClose(zip_file, NULL)) { |
256 DLOG(ERROR) << "Error closing zip file for fd " << dest_fd; | 256 DLOG(ERROR) << "Error closing zip file for fd " << dest_fd; |
257 success = false; | 257 success = false; |
258 } | 258 } |
259 | 259 |
260 return success; | 260 return success; |
261 } | 261 } |
262 #endif // defined(OS_POSIX) | 262 #endif // defined(OS_POSIX) |
263 | 263 |
264 } // namespace zip | 264 } // namespace zip |
OLD | NEW |