haiku/headers/os/package/hpkg/v1/PackageEntry.h
Ingo Weinhold 7575abbca2 Clone read support functionality for HPKG format version 1
It uses sub-namespace BPackage::BHPKG::V1. Unlike the one for the
current format version, the V1 version of BPackageInfoContentHandler
lives in BHPKG(::V1) sub-namespace and is private.
2013-05-25 01:12:22 +02:00

99 lines
2.3 KiB
C++

/*
* Copyright 2009,2011, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _PACKAGE__HPKG__V1__PACKAGE_ENTRY_H_
#define _PACKAGE__HPKG__V1__PACKAGE_ENTRY_H_
#include <sys/stat.h>
#include <package/hpkg/v1/PackageData.h>
namespace BPackageKit {
namespace BHPKG {
namespace V1 {
class BPackageEntry {
public:
BPackageEntry(BPackageEntry* parent,
const char* name);
const BPackageEntry* Parent() const { return fParent; }
const char* Name() const { return fName; }
void* UserToken() const { return fUserToken; }
mode_t Mode() const { return fMode; }
const timespec& AccessTime() const
{ return fAccessTime; }
const timespec& ModifiedTime() const
{ return fModifiedTime; }
const timespec& CreationTime() const
{ return fCreationTime; }
BPackageData& Data() { return fData; }
const char* SymlinkPath() const { return fSymlinkPath; }
void SetUserToken(void* token)
{ fUserToken = token; }
void SetType(uint32 type);
void SetPermissions(uint32 permissions);
void SetAccessTime(uint32 seconds)
{ fAccessTime.tv_sec = seconds; }
void SetAccessTimeNanos(uint32 nanos)
{ fAccessTime.tv_nsec = nanos; }
void SetModifiedTime(uint32 seconds)
{ fModifiedTime.tv_sec = seconds; }
void SetModifiedTimeNanos(uint32 nanos)
{ fModifiedTime.tv_nsec = nanos; }
void SetCreationTime(uint32 seconds)
{ fCreationTime.tv_sec = seconds; }
void SetCreationTimeNanos(uint32 nanos)
{ fCreationTime.tv_nsec = nanos; }
void SetSymlinkPath(const char* path)
{ fSymlinkPath = path; }
private:
BPackageEntry* fParent;
const char* fName;
void* fUserToken;
mode_t fMode;
timespec fAccessTime;
timespec fModifiedTime;
timespec fCreationTime;
BPackageData fData;
const char* fSymlinkPath;
};
inline void
BPackageEntry::SetType(uint32 type)
{
fMode = (fMode & ~(uint32)S_IFMT) | (type & S_IFMT);
}
inline void
BPackageEntry::SetPermissions(uint32 permissions)
{
fMode = (fMode & ~(uint32)ALLPERMS) | (permissions & ALLPERMS);
}
} // namespace V1
} // namespace BHPKG
} // namespace BPackageKit
#endif // _PACKAGE__HPKG__V1__PACKAGE_ENTRY_H_