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

Side by Side Diff: third_party/zlib/google/zip_reader.h

Issue 99333019: Preserve modification timestamp when zipping files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed review issues 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 | « third_party/zlib/google/zip.cc ('k') | third_party/zlib/google/zip_reader.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_ 5 #ifndef THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_
6 #define THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_ 6 #define THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 const unz_file_info& raw_file_info); 50 const unz_file_info& raw_file_info);
51 51
52 // Returns the file path. The path is usually relative like 52 // Returns the file path. The path is usually relative like
53 // "foo/bar.txt", but if it's absolute, is_unsafe() returns true. 53 // "foo/bar.txt", but if it's absolute, is_unsafe() returns true.
54 const base::FilePath& file_path() const { return file_path_; } 54 const base::FilePath& file_path() const { return file_path_; }
55 55
56 // Returns the size of the original file (i.e. after uncompressed). 56 // Returns the size of the original file (i.e. after uncompressed).
57 // Returns 0 if the entry is a directory. 57 // Returns 0 if the entry is a directory.
58 int64 original_size() const { return original_size_; } 58 int64 original_size() const { return original_size_; }
59 59
60 // Returns the last modified time. 60 // Returns the last modified time. If the time stored in the zip file was
61 // not valid, the unix epoch will be returned.
satorux1 2013/12/17 02:32:25 Please document that the timestamp resolution is t
João Eiras 2013/12/17 10:15:38 Done.
61 base::Time last_modified() const { return last_modified_; } 62 base::Time last_modified() const { return last_modified_; }
62 63
63 // Returns true if the entry is a directory. 64 // Returns true if the entry is a directory.
64 bool is_directory() const { return is_directory_; } 65 bool is_directory() const { return is_directory_; }
65 66
66 // Returns true if the entry is unsafe, like having ".." or invalid 67 // Returns true if the entry is unsafe, like having ".." or invalid
67 // UTF-8 characters in its file name, or the file path is absolute. 68 // UTF-8 characters in its file name, or the file path is absolute.
68 bool is_unsafe() const { return is_unsafe_; } 69 bool is_unsafe() const { return is_unsafe_; }
69 70
70 private: 71 private:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // Locates an entry in the zip file and opens it. Returns true on 121 // Locates an entry in the zip file and opens it. Returns true on
121 // success. This function internally calls OpenCurrentEntryInZip() on 122 // success. This function internally calls OpenCurrentEntryInZip() on
122 // success. On failure, current_entry_info() becomes NULL. 123 // success. On failure, current_entry_info() becomes NULL.
123 bool LocateAndOpenEntry(const base::FilePath& path_in_zip); 124 bool LocateAndOpenEntry(const base::FilePath& path_in_zip);
124 125
125 // Extracts the current entry to the given output file path. If the 126 // Extracts the current entry to the given output file path. If the
126 // current file is a directory, just creates a directory 127 // current file is a directory, just creates a directory
127 // instead. Returns true on success. OpenCurrentEntryInZip() must be 128 // instead. Returns true on success. OpenCurrentEntryInZip() must be
128 // called beforehand. 129 // called beforehand.
129 // 130 //
130 // This function does not preserve the timestamp of the original entry. 131 // This function preserves the timestamp of the original entry. If that
132 // timestamp is not valid, the timestamp will be set to the current time.
131 bool ExtractCurrentEntryToFilePath(const base::FilePath& output_file_path); 133 bool ExtractCurrentEntryToFilePath(const base::FilePath& output_file_path);
132 134
133 // Extracts the current entry to the given output directory path using 135 // Extracts the current entry to the given output directory path using
134 // ExtractCurrentEntryToFilePath(). Sub directories are created as needed 136 // ExtractCurrentEntryToFilePath(). Sub directories are created as needed
135 // based on the file path of the current entry. For example, if the file 137 // based on the file path of the current entry. For example, if the file
136 // path in zip is "foo/bar.txt", and the output directory is "output", 138 // path in zip is "foo/bar.txt", and the output directory is "output",
137 // "output/foo/bar.txt" will be created. 139 // "output/foo/bar.txt" will be created.
138 // 140 //
139 // Returns true on success. OpenCurrentEntryInZip() must be called 141 // Returns true on success. OpenCurrentEntryInZip() must be called
140 // beforehand. 142 // beforehand.
143 //
144 // This function preserves the timestamp of the original entry. If that
145 // timestamp is not valid, the timestamp will be set to the current time.
141 bool ExtractCurrentEntryIntoDirectory( 146 bool ExtractCurrentEntryIntoDirectory(
142 const base::FilePath& output_directory_path); 147 const base::FilePath& output_directory_path);
143 148
144 #if defined(OS_POSIX) 149 #if defined(OS_POSIX)
145 // Extracts the current entry by writing directly to a file descriptor. 150 // Extracts the current entry by writing directly to a file descriptor.
146 // Does not close the file descriptor. Returns true on success. 151 // Does not close the file descriptor. Returns true on success.
147 bool ExtractCurrentEntryToFd(int fd); 152 bool ExtractCurrentEntryToFd(int fd);
148 #endif 153 #endif
149 154
150 // Returns the current entry info. Returns NULL if the current entry is 155 // Returns the current entry info. Returns NULL if the current entry is
(...skipping 17 matching lines...) Expand all
168 int num_entries_; 173 int num_entries_;
169 bool reached_end_; 174 bool reached_end_;
170 scoped_ptr<EntryInfo> current_entry_info_; 175 scoped_ptr<EntryInfo> current_entry_info_;
171 176
172 DISALLOW_COPY_AND_ASSIGN(ZipReader); 177 DISALLOW_COPY_AND_ASSIGN(ZipReader);
173 }; 178 };
174 179
175 } // namespace zip 180 } // namespace zip
176 181
177 #endif // THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_ 182 #endif // THIRD_PARTY_ZLIB_GOOGLE_ZIP_READER_H_
OLDNEW
« no previous file with comments | « third_party/zlib/google/zip.cc ('k') | third_party/zlib/google/zip_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698