2009-11-13 16:45:49 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
2011-02-05 01:42:56 +03:00
|
|
|
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
|
2009-11-13 16:45:49 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2011-01-30 18:05:38 +03:00
|
|
|
#ifndef _PACKAGE__HPKG__PRIVATE__PACKAGE_READER_IMPL_H_
|
|
|
|
#define _PACKAGE__HPKG__PRIVATE__PACKAGE_READER_IMPL_H_
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
|
2011-02-14 16:09:09 +03:00
|
|
|
#include <package/hpkg/ReaderImplBase.h>
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
namespace BPackageKit {
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
namespace BHPKG {
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2009-11-13 16:45:49 +03:00
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
class BPackageEntry;
|
|
|
|
class BPackageEntryAttribute;
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
namespace BPrivate {
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
|
2011-02-14 16:09:09 +03:00
|
|
|
class PackageReaderImpl : public ReaderImplBase {
|
|
|
|
typedef ReaderImplBase inherited;
|
2009-11-13 16:45:49 +03:00
|
|
|
public:
|
2013-05-18 06:11:01 +04:00
|
|
|
PackageReaderImpl(BErrorOutput* errorOutput);
|
2011-01-30 18:05:38 +03:00
|
|
|
~PackageReaderImpl();
|
2009-11-13 16:45:49 +03:00
|
|
|
|
2013-05-20 22:15:59 +04:00
|
|
|
status_t Init(const char* fileName, uint32 flags);
|
|
|
|
status_t Init(int fd, bool keepFD, uint32 flags);
|
2009-11-13 16:45:49 +03:00
|
|
|
status_t ParseContent(
|
2011-01-30 18:05:38 +03:00
|
|
|
BPackageContentHandler* contentHandler);
|
|
|
|
status_t ParseContent(BLowLevelPackageContentHandler*
|
2009-11-13 16:45:49 +03:00
|
|
|
contentHandler);
|
|
|
|
|
2011-02-14 16:09:09 +03:00
|
|
|
int PackageFileFD() const;
|
|
|
|
|
2011-07-03 06:08:40 +04:00
|
|
|
uint64 HeapOffset() const;
|
|
|
|
uint64 HeapSize() const;
|
|
|
|
|
2013-05-21 21:42:57 +04:00
|
|
|
PackageFileHeapReader* RawHeapReader() const
|
|
|
|
{ return inherited::RawHeapReader(); }
|
|
|
|
BAbstractBufferedDataReader* HeapReader() const
|
2013-05-18 06:11:01 +04:00
|
|
|
{ return inherited::HeapReader(); }
|
|
|
|
|
2011-02-14 16:09:09 +03:00
|
|
|
protected:
|
|
|
|
// from ReaderImplBase
|
|
|
|
virtual status_t ReadAttributeValue(uint8 type, uint8 encoding,
|
|
|
|
AttributeValue& _value);
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct AttributeAttributeHandler;
|
|
|
|
struct EntryAttributeHandler;
|
2011-02-12 22:21:37 +03:00
|
|
|
struct RootAttributeHandler;
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
private:
|
2011-02-14 16:09:09 +03:00
|
|
|
status_t _ParseTOC(AttributeHandlerContext* context,
|
2009-11-13 16:45:49 +03:00
|
|
|
AttributeHandler* rootAttributeHandler);
|
|
|
|
|
|
|
|
status_t _GetTOCBuffer(size_t size,
|
|
|
|
const void*& _buffer);
|
|
|
|
private:
|
|
|
|
uint64 fHeapOffset;
|
|
|
|
uint64 fHeapSize;
|
|
|
|
|
2013-05-18 06:11:01 +04:00
|
|
|
PackageFileSection fTOCSection;
|
2009-11-13 16:45:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-02-14 16:09:09 +03:00
|
|
|
inline int
|
|
|
|
PackageReaderImpl::PackageFileFD() const
|
2009-11-13 16:45:49 +03:00
|
|
|
{
|
2011-02-14 16:09:09 +03:00
|
|
|
return FD();
|
2009-11-13 16:45:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-03 06:08:40 +04:00
|
|
|
inline uint64
|
|
|
|
PackageReaderImpl::HeapOffset() const
|
|
|
|
{
|
|
|
|
return fHeapOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline uint64
|
|
|
|
PackageReaderImpl::HeapSize() const
|
|
|
|
{
|
|
|
|
return fHeapSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-28 02:17:03 +03:00
|
|
|
} // namespace BPrivate
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
} // namespace BHPKG
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
#endif // _PACKAGE__HPKG__PRIVATE__PACKAGE_READER_IMPL_H_
|