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 26 const BPackageEntry* Parent() const { return fParent; } 27 const char* Name() const { return fName; } 28 void* UserToken() const { return fUserToken; } 29 30 mode_t Mode() const { return fMode; } 31 32 const timespec& AccessTime() const 33 { return fAccessTime; } 34 const timespec& ModifiedTime() const 35 { return fModifiedTime; } 36 const timespec& CreationTime() const 37 { return fCreationTime; } 38 39 BPackageData& Data() { return fData; } 40 41 const char* SymlinkPath() const { return fSymlinkPath; } 42 43 void SetUserToken(void* token) 44 { fUserToken = token; } 45 46 void SetType(uint32 type); 47 void SetPermissions(uint32 permissions); 48 49 void SetAccessTime(uint32 seconds) 50 { fAccessTime.tv_sec = seconds; } 51 void SetAccessTimeNanos(uint32 nanos) 52 { fAccessTime.tv_nsec = nanos; } 53 void SetModifiedTime(uint32 seconds) 54 { fModifiedTime.tv_sec = seconds; } 55 void SetModifiedTimeNanos(uint32 nanos) 56 { fModifiedTime.tv_nsec = nanos; } 57 void SetCreationTime(uint32 seconds) 58 { fCreationTime.tv_sec = seconds; } 59 void SetCreationTimeNanos(uint32 nanos) 60 { fCreationTime.tv_nsec = nanos; } 61 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 78 BPackageEntry::SetType(uint32 type) 79 { 80 fMode = (fMode & ~(uint32)S_IFMT) | (type & S_IFMT); 81 } 82 83 84 inline void 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