xref: /haiku/src/kits/package/GlobalWritableFileInfo.cpp (revision 29f8805f6c70f1c819eb58ac2220647d8e40d6e7)
1 /*
2  * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <package/GlobalWritableFileInfo.h>
8 
9 #include <package/hpkg/PackageInfoAttributeValue.h>
10 
11 
12 namespace BPackageKit {
13 
14 
15 BGlobalWritableFileInfo::BGlobalWritableFileInfo()
16 	:
17 	fPath(),
18 	fUpdateType(B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT)
19 {
20 }
21 
22 
23 BGlobalWritableFileInfo::BGlobalWritableFileInfo(
24 	const BHPKG::BGlobalWritableFileInfoData& infoData)
25 	:
26 	fPath(infoData.path),
27 	fUpdateType(infoData.updateType),
28 	fIsDirectory(infoData.isDirectory)
29 {
30 }
31 
32 
33 BGlobalWritableFileInfo::BGlobalWritableFileInfo(const BString& path,
34 	BWritableFileUpdateType updateType, bool isDirectory)
35 	:
36 	fPath(path),
37 	fUpdateType(updateType),
38 	fIsDirectory(isDirectory)
39 {
40 }
41 
42 
43 BGlobalWritableFileInfo::~BGlobalWritableFileInfo()
44 {
45 }
46 
47 
48 status_t
49 BGlobalWritableFileInfo::InitCheck() const
50 {
51 	if (fPath.IsEmpty())
52 		return B_NO_INIT;
53 	return B_OK;
54 }
55 
56 
57 const BString&
58 BGlobalWritableFileInfo::Path() const
59 {
60 	return fPath;
61 }
62 
63 
64 bool
65 BGlobalWritableFileInfo::IsIncluded() const
66 {
67 	return fUpdateType != B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT;
68 }
69 
70 
71 BWritableFileUpdateType
72 BGlobalWritableFileInfo::UpdateType() const
73 {
74 	return fUpdateType;
75 }
76 
77 
78 bool
79 BGlobalWritableFileInfo::IsDirectory() const
80 {
81 	return fIsDirectory;
82 }
83 
84 
85 void
86 BGlobalWritableFileInfo::SetTo(const BString& path,
87 	BWritableFileUpdateType updateType, bool isDirectory)
88 {
89 	fPath = path;
90 	fUpdateType = updateType;
91 	fIsDirectory = isDirectory;
92 }
93 
94 
95 }	// namespace BPackageKit
96