17575abbcSIngo Weinhold/*
27575abbcSIngo Weinhold * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
37575abbcSIngo Weinhold * Distributed under the terms of the MIT License.
47575abbcSIngo Weinhold */
57575abbcSIngo Weinhold
67575abbcSIngo Weinhold
77575abbcSIngo Weinhold#include <package/hpkg/v1/PackageReader.h>
87575abbcSIngo Weinhold
97575abbcSIngo Weinhold#include <new>
107575abbcSIngo Weinhold
117575abbcSIngo Weinhold#include <package/hpkg/ErrorOutput.h>
127575abbcSIngo Weinhold#include <package/hpkg/v1/PackageReaderImpl.h>
137575abbcSIngo Weinhold
147575abbcSIngo Weinhold
157575abbcSIngo Weinholdnamespace BPackageKit {
167575abbcSIngo Weinhold
177575abbcSIngo Weinholdnamespace BHPKG {
187575abbcSIngo Weinhold
197575abbcSIngo Weinholdnamespace V1 {
207575abbcSIngo Weinhold
217575abbcSIngo Weinhold
227575abbcSIngo WeinholdBPackageReader::BPackageReader(BErrorOutput* errorOutput)
237575abbcSIngo Weinhold	:
247575abbcSIngo Weinhold	fImpl(new (std::nothrow) PackageReaderImpl(errorOutput))
257575abbcSIngo Weinhold{
267575abbcSIngo Weinhold}
277575abbcSIngo Weinhold
287575abbcSIngo Weinhold
297575abbcSIngo WeinholdBPackageReader::~BPackageReader()
307575abbcSIngo Weinhold{
317575abbcSIngo Weinhold	delete fImpl;
327575abbcSIngo Weinhold}
337575abbcSIngo Weinhold
347575abbcSIngo Weinhold
357575abbcSIngo Weinholdstatus_t
367575abbcSIngo WeinholdBPackageReader::Init(const char* fileName)
377575abbcSIngo Weinhold{
387575abbcSIngo Weinhold	if (fImpl == NULL)
397575abbcSIngo Weinhold		return B_NO_INIT;
407575abbcSIngo Weinhold
417575abbcSIngo Weinhold	return fImpl->Init(fileName);
427575abbcSIngo Weinhold}
437575abbcSIngo Weinhold
447575abbcSIngo Weinhold
457575abbcSIngo Weinholdstatus_t
467575abbcSIngo WeinholdBPackageReader::Init(int fd, bool keepFD)
477575abbcSIngo Weinhold{
487575abbcSIngo Weinhold	if (fImpl == NULL)
497575abbcSIngo Weinhold		return B_NO_INIT;
507575abbcSIngo Weinhold
517575abbcSIngo Weinhold	return fImpl->Init(fd, keepFD);
527575abbcSIngo Weinhold}
537575abbcSIngo Weinhold
547575abbcSIngo Weinhold
557575abbcSIngo Weinholdstatus_t
567575abbcSIngo WeinholdBPackageReader::ParseContent(BPackageContentHandler* contentHandler)
577575abbcSIngo Weinhold{
587575abbcSIngo Weinhold	if (fImpl == NULL)
597575abbcSIngo Weinhold		return B_NO_INIT;
607575abbcSIngo Weinhold
617575abbcSIngo Weinhold	return fImpl->ParseContent(contentHandler);
627575abbcSIngo Weinhold}
637575abbcSIngo Weinhold
647575abbcSIngo Weinhold
657575abbcSIngo Weinholdstatus_t
667575abbcSIngo WeinholdBPackageReader::ParseContent(BLowLevelPackageContentHandler* contentHandler)
677575abbcSIngo Weinhold{
687575abbcSIngo Weinhold	if (fImpl == NULL)
697575abbcSIngo Weinhold		return B_NO_INIT;
707575abbcSIngo Weinhold
717575abbcSIngo Weinhold	return fImpl->ParseContent(contentHandler);
727575abbcSIngo Weinhold}
737575abbcSIngo Weinhold
747575abbcSIngo Weinhold
757575abbcSIngo Weinholdint
767575abbcSIngo WeinholdBPackageReader::PackageFileFD()
777575abbcSIngo Weinhold{
787575abbcSIngo Weinhold	if (fImpl == NULL)
797575abbcSIngo Weinhold		return -1;
807575abbcSIngo Weinhold
817575abbcSIngo Weinhold	return fImpl->PackageFileFD();
827575abbcSIngo Weinhold}
837575abbcSIngo Weinhold
847575abbcSIngo Weinhold
857575abbcSIngo Weinhold}	// namespace V1
867575abbcSIngo Weinhold
877575abbcSIngo Weinhold}	// namespace BHPKG
887575abbcSIngo Weinhold
897575abbcSIngo Weinhold}	// namespace BPackageKit
90