1 /* 2 * Copyright 2009-2013, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <package/hpkg/PackageReader.h> 8 9 #include <new> 10 11 #include <package/hpkg/ErrorOutput.h> 12 13 #include <package/hpkg/PackageFileHeapReader.h> 14 #include <package/hpkg/PackageReaderImpl.h> 15 16 17 namespace BPackageKit { 18 19 namespace BHPKG { 20 21 22 BPackageReader::BPackageReader(BErrorOutput* errorOutput) 23 : 24 fImpl(new (std::nothrow) PackageReaderImpl(errorOutput)) 25 { 26 } 27 28 29 BPackageReader::~BPackageReader() 30 { 31 delete fImpl; 32 } 33 34 35 status_t 36 BPackageReader::Init(const char* fileName, uint32 flags) 37 { 38 if (fImpl == NULL) 39 return B_NO_INIT; 40 41 return fImpl->Init(fileName, flags); 42 } 43 44 45 status_t 46 BPackageReader::Init(int fd, bool keepFD, uint32 flags) 47 { 48 if (fImpl == NULL) 49 return B_NO_INIT; 50 51 return fImpl->Init(fd, keepFD, flags); 52 } 53 54 55 status_t 56 BPackageReader::ParseContent(BPackageContentHandler* contentHandler) 57 { 58 if (fImpl == NULL) 59 return B_NO_INIT; 60 61 return fImpl->ParseContent(contentHandler); 62 } 63 64 65 status_t 66 BPackageReader::ParseContent(BLowLevelPackageContentHandler* contentHandler) 67 { 68 if (fImpl == NULL) 69 return B_NO_INIT; 70 71 return fImpl->ParseContent(contentHandler); 72 } 73 74 75 int 76 BPackageReader::PackageFileFD() 77 { 78 if (fImpl == NULL) 79 return -1; 80 81 return fImpl->PackageFileFD(); 82 } 83 84 85 86 BAbstractBufferedDataReader* 87 BPackageReader::HeapReader() const 88 { 89 return fImpl != NULL ? fImpl->HeapReader() : NULL; 90 } 91 92 93 } // namespace BHPKG 94 95 } // namespace BPackageKit 96