xref: /haiku/src/kits/package/hpkg/RepositoryWriter.cpp (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
1 /*
2  * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <package/hpkg/RepositoryWriter.h>
8 
9 #include <new>
10 
11 #include <package/hpkg/RepositoryWriterImpl.h>
12 #include <package/RepositoryInfo.h>
13 
14 
15 namespace BPackageKit {
16 
17 namespace BHPKG {
18 
19 
20 BRepositoryWriter::BRepositoryWriter(BRepositoryWriterListener* listener,
21 	BRepositoryInfo* repositoryInfo)
22 	:
23 	fImpl(new (std::nothrow) RepositoryWriterImpl(listener, repositoryInfo))
24 {
25 }
26 
27 
28 BRepositoryWriter::~BRepositoryWriter()
29 {
30 	delete fImpl;
31 }
32 
33 
34 status_t
35 BRepositoryWriter::Init(const char* fileName)
36 {
37 	if (fImpl == NULL)
38 		return B_NO_MEMORY;
39 
40 	return fImpl->Init(fileName);
41 }
42 
43 
44 status_t
45 BRepositoryWriter::AddPackage(const BEntry& packageEntry)
46 {
47 	if (fImpl == NULL)
48 		return B_NO_INIT;
49 
50 	return fImpl->AddPackage(packageEntry);
51 }
52 
53 
54 status_t
55 BRepositoryWriter::AddPackageInfo(const BPackageInfo& packageInfo)
56 {
57 	if (fImpl == NULL)
58 		return B_NO_INIT;
59 
60 	return fImpl->AddPackageInfo(packageInfo);
61 }
62 
63 
64 status_t
65 BRepositoryWriter::Finish()
66 {
67 	if (fImpl == NULL)
68 		return B_NO_INIT;
69 
70 	return fImpl->Finish();
71 }
72 
73 
74 }	// namespace BHPKG
75 
76 }	// namespace BPackageKit
77