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

Side by Side Diff: ui/file_manager/zip_archiver/cpp/volume_archive.h

Issue 2807063002: Replace Libarchive with MiniZip. (Closed)
Patch Set: Fix a few nits. Created 3 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium OS Authors. All rights reserved. 1 // Copyright 2014 The Chromium OS 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 VOLUME_ARCHIVE_H_ 5 #ifndef VOLUME_ARCHIVE_H_
6 #define VOLUME_ARCHIVE_H_ 6 #define VOLUME_ARCHIVE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "volume_reader.h" 10 #include "volume_reader.h"
(...skipping 13 matching lines...) Expand all
24 RESULT_FAIL, 24 RESULT_FAIL,
25 }; 25 };
26 26
27 // Initializes VolumeArchive. Should be called only once. 27 // Initializes VolumeArchive. Should be called only once.
28 // In case of any errors call VolumeArchive::Cleanup and the error message can 28 // In case of any errors call VolumeArchive::Cleanup and the error message can
29 // be obtained with VolumeArchive::error_message(). Encoding is the default 29 // be obtained with VolumeArchive::error_message(). Encoding is the default
30 // encoding. Note, that other encoding may be used if specified in the 30 // encoding. Note, that other encoding may be used if specified in the
31 // archive file. 31 // archive file.
32 virtual bool Init(const std::string& encoding) = 0; 32 virtual bool Init(const std::string& encoding) = 0;
33 33
34 // Gets the next header. In case of failure the error message can be 34 // Gets the next header. If path_name is set to nullptr, then there are no mor e
35 // obtained with VolumeArchive::error_message(). 35 // available headers. Returns true if reading next header was successful.
36 virtual Result GetNextHeader() = 0; 36 // In case of failure the error message can be obtained with
37 virtual Result GetNextHeader(const char** path_name, 37 // VolumeArchive::error_message().
38 int64_t* size, 38 virtual VolumeArchive::Result GetCurrentFileInfo(
39 bool* is_directory, 39 std::string* path_name,
40 time_t* modification_time) = 0; 40 int64_t* size,
41 bool* is_directory,
42 time_t* modification_time) = 0;
41 43
42 // Seeks to the |index|-th header. 44 virtual VolumeArchive::Result GoToNextFile() = 0;
43 virtual bool SeekHeader(int64_t index) = 0; 45
46 // Seeks to the header whose pathname is path_name.
47 virtual bool SeekHeader(const std::string& path_name) = 0;
44 48
45 // Gets data from offset to offset + length for the file reached with 49 // Gets data from offset to offset + length for the file reached with
46 // VolumeArchive::GetNextHeader. The data is stored in an internal buffer 50 // VolumeArchive::GetNextHeader. The data is stored in an internal buffer
47 // in the implementation of VolumeArchive and it will be returned 51 // in the implementation of VolumeArchive and it will be returned
48 // via *buffer parameter to avoid an extra copy. *buffer is owned by 52 // via *buffer parameter to avoid an extra copy. *buffer is owned by
49 // VolumeArchive. 53 // VolumeArchive.
50 // 54 //
51 // Supports file seek by using the offset parameter. In case offset is less 55 // Supports file seek by using the offset parameter. In case offset is less
52 // then last VolumeArchive::ReadData offset, then the read will be restarted 56 // then last VolumeArchive::ReadData offset, then the read will be restarted
53 // from the beginning of the archive. 57 // from the beginning of the archive.
(...skipping 25 matching lines...) Expand all
79 virtual bool Cleanup() = 0; 83 virtual bool Cleanup() = 0;
80 84
81 VolumeReader* reader() const { return reader_; } 85 VolumeReader* reader() const { return reader_; }
82 std::string error_message() const { return error_message_; } 86 std::string error_message() const { return error_message_; }
83 87
84 protected: 88 protected:
85 // Cleans up the reader. Can be called multiple times, but once called reader 89 // Cleans up the reader. Can be called multiple times, but once called reader
86 // cannot be reinitialized. 90 // cannot be reinitialized.
87 void CleanupReader() { 91 void CleanupReader() {
88 delete reader_; 92 delete reader_;
89 reader_ = NULL; 93 reader_ = nullptr;
90 } 94 }
91 95
92 void set_error_message(const std::string& error_message) { 96 void set_error_message(const std::string& error_message) {
93 error_message_ = error_message; 97 error_message_ = error_message;
94 } 98 }
95 99
96 private: 100 private:
97 VolumeReader* reader_; // The reader that actually reads the archive data. 101 VolumeReader* reader_; // The reader that actually reads the archive data.
98 std::string error_message_; // An error message set in case of any errors. 102 std::string error_message_; // An error message set in case of any errors.
99 }; 103 };
100 104
101 #endif // VOLUME_ARCHIVE_H_ 105 #endif // VOLUME_ARCHIVE_H_
OLDNEW
« no previous file with comments | « ui/file_manager/zip_archiver/cpp/volume.cc ('k') | ui/file_manager/zip_archiver/cpp/volume_archive_libarchive.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698