BPackageInfo: Add fileName property

The property is archived and unarchived, but otherwise not yet stored.
If not set, FileName() returns CanonicalFileName(). Can be used for
packages like haiku.hpkg etc. that don't have a properly qualified file
name (yet).
This commit is contained in:
Ingo Weinhold 2013-08-29 23:07:11 +02:00
parent 08fb013f56
commit 6692db5c1c
2 changed files with 25 additions and 3 deletions

View File

@ -70,6 +70,9 @@ public:
const BString& BasePackage() const;
const BString& Checksum() const;
const BString& InstallPath() const;
BString FileName() const;
// the explicitly set file name, if any, or
// CanonicalFileName() otherwise
uint32 Flags() const;
@ -116,6 +119,7 @@ public:
void SetBasePackage(const BString& basePackage);
void SetChecksum(const BString& checksum);
void SetInstallPath(const BString& installPath);
void SetFileName(const BString& fileName);
void SetFlags(uint32 flags);
@ -299,6 +303,7 @@ private:
BString fChecksum;
BString fInstallPath;
BString fFileName;
};

View File

@ -244,7 +244,8 @@ BPackageInfo::BPackageInfo(BMessage* archive, status_t* _error)
&& (error = _ExtractStringList(archive, "replaces", fReplacesList))
== B_OK
&& (error = archive->FindString("checksum", &fChecksum)) == B_OK
&& (error = archive->FindString("install-path", &fInstallPath)) == B_OK) {
&& (error = archive->FindString("install-path", &fInstallPath)) == B_OK
&& (error = archive->FindString("file-name", &fFileName)) == B_OK) {
if (architecture >= 0
&& architecture <= B_PACKAGE_ARCHITECTURE_ENUM_COUNT) {
fArchitecture = (BPackageArchitecture)architecture;
@ -445,6 +446,13 @@ BPackageInfo::InstallPath() const
}
BString
BPackageInfo::FileName() const
{
return fFileName.IsEmpty() ? CanonicalFileName() : fFileName;
}
uint32
BPackageInfo::Flags() const
{
@ -660,6 +668,13 @@ BPackageInfo::SetInstallPath(const BString& installPath)
}
void
BPackageInfo::SetFileName(const BString& fileName)
{
fFileName = fileName;
}
void
BPackageInfo::SetVersion(const BPackageVersion& version)
{
@ -947,6 +962,7 @@ BPackageInfo::Clear()
fBasePackage.Truncate(0);
fChecksum.Truncate(0);
fInstallPath.Truncate(0);
fFileName.Truncate(0);
fFlags = 0;
fArchitecture = B_PACKAGE_ARCHITECTURE_ENUM_COUNT;
fVersion.Clear();
@ -1009,7 +1025,8 @@ BPackageInfo::Archive(BMessage* archive, bool deep) const
fFreshensList)) != B_OK
|| (error = archive->AddStrings("replaces", fReplacesList)) != B_OK
|| (error = archive->AddString("checksum", fChecksum)) != B_OK
|| (error = archive->AddString("install-path", fInstallPath)) != B_OK) {
|| (error = archive->AddString("install-path", fInstallPath)) != B_OK
|| (error = archive->AddString("file-name", fFileName)) != B_OK) {
return error;
}
@ -1057,7 +1074,7 @@ BPackageInfo::GetConfigString(BString& _string) const
.WriteFlags("flags", fFlags)
.Write("checksum", fChecksum)
.GetString(_string);
// Note: fInstallPath can not be specified via .PackageInfo.
// Note: fInstallPath and fFileName can not be specified via .PackageInfo.
}