BPicture: Fix archive constructor.
[haiku.git] / src / kits / package / hpkg / PackageWriter.cpp
blob29f1d6edaf29ec826df1b900057eb5defe9a6c2c
1 /*
2 * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
3 * Distributed under the terms of the MIT License.
4 */
7 #include <package/hpkg/PackageWriter.h>
9 #include <new>
11 #include <package/hpkg/PackageWriterImpl.h>
14 namespace BPackageKit {
16 namespace BHPKG {
19 // #pragma mark - BPackageWriterParameters
22 BPackageWriterParameters::BPackageWriterParameters()
24 fFlags(0),
25 fCompression(B_HPKG_COMPRESSION_ZLIB),
26 fCompressionLevel(B_HPKG_COMPRESSION_LEVEL_BEST)
31 BPackageWriterParameters::~BPackageWriterParameters()
36 uint32
37 BPackageWriterParameters::Flags() const
39 return fFlags;
43 void
44 BPackageWriterParameters::SetFlags(uint32 flags)
46 fFlags = flags;
50 uint32
51 BPackageWriterParameters::Compression() const
53 return fCompression;
57 void
58 BPackageWriterParameters::SetCompression(uint32 compression)
60 fCompression = compression;
64 int32
65 BPackageWriterParameters::CompressionLevel() const
67 return fCompressionLevel;
71 void
72 BPackageWriterParameters::SetCompressionLevel(int32 compressionLevel)
74 fCompressionLevel = compressionLevel;
78 // #pragma mark - BPackageWriter
81 BPackageWriter::BPackageWriter(BPackageWriterListener* listener)
83 fImpl(new (std::nothrow) PackageWriterImpl(listener))
88 BPackageWriter::~BPackageWriter()
90 delete fImpl;
94 status_t
95 BPackageWriter::Init(const char* fileName,
96 const BPackageWriterParameters* parameters)
98 if (fImpl == NULL)
99 return B_NO_MEMORY;
101 BPackageWriterParameters defaultParameters;
103 return fImpl->Init(fileName,
104 parameters != NULL ? *parameters : defaultParameters);
108 status_t
109 BPackageWriter::Init(BPositionIO* file, bool keepFile,
110 const BPackageWriterParameters* parameters)
112 if (fImpl == NULL)
113 return B_NO_MEMORY;
115 BPackageWriterParameters defaultParameters;
117 return fImpl->Init(file, keepFile,
118 parameters != NULL ? *parameters : defaultParameters);
122 status_t
123 BPackageWriter::SetInstallPath(const char* installPath)
125 if (fImpl == NULL)
126 return B_NO_INIT;
128 return fImpl->SetInstallPath(installPath);
132 void
133 BPackageWriter::SetCheckLicenses(bool checkLicenses)
135 if (fImpl != NULL)
136 fImpl->SetCheckLicenses(checkLicenses);
140 status_t
141 BPackageWriter::AddEntry(const char* fileName, int fd)
143 if (fImpl == NULL)
144 return B_NO_INIT;
146 return fImpl->AddEntry(fileName, fd);
150 status_t
151 BPackageWriter::Finish()
153 if (fImpl == NULL)
154 return B_NO_INIT;
156 return fImpl->Finish();
160 status_t
161 BPackageWriter::Recompress(BPositionIO* inputFile)
163 if (fImpl == NULL)
164 return B_NO_INIT;
166 return fImpl->Recompress(inputFile);
170 } // namespace BHPKG
172 } // namespace BPackageKit