1 /* 2 * Copyright 2009, 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 #include <package/hpkg/PackageReaderImpl.h> 13 14 15 namespace BPackageKit { 16 17 namespace BHPKG { 18 19 20 BPackageReader::BPackageReader(BErrorOutput* errorOutput) 21 : 22 fImpl(new (std::nothrow) PackageReaderImpl(errorOutput)) 23 { 24 } 25 26 27 BPackageReader::~BPackageReader() 28 { 29 delete fImpl; 30 } 31 32 33 status_t 34 BPackageReader::Init(const char* fileName) 35 { 36 if (fImpl == NULL) 37 return B_NO_INIT; 38 39 return fImpl->Init(fileName); 40 } 41 42 43 status_t 44 BPackageReader::Init(int fd, bool keepFD) 45 { 46 if (fImpl == NULL) 47 return B_NO_INIT; 48 49 return fImpl->Init(fd, keepFD); 50 } 51 52 53 status_t 54 BPackageReader::ParseContent(BPackageContentHandler* contentHandler) 55 { 56 if (fImpl == NULL) 57 return B_NO_INIT; 58 59 return fImpl->ParseContent(contentHandler); 60 } 61 62 63 status_t 64 BPackageReader::ParseContent(BLowLevelPackageContentHandler* contentHandler) 65 { 66 if (fImpl == NULL) 67 return B_NO_INIT; 68 69 return fImpl->ParseContent(contentHandler); 70 } 71 72 73 int 74 BPackageReader::PackageFileFD() 75 { 76 if (fImpl == NULL) 77 return -1; 78 79 return fImpl->PackageFileFD(); 80 } 81 82 83 } // namespace BHPKG 84 85 } // namespace BPackageKit 86