15fb1c6ffSOliver Tappe /* 2*95d84e41SOliver Tappe * Copyright 2009,2011, Haiku, Inc. 35fb1c6ffSOliver Tappe * Distributed under the terms of the MIT License. 45fb1c6ffSOliver Tappe */ 55fb1c6ffSOliver Tappe #ifndef _PACKAGE__HPKG__PACKAGE_ENTRY_H_ 65fb1c6ffSOliver Tappe #define _PACKAGE__HPKG__PACKAGE_ENTRY_H_ 75fb1c6ffSOliver Tappe 85fb1c6ffSOliver Tappe 95fb1c6ffSOliver Tappe #include <sys/stat.h> 105fb1c6ffSOliver Tappe 115fb1c6ffSOliver Tappe #include <package/hpkg/PackageData.h> 125fb1c6ffSOliver Tappe 135fb1c6ffSOliver Tappe 145fb1c6ffSOliver Tappe namespace BPackageKit { 155fb1c6ffSOliver Tappe 165fb1c6ffSOliver Tappe namespace BHPKG { 175fb1c6ffSOliver Tappe 185fb1c6ffSOliver Tappe 195fb1c6ffSOliver Tappe class BPackageEntry { 205fb1c6ffSOliver Tappe public: 215fb1c6ffSOliver Tappe BPackageEntry(BPackageEntry* parent, 225fb1c6ffSOliver Tappe const char* name); 235fb1c6ffSOliver Tappe 245fb1c6ffSOliver Tappe const BPackageEntry* Parent() const { return fParent; } 255fb1c6ffSOliver Tappe const char* Name() const { return fName; } 265fb1c6ffSOliver Tappe void* UserToken() const { return fUserToken; } 275fb1c6ffSOliver Tappe 285fb1c6ffSOliver Tappe mode_t Mode() const { return fMode; } 295fb1c6ffSOliver Tappe 305fb1c6ffSOliver Tappe const timespec& AccessTime() const 315fb1c6ffSOliver Tappe { return fAccessTime; } 325fb1c6ffSOliver Tappe const timespec& ModifiedTime() const 335fb1c6ffSOliver Tappe { return fModifiedTime; } 345fb1c6ffSOliver Tappe const timespec& CreationTime() const 355fb1c6ffSOliver Tappe { return fCreationTime; } 365fb1c6ffSOliver Tappe 375fb1c6ffSOliver Tappe BPackageData& Data() { return fData; } 385fb1c6ffSOliver Tappe 395fb1c6ffSOliver Tappe const char* SymlinkPath() const { return fSymlinkPath; } 405fb1c6ffSOliver Tappe 415fb1c6ffSOliver Tappe void SetUserToken(void* token) 425fb1c6ffSOliver Tappe { fUserToken = token; } 435fb1c6ffSOliver Tappe 445fb1c6ffSOliver Tappe void SetType(uint32 type); 455fb1c6ffSOliver Tappe void SetPermissions(uint32 permissions); 465fb1c6ffSOliver Tappe 475fb1c6ffSOliver Tappe void SetAccessTime(uint32 seconds) 485fb1c6ffSOliver Tappe { fAccessTime.tv_sec = seconds; } 495fb1c6ffSOliver Tappe void SetAccessTimeNanos(uint32 nanos) 505fb1c6ffSOliver Tappe { fAccessTime.tv_nsec = nanos; } 515fb1c6ffSOliver Tappe void SetModifiedTime(uint32 seconds) 525fb1c6ffSOliver Tappe { fModifiedTime.tv_sec = seconds; } 535fb1c6ffSOliver Tappe void SetModifiedTimeNanos(uint32 nanos) 545fb1c6ffSOliver Tappe { fModifiedTime.tv_nsec = nanos; } 555fb1c6ffSOliver Tappe void SetCreationTime(uint32 seconds) 565fb1c6ffSOliver Tappe { fCreationTime.tv_sec = seconds; } 575fb1c6ffSOliver Tappe void SetCreationTimeNanos(uint32 nanos) 585fb1c6ffSOliver Tappe { fCreationTime.tv_nsec = nanos; } 595fb1c6ffSOliver Tappe 605fb1c6ffSOliver Tappe void SetSymlinkPath(const char* path) 615fb1c6ffSOliver Tappe { fSymlinkPath = path; } 625fb1c6ffSOliver Tappe private: 635fb1c6ffSOliver Tappe BPackageEntry* fParent; 645fb1c6ffSOliver Tappe const char* fName; 655fb1c6ffSOliver Tappe void* fUserToken; 665fb1c6ffSOliver Tappe mode_t fMode; 675fb1c6ffSOliver Tappe timespec fAccessTime; 685fb1c6ffSOliver Tappe timespec fModifiedTime; 695fb1c6ffSOliver Tappe timespec fCreationTime; 705fb1c6ffSOliver Tappe BPackageData fData; 715fb1c6ffSOliver Tappe const char* fSymlinkPath; 725fb1c6ffSOliver Tappe }; 735fb1c6ffSOliver Tappe 745fb1c6ffSOliver Tappe 755fb1c6ffSOliver Tappe inline void 765fb1c6ffSOliver Tappe BPackageEntry::SetType(uint32 type) 775fb1c6ffSOliver Tappe { 785fb1c6ffSOliver Tappe fMode = (fMode & ~(uint32)S_IFMT) | (type & S_IFMT); 795fb1c6ffSOliver Tappe } 805fb1c6ffSOliver Tappe 815fb1c6ffSOliver Tappe 825fb1c6ffSOliver Tappe inline void 835fb1c6ffSOliver Tappe BPackageEntry::SetPermissions(uint32 permissions) 845fb1c6ffSOliver Tappe { 855fb1c6ffSOliver Tappe fMode = (fMode & ~(uint32)ALLPERMS) | (permissions & ALLPERMS); 865fb1c6ffSOliver Tappe } 875fb1c6ffSOliver Tappe 885fb1c6ffSOliver Tappe 895fb1c6ffSOliver Tappe } // namespace BHPKG 905fb1c6ffSOliver Tappe 915fb1c6ffSOliver Tappe } // namespace BPackageKit 925fb1c6ffSOliver Tappe 935fb1c6ffSOliver Tappe 945fb1c6ffSOliver Tappe #endif // _PACKAGE__HPKG__PACKAGE_ENTRY_H_ 95