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:
|
2011-01-30 18:05:38 +03:00
|
|
|
PackageReaderImpl(
|
|
|
|
BErrorOutput* errorOutput);
|
|
|
|
~PackageReaderImpl();
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
status_t Init(const char* fileName);
|
2009-11-17 14:33:50 +03:00
|
|
|
status_t Init(int fd, bool keepFD);
|
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;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// from ReaderImplBase
|
|
|
|
virtual status_t ReadAttributeValue(uint8 type, uint8 encoding,
|
|
|
|
AttributeValue& _value);
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct DataAttributeHandler;
|
|
|
|
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 fTotalSize;
|
|
|
|
uint64 fHeapOffset;
|
|
|
|
uint64 fHeapSize;
|
|
|
|
|
2011-02-05 01:42:56 +03:00
|
|
|
SectionInfo 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-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_
|