xref: /haiku/headers/os/package/hpkg/PackageReader.h (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
1 /*
2  * Copyright 2009,2011, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__HPKG__PACKAGE_READER_H_
6 #define _PACKAGE__HPKG__PACKAGE_READER_H_
7 
8 
9 #include <SupportDefs.h>
10 
11 
12 class BPositionIO;
13 
14 
15 namespace BPackageKit {
16 
17 namespace BHPKG {
18 
19 
20 namespace BPrivate {
21 	class PackageReaderImpl;
22 }
23 using BPrivate::PackageReaderImpl;
24 
25 
26 class BAbstractBufferedDataReader;
27 class BErrorOutput;
28 class BLowLevelPackageContentHandler;
29 class BPackageContentHandler;
30 class BPackageWriter;
31 
32 
33 class BPackageReader {
34 public:
35 								BPackageReader(BErrorOutput* errorOutput);
36 								~BPackageReader();
37 
38 			status_t			Init(const char* fileName, uint32 flags = 0);
39 			status_t			Init(int fd, bool keepFD, uint32 flags = 0);
40 			status_t			Init(BPositionIO* file, bool keepFile,
41 									uint32 flags = 0);
42 			status_t			ParseContent(
43 									BPackageContentHandler* contentHandler);
44 			status_t			ParseContent(BLowLevelPackageContentHandler*
45 										contentHandler);
46 
47 			BPositionIO*		PackageFile() const;
48 
49 			BAbstractBufferedDataReader* HeapReader() const;
50 									// Only valid as long as the reader lives.
51 
52 private:
53 			friend class BPackageWriter;
54 
55 private:
56 			PackageReaderImpl*	fImpl;
57 };
58 
59 
60 }	// namespace BHPKG
61 
62 }	// namespace BPackageKit
63 
64 
65 #endif	// _PACKAGE__HPKG__PACKAGE_READER_H_
66