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