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

Side by Side Diff: ui/file_manager/zip_archiver/cpp/volume_reader.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_READER_H_ 5 #ifndef VOLUME_READER_H_
6 #define VOLUME_READER_H_ 6 #define VOLUME_READER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "archive.h"
11
12 // Defines a reader for archive volumes. This class is used by libarchive 10 // Defines a reader for archive volumes. This class is used by libarchive
13 // for custom reads: https://github.com/libarchive/libarchive/wiki/Examples 11 // for custom reads: https://github.com/libarchive/libarchive/wiki/Examples
14 class VolumeReader { 12 class VolumeReader {
15 public: 13 public:
16 virtual ~VolumeReader() {} 14 virtual ~VolumeReader() {}
17 15
18 // Tries to read bytes_to_read from the archive. The result will be stored at 16 // Tries to read bytes_to_read from the archive. The result will be stored at
19 // *destination_buffer, which is the address of a buffer handled by 17 // *destination_buffer, which is the address of a buffer handled by
20 // VolumeReaderJavaScriptStream. *destination_buffer must be available until 18 // VolumeReaderJavaScriptStream. *destination_buffer must be available until
21 // the next VolumeReader:Read call or until VolumeReader is destructed. 19 // the next VolumeReader:Read call or until VolumeReader is destructed.
22 // 20 //
23 // The operation must be synchronous (libarchive requirement), so it 21 // The operation must be synchronous (libarchive requirement), so it
24 // should NOT be done on the main thread. bytes_to_read should be > 0. 22 // should NOT be done on the main thread. bytes_to_read should be > 0.
25 // 23 //
26 // Returns the actual number of read bytes or ARCHIVE_FATAL in case of 24 // Returns the actual number of read bytes or -1 in case of failure.
27 // failure.
28 virtual int64_t Read(int64_t bytes_to_read, 25 virtual int64_t Read(int64_t bytes_to_read,
29 const void** destination_buffer) = 0; 26 const void** destination_buffer) = 0;
30 27
31 // Tries to skip bytes_to_skip number of bytes. Returns the actual number of
32 // skipped bytes or 0 if none were skipped. In case of failure
33 // VolumeReader::Skip returns 0 bytes and VolumeReader::Read can be used
34 // to skip those bytes by discarding them.
35 virtual int64_t Skip(int64_t bytes_to_skip) = 0;
36
37 // Tries to seek to offset from whence. Returns the resulting offset location 28 // Tries to seek to offset from whence. Returns the resulting offset location
38 // or ARCHIVE_FATAL in case of errors. Similar to 29 // or -1 in case of errors. Similar to
39 // http://www.cplusplus.com/reference/cstdio/fseek/ 30 // http://www.cplusplus.com/reference/cstdio/fseek/
40 virtual int64_t Seek(int64_t offset, int whence) = 0; 31 virtual int64_t Seek(int64_t offset, int whence) = 0;
41 32
42 // Fetches a passphrase for reading. If the passphrase is not available it 33 // Fetches a passphrase for reading. If the passphrase is not available it
43 // returns NULL. 34 // returns nullptr.
44 virtual const char* Passphrase() = 0; 35 virtual const char* Passphrase() = 0;
36
37 virtual int64_t offset() = 0;
38
39 virtual int64_t archive_size() = 0;
45 }; 40 };
46 41
47 #endif // VOLUME_READER_H_ 42 #endif // VOLUME_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698