xref: /haiku/headers/os/package/hpkg/v1/PackageEntry.h (revision 9f81ca838ce7b92b5689e57d3f86765db4705a7b)
1 /*
2  * Copyright 2009,2011, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__HPKG__V1__PACKAGE_ENTRY_H_
6 #define _PACKAGE__HPKG__V1__PACKAGE_ENTRY_H_
7 
8 
9 #include <sys/stat.h>
10 
11 #include <package/hpkg/v1/PackageData.h>
12 
13 
14 namespace BPackageKit {
15 
16 namespace BHPKG {
17 
18 namespace V1 {
19 
20 
21 class BPackageEntry {
22 public:
23 								BPackageEntry(BPackageEntry* parent,
24 									const char* name);
25 
Parent()26 			const BPackageEntry*	Parent() const	{ return fParent; }
Name()27 			const char*			Name() const		{ return fName; }
UserToken()28 			void*				UserToken() const	{ return fUserToken; }
29 
Mode()30 			mode_t				Mode() const		{ return fMode; }
31 
AccessTime()32 			const timespec&		AccessTime() const
33 									{ return fAccessTime; }
ModifiedTime()34 			const timespec&		ModifiedTime() const
35 									{ return fModifiedTime; }
CreationTime()36 			const timespec&		CreationTime() const
37 									{ return fCreationTime; }
38 
Data()39 			BPackageData&		Data()	{ return fData; }
40 
SymlinkPath()41 			const char*			SymlinkPath() const	{ return fSymlinkPath; }
42 
SetUserToken(void * token)43 			void				SetUserToken(void* token)
44 									{ fUserToken = token; }
45 
46 			void				SetType(uint32 type);
47 			void				SetPermissions(uint32 permissions);
48 
SetAccessTime(uint32 seconds)49 			void				SetAccessTime(uint32 seconds)
50 									{ fAccessTime.tv_sec = seconds; }
SetAccessTimeNanos(uint32 nanos)51 			void				SetAccessTimeNanos(uint32 nanos)
52 									{ fAccessTime.tv_nsec = nanos; }
SetModifiedTime(uint32 seconds)53 			void				SetModifiedTime(uint32 seconds)
54 									{ fModifiedTime.tv_sec = seconds; }
SetModifiedTimeNanos(uint32 nanos)55 			void				SetModifiedTimeNanos(uint32 nanos)
56 									{ fModifiedTime.tv_nsec = nanos; }
SetCreationTime(uint32 seconds)57 			void				SetCreationTime(uint32 seconds)
58 									{ fCreationTime.tv_sec = seconds; }
SetCreationTimeNanos(uint32 nanos)59 			void				SetCreationTimeNanos(uint32 nanos)
60 									{ fCreationTime.tv_nsec = nanos; }
61 
SetSymlinkPath(const char * path)62 			void				SetSymlinkPath(const char* path)
63 									{ fSymlinkPath = path; }
64 private:
65 			BPackageEntry*		fParent;
66 			const char*			fName;
67 			void*				fUserToken;
68 			mode_t				fMode;
69 			timespec			fAccessTime;
70 			timespec			fModifiedTime;
71 			timespec			fCreationTime;
72 			BPackageData		fData;
73 			const char*			fSymlinkPath;
74 };
75 
76 
77 inline void
SetType(uint32 type)78 BPackageEntry::SetType(uint32 type)
79 {
80 	fMode = (fMode & ~(uint32)S_IFMT) | (type & S_IFMT);
81 }
82 
83 
84 inline void
SetPermissions(uint32 permissions)85 BPackageEntry::SetPermissions(uint32 permissions)
86 {
87 	fMode = (fMode & ~(uint32)ALLPERMS) | (permissions & ALLPERMS);
88 }
89 
90 
91 }	// namespace V1
92 
93 }	// namespace BHPKG
94 
95 }	// namespace BPackageKit
96 
97 
98 #endif	// _PACKAGE__HPKG__V1__PACKAGE_ENTRY_H_
99