diff --git a/headers/build/os/package/GlobalSettingsFileInfo.h b/headers/build/os/package/GlobalSettingsFileInfo.h deleted file mode 100644 index 6e17a15d21..0000000000 --- a/headers/build/os/package/GlobalSettingsFileInfo.h +++ /dev/null @@ -1 +0,0 @@ -#include <../os/package/GlobalSettingsFileInfo.h> diff --git a/headers/build/os/package/GlobalWritableFileInfo.h b/headers/build/os/package/GlobalWritableFileInfo.h new file mode 100644 index 0000000000..73bdbceec6 --- /dev/null +++ b/headers/build/os/package/GlobalWritableFileInfo.h @@ -0,0 +1 @@ +#include <../os/package/GlobalWritableFileInfo.h> diff --git a/headers/build/os/package/SettingsFileUpdateType.h b/headers/build/os/package/SettingsFileUpdateType.h deleted file mode 100644 index ab52190853..0000000000 --- a/headers/build/os/package/SettingsFileUpdateType.h +++ /dev/null @@ -1 +0,0 @@ -#include <../os/package/SettingsFileUpdateType.h> diff --git a/headers/build/os/package/WritableFileUpdateType.h b/headers/build/os/package/WritableFileUpdateType.h new file mode 100644 index 0000000000..d35b6c4673 --- /dev/null +++ b/headers/build/os/package/WritableFileUpdateType.h @@ -0,0 +1 @@ +#include <../os/package/WritableFileUpdateType.h> diff --git a/headers/os/package/GlobalSettingsFileInfo.h b/headers/os/package/GlobalSettingsFileInfo.h deleted file mode 100644 index 88ff8b9877..0000000000 --- a/headers/os/package/GlobalSettingsFileInfo.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013, Haiku, Inc. - * Distributed under the terms of the MIT License. - */ -#ifndef _PACKAGE__GLOBAL_SETTINGS_FILE_INFO_H_ -#define _PACKAGE__GLOBAL_SETTINGS_FILE_INFO_H_ - - -#include -#include - - -namespace BPackageKit { - - -namespace BHPKG { - struct BGlobalSettingsFileInfoData; -} - - -class BGlobalSettingsFileInfo { -public: - BGlobalSettingsFileInfo(); - BGlobalSettingsFileInfo( - const BHPKG::BGlobalSettingsFileInfoData& - infoData); - BGlobalSettingsFileInfo(const BString& path, - BSettingsFileUpdateType updateType); - ~BGlobalSettingsFileInfo(); - - status_t InitCheck() const; - - const BString& Path() const; - bool IsIncluded() const; - BSettingsFileUpdateType UpdateType() const; - - void SetTo(const BString& path, - BSettingsFileUpdateType updateType); - -private: - BString fPath; - BSettingsFileUpdateType fUpdateType; -}; - - -} // namespace BPackageKit - - -#endif // _PACKAGE__GLOBAL_SETTINGS_FILE_INFO_H_ diff --git a/headers/os/package/GlobalWritableFileInfo.h b/headers/os/package/GlobalWritableFileInfo.h new file mode 100644 index 0000000000..07553174c7 --- /dev/null +++ b/headers/os/package/GlobalWritableFileInfo.h @@ -0,0 +1,53 @@ +/* + * Copyright 2013, Haiku, Inc. + * Distributed under the terms of the MIT License. + */ +#ifndef _PACKAGE__GLOBAL_WRITABLE_FILE_INFO_H_ +#define _PACKAGE__GLOBAL_WRITABLE_FILE_INFO_H_ + + +#include +#include + + +namespace BPackageKit { + + +namespace BHPKG { + struct BGlobalWritableFileInfoData; +} + + +class BGlobalWritableFileInfo { +public: + BGlobalWritableFileInfo(); + BGlobalWritableFileInfo( + const BHPKG::BGlobalWritableFileInfoData& + infoData); + BGlobalWritableFileInfo(const BString& path, + BWritableFileUpdateType updateType, + bool isDirectory); + ~BGlobalWritableFileInfo(); + + status_t InitCheck() const; + + const BString& Path() const; + bool IsIncluded() const; + BWritableFileUpdateType UpdateType() const; + bool IsDirectory() const; + + void SetTo(const BString& path, + BWritableFileUpdateType updateType, + bool isDirectory); + +private: + BString fPath; + BWritableFileUpdateType fUpdateType; + bool fIsDirectory; +}; + + +} // namespace BPackageKit + + +#endif // _PACKAGE__GLOBAL_WRITABLE_FILE_INFO_H_ diff --git a/headers/os/package/PackageInfo.h b/headers/os/package/PackageInfo.h index 68d5e21067..4d691df6a0 100644 --- a/headers/os/package/PackageInfo.h +++ b/headers/os/package/PackageInfo.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -82,8 +82,8 @@ public: const BStringList& URLList() const; const BStringList& SourceURLList() const; - const BObjectList& - GlobalSettingsFileInfos() const; + const BObjectList& + GlobalWritableFileInfos() const; const BObjectList& UserSettingsFileInfos() const; @@ -133,9 +133,9 @@ public: void ClearSourceURLList(); status_t AddSourceURL(const BString& url); - void ClearGlobalSettingsFileInfos(); - status_t AddGlobalSettingsFileInfo( - const BGlobalSettingsFileInfo& info); + void ClearGlobalWritableFileInfos(); + status_t AddGlobalWritableFileInfo( + const BGlobalWritableFileInfo& info); void ClearUserSettingsFileInfos(); status_t AddUserSettingsFileInfo( @@ -193,7 +193,7 @@ public: public: static const char* const kElementNames[]; static const char* const kArchitectureNames[]; - static const char* const kSettingsFileUpdateTypes[]; + static const char* const kWritableFileUpdateTypes[]; private: class Parser; @@ -206,8 +206,8 @@ private: typedef BObjectList ResolvableExpressionList; - typedef BObjectList - GlobalSettingsFileInfoList; + typedef BObjectList + GlobalWritableFileInfoList; typedef BObjectList UserSettingsFileInfoList; @@ -227,9 +227,9 @@ private: const char* field, const ResolvableExpressionList& expressions); - static status_t _AddGlobalSettingsFileInfos(BMessage* archive, + static status_t _AddGlobalWritableFileInfos(BMessage* archive, const char* field, - const GlobalSettingsFileInfoList& + const GlobalWritableFileInfoList& infos); static status_t _AddUserSettingsFileInfos(BMessage* archive, const char* field, @@ -249,9 +249,9 @@ private: static status_t _ExtractResolvableExpressions(BMessage* archive, const char* field, ResolvableExpressionList& _expressions); - static status_t _ExtractGlobalSettingsFileInfos( + static status_t _ExtractGlobalWritableFileInfos( BMessage* archive, const char* field, - GlobalSettingsFileInfoList& _infos); + GlobalWritableFileInfoList& _infos); static status_t _ExtractUserSettingsFileInfos( BMessage* archive, const char* field, UserSettingsFileInfoList& _infos); @@ -277,7 +277,7 @@ private: BStringList fURLList; BStringList fSourceURLList; - BObjectList fGlobalSettingsFileInfos; + BObjectList fGlobalWritableFileInfos; BObjectList fUserSettingsFileInfos; UserList fUsers; diff --git a/headers/os/package/PackageInfoAttributes.h b/headers/os/package/PackageInfoAttributes.h index 71e186b888..9f4fda47e0 100644 --- a/headers/os/package/PackageInfoAttributes.h +++ b/headers/os/package/PackageInfoAttributes.h @@ -41,8 +41,8 @@ enum BPackageInfoAttributeID { B_PACKAGE_INFO_INSTALL_PATH, // package install path; only for package // building B_PACKAGE_INFO_BASE_PACKAGE, // name of the base package for this package - B_PACKAGE_INFO_GLOBAL_SETTINGS_FILES, - // list of global settings file infos + B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES, + // list of global writable file infos B_PACKAGE_INFO_USER_SETTINGS_FILES, // list of user settings file infos B_PACKAGE_INFO_USERS, diff --git a/headers/os/package/SettingsFileUpdateType.h b/headers/os/package/SettingsFileUpdateType.h deleted file mode 100644 index 2ddb6f2bbb..0000000000 --- a/headers/os/package/SettingsFileUpdateType.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2013, Haiku, Inc. - * Distributed under the terms of the MIT License. - */ -#ifndef _PACKAGE__SETTINGS_FILE_UPDATE_TYPE_H_ -#define _PACKAGE__SETTINGS_FILE_UPDATE_TYPE_H_ - - -#include - - -namespace BPackageKit { - - -// global settings file update types -- specifies behavior in case the previous -// version of a settings file provided by a package has been changed by the -// user. -enum BSettingsFileUpdateType { - B_SETTINGS_FILE_UPDATE_TYPE_KEEP_OLD = 0, - // the old settings file can be kept - B_SETTINGS_FILE_UPDATE_TYPE_MANUAL = 1, - // the old settings file needs to be updated manually - B_SETTINGS_FILE_UPDATE_TYPE_AUTO_MERGE = 2, - // try a three-way merge - - B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT, - - B_SETTINGS_FILE_UPDATE_TYPE_DEFAULT = B_SETTINGS_FILE_UPDATE_TYPE_KEEP_OLD -}; - - -} // namespace BPackageKit - - -#endif // _PACKAGE__SETTINGS_FILE_UPDATE_TYPE_H_ diff --git a/headers/os/package/UserSettingsFileInfo.h b/headers/os/package/UserSettingsFileInfo.h index f92573258c..401bafb5dd 100644 --- a/headers/os/package/UserSettingsFileInfo.h +++ b/headers/os/package/UserSettingsFileInfo.h @@ -25,19 +25,25 @@ public: infoData); BUserSettingsFileInfo(const BString& path, const BString& templatePath = BString()); + BUserSettingsFileInfo(const BString& path, + bool isDirectory); ~BUserSettingsFileInfo(); status_t InitCheck() const; const BString& Path() const; const BString& TemplatePath() const; + bool IsDirectory() const; void SetTo(const BString& path, const BString& templatePath = BString()); + void SetTo(const BString& path, + bool isDirectory); private: BString fPath; BString fTemplatePath; + bool fIsDirectory; }; diff --git a/headers/os/package/WritableFileUpdateType.h b/headers/os/package/WritableFileUpdateType.h new file mode 100644 index 0000000000..3a8970c8c4 --- /dev/null +++ b/headers/os/package/WritableFileUpdateType.h @@ -0,0 +1,35 @@ +/* + * Copyright 2013, Haiku, Inc. + * Distributed under the terms of the MIT License. + */ +#ifndef _PACKAGE__WRITABLE_FILE_UPDATE_TYPE_H_ +#define _PACKAGE__WRITABLE_FILE_UPDATE_TYPE_H_ + + +#include + + +namespace BPackageKit { + + +// global writable file update types -- specifies behavior in case the previous +// version of a writable file provided by a package has been changed by the +// user. +enum BWritableFileUpdateType { + B_WRITABLE_FILE_UPDATE_TYPE_KEEP_OLD = 0, + // the old writable file can be kept + B_WRITABLE_FILE_UPDATE_TYPE_MANUAL = 1, + // the old writable file needs to be updated manually + B_WRITABLE_FILE_UPDATE_TYPE_AUTO_MERGE = 2, + // try a three-way merge + + B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT, + + B_WRITABLE_FILE_UPDATE_TYPE_DEFAULT = B_WRITABLE_FILE_UPDATE_TYPE_KEEP_OLD +}; + + +} // namespace BPackageKit + + +#endif // _PACKAGE__WRITABLE_FILE_UPDATE_TYPE_H_ diff --git a/headers/os/package/hpkg/PackageAttributes.h b/headers/os/package/hpkg/PackageAttributes.h index 022c93f75c..ba4fc3496f 100644 --- a/headers/os/package/hpkg/PackageAttributes.h +++ b/headers/os/package/hpkg/PackageAttributes.h @@ -62,12 +62,12 @@ B_DEFINE_HPKG_ATTRIBUTE(40, STRING, "package:install-path", PACKAGE_INSTALL_PATH) B_DEFINE_HPKG_ATTRIBUTE(41, STRING, "package:base-package", PACKAGE_BASE_PACKAGE) -B_DEFINE_HPKG_ATTRIBUTE(42, STRING, "package:global-settings-file", - PACKAGE_GLOBAL_SETTINGS_FILE) +B_DEFINE_HPKG_ATTRIBUTE(42, STRING, "package:global-writable-file", + PACKAGE_GLOBAL_WRITABLE_FILE) B_DEFINE_HPKG_ATTRIBUTE(43, STRING, "package:user-settings-file", PACKAGE_USER_SETTINGS_FILE) -B_DEFINE_HPKG_ATTRIBUTE(44, UINT, "package:settings-file-update-type", - PACKAGE_SETTINGS_FILE_UPDATE_TYPE) +B_DEFINE_HPKG_ATTRIBUTE(44, UINT, "package:writable-file-update-type", + PACKAGE_WRITABLE_FILE_UPDATE_TYPE) B_DEFINE_HPKG_ATTRIBUTE(45, STRING, "package:settings-file-template", PACKAGE_SETTINGS_FILE_TEMPLATE) B_DEFINE_HPKG_ATTRIBUTE(46, STRING, "package:user", PACKAGE_USER) @@ -79,3 +79,5 @@ B_DEFINE_HPKG_ATTRIBUTE(50, STRING, "package:user.group", PACKAGE_USER_GROUP) B_DEFINE_HPKG_ATTRIBUTE(51, STRING, "package:group", PACKAGE_GROUP) B_DEFINE_HPKG_ATTRIBUTE(52, STRING, "package:post-install-script", PACKAGE_POST_INSTALL_SCRIPT) +B_DEFINE_HPKG_ATTRIBUTE(53, UINT, "package:is-writable-directory", + PACKAGE_IS_WRITABLE_DIRECTORY) diff --git a/headers/os/package/hpkg/PackageInfoAttributeValue.h b/headers/os/package/hpkg/PackageInfoAttributeValue.h index e0b5db67b3..6e4a367d18 100644 --- a/headers/os/package/hpkg/PackageInfoAttributeValue.h +++ b/headers/os/package/hpkg/PackageInfoAttributeValue.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include namespace BPackageKit { @@ -47,15 +47,17 @@ struct BPackageResolvableExpressionData { }; -struct BGlobalSettingsFileInfoData { +struct BGlobalWritableFileInfoData { const char* path; - BSettingsFileUpdateType updateType; + BWritableFileUpdateType updateType; + bool isDirectory; }; struct BUserSettingsFileInfoData { const char* path; const char* templatePath; + bool isDirectory; }; @@ -76,7 +78,7 @@ struct BPackageInfoAttributeValue { BPackageVersionData version; BPackageResolvableData resolvable; BPackageResolvableExpressionData resolvableExpression; - BGlobalSettingsFileInfoData globalSettingsFileInfo; + BGlobalWritableFileInfoData globalWritableFileInfo; BUserSettingsFileInfoData userSettingsFileInfo; BUserData user; }; diff --git a/headers/private/package/hpkg/ReaderImplBase.h b/headers/private/package/hpkg/ReaderImplBase.h index c5c9694b5e..99bb2a3146 100644 --- a/headers/private/package/hpkg/ReaderImplBase.h +++ b/headers/private/package/hpkg/ReaderImplBase.h @@ -102,7 +102,7 @@ protected: class PackageVersionAttributeHandler; class PackageResolvableAttributeHandler; class PackageResolvableExpressionAttributeHandler; - class GlobalSettingsFileInfoAttributeHandler; + class GlobalWritableFileInfoAttributeHandler; class UserSettingsFileInfoAttributeHandler; class UserAttributeHandler; class PackageAttributeHandler; @@ -318,10 +318,10 @@ public: }; -class ReaderImplBase::GlobalSettingsFileInfoAttributeHandler +class ReaderImplBase::GlobalWritableFileInfoAttributeHandler : public PackageInfoAttributeHandlerBase { public: - GlobalSettingsFileInfoAttributeHandler( + GlobalWritableFileInfoAttributeHandler( BPackageInfoAttributeValue& packageInfoValue); diff --git a/src/bin/package/command_list.cpp b/src/bin/package/command_list.cpp index bc35f7a52b..dee04523ae 100644 --- a/src/bin/package/command_list.cpp +++ b/src/bin/package/command_list.cpp @@ -288,14 +288,16 @@ struct PackageContentListHandler : VersionPolicy::PackageContentHandler { printf("\treplaces: %s\n", value.string); break; - case B_PACKAGE_INFO_GLOBAL_SETTINGS_FILES: - printf("\tglobal settings file: %s", - value.globalSettingsFileInfo.path); - if (value.globalSettingsFileInfo.updateType - < B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT) { + case B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES: + printf("\tglobal writable file: %s", + value.globalWritableFileInfo.path); + if (value.globalWritableFileInfo.isDirectory) + printf( " directory"); + if (value.globalWritableFileInfo.updateType + < B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT) { printf(" %s\n", - BPackageInfo::kSettingsFileUpdateTypes[ - value.globalSettingsFileInfo.updateType]); + BPackageInfo::kWritableFileUpdateTypes[ + value.globalWritableFileInfo.updateType]); } else printf("\n"); break; @@ -303,7 +305,9 @@ struct PackageContentListHandler : VersionPolicy::PackageContentHandler { case B_PACKAGE_INFO_USER_SETTINGS_FILES: printf("\tuser settings file: %s", value.userSettingsFileInfo.path); - if (value.userSettingsFileInfo.templatePath != NULL) { + if (value.globalWritableFileInfo.isDirectory) { + printf( " directory\n"); + } else if (value.userSettingsFileInfo.templatePath != NULL) { printf(" template %s\n", value.userSettingsFileInfo.templatePath); } else diff --git a/src/build/libpackage/Jamfile b/src/build/libpackage/Jamfile index e1b530e63b..6c756f9dc9 100644 --- a/src/build/libpackage/Jamfile +++ b/src/build/libpackage/Jamfile @@ -31,7 +31,7 @@ HPKG_SOURCES = DataWriters.cpp ErrorOutput.cpp FDDataReader.cpp - GlobalSettingsFileInfo.cpp + GlobalWritableFileInfo.cpp HPKGDefs.cpp PackageContentHandler.cpp PackageData.cpp diff --git a/src/kits/package/GlobalSettingsFileInfo.cpp b/src/kits/package/GlobalSettingsFileInfo.cpp deleted file mode 100644 index 1cb85c3542..0000000000 --- a/src/kits/package/GlobalSettingsFileInfo.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. - * Distributed under the terms of the MIT License. - */ - - -#include - -#include - - -namespace BPackageKit { - - -BGlobalSettingsFileInfo::BGlobalSettingsFileInfo() - : - fPath(), - fUpdateType(B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT) -{ -} - - -BGlobalSettingsFileInfo::BGlobalSettingsFileInfo( - const BHPKG::BGlobalSettingsFileInfoData& infoData) - : - fPath(infoData.path), - fUpdateType(infoData.updateType) -{ -} - - -BGlobalSettingsFileInfo::BGlobalSettingsFileInfo(const BString& path, - BSettingsFileUpdateType updateType) - : - fPath(path), - fUpdateType(updateType) -{ -} - - -BGlobalSettingsFileInfo::~BGlobalSettingsFileInfo() -{ -} - - -status_t -BGlobalSettingsFileInfo::InitCheck() const -{ - if (fPath.IsEmpty()) - return B_NO_INIT; - return B_OK; -} - - -const BString& -BGlobalSettingsFileInfo::Path() const -{ - return fPath; -} - - -bool -BGlobalSettingsFileInfo::IsIncluded() const -{ - return fUpdateType != B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT; -} - - -BSettingsFileUpdateType -BGlobalSettingsFileInfo::UpdateType() const -{ - return fUpdateType; -} - - -void -BGlobalSettingsFileInfo::SetTo(const BString& path, - BSettingsFileUpdateType updateType) -{ - fPath = path; - fUpdateType = updateType; -} - - -} // namespace BPackageKit diff --git a/src/kits/package/GlobalWritableFileInfo.cpp b/src/kits/package/GlobalWritableFileInfo.cpp new file mode 100644 index 0000000000..b2eff631c2 --- /dev/null +++ b/src/kits/package/GlobalWritableFileInfo.cpp @@ -0,0 +1,95 @@ +/* + * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include + + +namespace BPackageKit { + + +BGlobalWritableFileInfo::BGlobalWritableFileInfo() + : + fPath(), + fUpdateType(B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT) +{ +} + + +BGlobalWritableFileInfo::BGlobalWritableFileInfo( + const BHPKG::BGlobalWritableFileInfoData& infoData) + : + fPath(infoData.path), + fUpdateType(infoData.updateType), + fIsDirectory(infoData.isDirectory) +{ +} + + +BGlobalWritableFileInfo::BGlobalWritableFileInfo(const BString& path, + BWritableFileUpdateType updateType, bool isDirectory) + : + fPath(path), + fUpdateType(updateType), + fIsDirectory(isDirectory) +{ +} + + +BGlobalWritableFileInfo::~BGlobalWritableFileInfo() +{ +} + + +status_t +BGlobalWritableFileInfo::InitCheck() const +{ + if (fPath.IsEmpty()) + return B_NO_INIT; + return B_OK; +} + + +const BString& +BGlobalWritableFileInfo::Path() const +{ + return fPath; +} + + +bool +BGlobalWritableFileInfo::IsIncluded() const +{ + return fUpdateType != B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT; +} + + +BWritableFileUpdateType +BGlobalWritableFileInfo::UpdateType() const +{ + return fUpdateType; +} + + +bool +BGlobalWritableFileInfo::IsDirectory() const +{ + return fIsDirectory; +} + + +void +BGlobalWritableFileInfo::SetTo(const BString& path, + BWritableFileUpdateType updateType, bool isDirectory) +{ + fPath = path; + fUpdateType = updateType; + fIsDirectory = isDirectory; +} + + +} // namespace BPackageKit diff --git a/src/kits/package/Jamfile b/src/kits/package/Jamfile index 0afbade17f..fccb49e1a3 100644 --- a/src/kits/package/Jamfile +++ b/src/kits/package/Jamfile @@ -21,7 +21,7 @@ HPKG_SOURCES = DataWriters.cpp ErrorOutput.cpp FDDataReader.cpp - GlobalSettingsFileInfo.cpp + GlobalWritableFileInfo.cpp HPKGDefs.cpp PackageContentHandler.cpp PackageData.cpp diff --git a/src/kits/package/PackageInfo.cpp b/src/kits/package/PackageInfo.cpp index 0e72db6a63..0a189dba40 100644 --- a/src/kits/package/PackageInfo.cpp +++ b/src/kits/package/PackageInfo.cpp @@ -51,7 +51,7 @@ const char* const BPackageInfo::kElementNames[B_PACKAGE_INFO_ENUM_COUNT] = { "checksum", // not being parsed, computed externally NULL, // install-path -- not settable via .PackageInfo "base-package", - "global-settings-files", + "global-writable-files", "user-settings-files", "users", "groups", @@ -68,8 +68,8 @@ BPackageInfo::kArchitectureNames[B_PACKAGE_ARCHITECTURE_ENUM_COUNT] = { }; -const char* const BPackageInfo::kSettingsFileUpdateTypes[ - B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT] = { +const char* const BPackageInfo::kWritableFileUpdateTypes[ + B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT] = { "keep-old", "manual", "auto-merge", @@ -168,7 +168,7 @@ BPackageInfo::BPackageInfo() fLicenseList(4), fURLList(4), fSourceURLList(4), - fGlobalSettingsFileInfos(4, true), + fGlobalWritableFileInfos(4, true), fUserSettingsFileInfos(4, true), fUsers(4, true), fGroups(4), @@ -192,7 +192,7 @@ BPackageInfo::BPackageInfo(BMessage* archive, status_t* _error) fLicenseList(4), fURLList(4), fSourceURLList(4), - fGlobalSettingsFileInfos(4, true), + fGlobalWritableFileInfos(4, true), fUserSettingsFileInfos(4, true), fUsers(4, true), fGroups(4), @@ -222,8 +222,8 @@ BPackageInfo::BPackageInfo(BMessage* archive, status_t* _error) && (error = _ExtractStringList(archive, "urls", fURLList)) == B_OK && (error = _ExtractStringList(archive, "source-urls", fSourceURLList)) == B_OK - && (error = _ExtractGlobalSettingsFileInfos(archive, - "global-settings-files", fGlobalSettingsFileInfos)) == B_OK + && (error = _ExtractGlobalWritableFileInfos(archive, + "global-writable-files", fGlobalWritableFileInfos)) == B_OK && (error = _ExtractUserSettingsFileInfos(archive, "user-settings-files", fUserSettingsFileInfos)) == B_OK && (error = _ExtractUsers(archive, "users", fUsers)) == B_OK @@ -340,11 +340,11 @@ BPackageInfo::InitCheck() const || fProvidesList.IsEmpty()) return B_NO_INIT; - // check global settings files - int32 globalSettingsFileCount = fGlobalSettingsFileInfos.CountItems(); - for (int32 i = 0; i < globalSettingsFileCount; i++) { - const BGlobalSettingsFileInfo* info - = fGlobalSettingsFileInfos.ItemAt(i); + // check global writable files + int32 globalWritableFileCount = fGlobalWritableFileInfos.CountItems(); + for (int32 i = 0; i < globalWritableFileCount; i++) { + const BGlobalWritableFileInfo* info + = fGlobalWritableFileInfos.ItemAt(i); status_t error = info->InitCheck(); if (error != B_OK) return error; @@ -493,10 +493,10 @@ BPackageInfo::SourceURLList() const } -const BObjectList& -BPackageInfo::GlobalSettingsFileInfos() const +const BObjectList& +BPackageInfo::GlobalWritableFileInfos() const { - return fGlobalSettingsFileInfos; + return fGlobalWritableFileInfos; } @@ -716,18 +716,18 @@ BPackageInfo::AddSourceURL(const BString& url) void -BPackageInfo::ClearGlobalSettingsFileInfos() +BPackageInfo::ClearGlobalWritableFileInfos() { - fGlobalSettingsFileInfos.MakeEmpty(); + fGlobalWritableFileInfos.MakeEmpty(); } status_t -BPackageInfo::AddGlobalSettingsFileInfo(const BGlobalSettingsFileInfo& info) +BPackageInfo::AddGlobalWritableFileInfo(const BGlobalWritableFileInfo& info) { - BGlobalSettingsFileInfo* newInfo - = new (std::nothrow) BGlobalSettingsFileInfo(info); - if (newInfo == NULL || !fGlobalSettingsFileInfos.AddItem(newInfo)) { + BGlobalWritableFileInfo* newInfo + = new (std::nothrow) BGlobalWritableFileInfo(info); + if (newInfo == NULL || !fGlobalWritableFileInfos.AddItem(newInfo)) { delete newInfo; return B_NO_MEMORY; } @@ -932,7 +932,7 @@ BPackageInfo::Clear() fLicenseList.MakeEmpty(); fURLList.MakeEmpty(); fSourceURLList.MakeEmpty(); - fGlobalSettingsFileInfos.MakeEmpty(); + fGlobalWritableFileInfos.MakeEmpty(); fUserSettingsFileInfos.MakeEmpty(); fUsers.MakeEmpty(); fGroups.MakeEmpty(); @@ -968,8 +968,8 @@ BPackageInfo::Archive(BMessage* archive, bool deep) const || (error = archive->AddStrings("urls", fURLList)) != B_OK || (error = archive->AddStrings("source-urls", fSourceURLList)) != B_OK - || (error = _AddGlobalSettingsFileInfos(archive, - "global-settings-files", fGlobalSettingsFileInfos)) != B_OK + || (error = _AddGlobalWritableFileInfos(archive, + "global-writable-files", fGlobalWritableFileInfos)) != B_OK || (error = _AddUserSettingsFileInfos(archive, "user-settings-files", fUserSettingsFileInfos)) != B_OK || (error = _AddUsers(archive, "users", fUsers)) != B_OK @@ -1019,7 +1019,7 @@ BPackageInfo::GetConfigString(BString& _string) const .Write("licenses", fLicenseList) .Write("urls", fURLList) .Write("source-urls", fSourceURLList) - .Write("global-settings-files", fGlobalSettingsFileInfos) + .Write("global-writable-files", fGlobalWritableFileInfos) .Write("user-settings-files", fUserSettingsFileInfos) .Write("users", fUsers) .Write("groups", fGroups) @@ -1219,24 +1219,29 @@ BPackageInfo::_AddResolvableExpressions(BMessage* archive, const char* field, /*static*/ status_t -BPackageInfo::_AddGlobalSettingsFileInfos(BMessage* archive, const char* field, - const GlobalSettingsFileInfoList& infos) +BPackageInfo::_AddGlobalWritableFileInfos(BMessage* archive, const char* field, + const GlobalWritableFileInfoList& infos) { // construct the field names we need FieldName pathField(field, ":path"); - FieldName updateTypeField(field, ":version"); + FieldName updateTypeField(field, ":updateType"); + FieldName isDirectoryField(field, ":isDirectory"); - if (!pathField.IsValid() || !updateTypeField.IsValid()) + if (!pathField.IsValid() || !updateTypeField.IsValid() + || !isDirectoryField.IsValid()) { return B_BAD_VALUE; + } // add fields int32 count = infos.CountItems(); for (int32 i = 0; i < count; i++) { - const BGlobalSettingsFileInfo* info = infos.ItemAt(i); + const BGlobalWritableFileInfo* info = infos.ItemAt(i); status_t error; if ((error = archive->AddString(pathField, info->Path())) != B_OK || (error = archive->AddInt32(updateTypeField, info->UpdateType())) - != B_OK) { + != B_OK + || (error = archive->AddBool(isDirectoryField, + info->IsDirectory())) != B_OK) { return error; } } @@ -1252,9 +1257,12 @@ BPackageInfo::_AddUserSettingsFileInfos(BMessage* archive, const char* field, // construct the field names we need FieldName pathField(field, ":path"); FieldName templatePathField(field, ":templatePath"); + FieldName isDirectoryField(field, ":isDirectory"); - if (!pathField.IsValid() || !templatePathField.IsValid()) + if (!pathField.IsValid() || !templatePathField.IsValid() + || !isDirectoryField.IsValid()) { return B_BAD_VALUE; + } // add fields int32 count = infos.CountItems(); @@ -1263,7 +1271,9 @@ BPackageInfo::_AddUserSettingsFileInfos(BMessage* archive, const char* field, status_t error; if ((error = archive->AddString(pathField, info->Path())) != B_OK || (error = archive->AddString(templatePathField, - info->TemplatePath())) != B_OK) { + info->TemplatePath())) != B_OK + || (error = archive->AddBool(isDirectoryField, + info->IsDirectory())) != B_OK) { return error; } } @@ -1486,15 +1496,18 @@ BPackageInfo::_ExtractResolvableExpressions(BMessage* archive, /*static*/ status_t -BPackageInfo::_ExtractGlobalSettingsFileInfos(BMessage* archive, - const char* field, GlobalSettingsFileInfoList& _infos) +BPackageInfo::_ExtractGlobalWritableFileInfos(BMessage* archive, + const char* field, GlobalWritableFileInfoList& _infos) { // construct the field names we need FieldName pathField(field, ":path"); - FieldName updateTypeField(field, ":version"); + FieldName updateTypeField(field, ":updateType"); + FieldName isDirectoryField(field, ":isDirectory"); - if (!pathField.IsValid() || !updateTypeField.IsValid()) + if (!pathField.IsValid() || !updateTypeField.IsValid() + || !isDirectoryField.IsValid()) { return B_BAD_VALUE; + } // get the number of items type_code type; @@ -1516,13 +1529,18 @@ BPackageInfo::_ExtractGlobalSettingsFileInfos(BMessage* archive, if (error != B_OK) return error; if (updateType < 0 - || updateType > B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT) { + || updateType > B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT) { return B_BAD_DATA; } - BGlobalSettingsFileInfo* info - = new(std::nothrow) BGlobalSettingsFileInfo(path, - (BSettingsFileUpdateType)updateType); + bool isDirectory; + error = archive->FindBool(isDirectoryField, i, &isDirectory); + if (error != B_OK) + return error; + + BGlobalWritableFileInfo* info + = new(std::nothrow) BGlobalWritableFileInfo(path, + (BWritableFileUpdateType)updateType, isDirectory); if (info == NULL || !_infos.AddItem(info)) { delete info; return B_NO_MEMORY; @@ -1540,9 +1558,12 @@ BPackageInfo::_ExtractUserSettingsFileInfos(BMessage* archive, // construct the field names we need FieldName pathField(field, ":path"); FieldName templatePathField(field, ":templatePath"); + FieldName isDirectoryField(field, ":isDirectory"); - if (!pathField.IsValid() || !templatePathField.IsValid()) + if (!pathField.IsValid() || !templatePathField.IsValid() + || !isDirectoryField.IsValid()) { return B_BAD_VALUE; + } // get the number of items type_code type; @@ -1564,8 +1585,14 @@ BPackageInfo::_ExtractUserSettingsFileInfos(BMessage* archive, if (error != B_OK) return error; - BUserSettingsFileInfo* info - = new(std::nothrow) BUserSettingsFileInfo(path, templatePath); + bool isDirectory; + error = archive->FindBool(isDirectoryField, i, &isDirectory); + if (error != B_OK) + return error; + + BUserSettingsFileInfo* info = isDirectory + ? new(std::nothrow) BUserSettingsFileInfo(path, true) + : new(std::nothrow) BUserSettingsFileInfo(path, templatePath); if (info == NULL || !_infos.AddItem(info)) { delete info; return B_NO_MEMORY; diff --git a/src/kits/package/PackageInfoContentHandler.cpp b/src/kits/package/PackageInfoContentHandler.cpp index e6ceacccb6..62ae30d6d6 100644 --- a/src/kits/package/PackageInfoContentHandler.cpp +++ b/src/kits/package/PackageInfoContentHandler.cpp @@ -143,9 +143,9 @@ BPackageInfoContentHandler::HandlePackageAttribute( fPackageInfo.SetBasePackage(value.string); break; - case B_PACKAGE_INFO_GLOBAL_SETTINGS_FILES: - fPackageInfo.AddGlobalSettingsFileInfo( - value.globalSettingsFileInfo); + case B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES: + fPackageInfo.AddGlobalWritableFileInfo( + value.globalWritableFileInfo); break; case B_PACKAGE_INFO_USER_SETTINGS_FILES: diff --git a/src/kits/package/PackageInfoParser.cpp b/src/kits/package/PackageInfoParser.cpp index aaa37b9d5c..02ffe0edd8 100644 --- a/src/kits/package/PackageInfoParser.cpp +++ b/src/kits/package/PackageInfoParser.cpp @@ -604,15 +604,15 @@ BPackageInfo::Parser::_ParseResolvableExprList( void -BPackageInfo::Parser::_ParseGlobalSettingsFileInfos( - GlobalSettingsFileInfoList* infos) +BPackageInfo::Parser::_ParseGlobalWritableFileInfos( + GlobalWritableFileInfoList* infos) { - struct GlobalSettingsFileInfoParser : public ListElementParser { + struct GlobalWritableFileInfoParser : public ListElementParser { Parser& parser; - GlobalSettingsFileInfoList* infos; + GlobalWritableFileInfoList* infos; - GlobalSettingsFileInfoParser(Parser& parser, - GlobalSettingsFileInfoList* infos) + GlobalWritableFileInfoParser(Parser& parser, + GlobalWritableFileInfoList* infos) : parser(parser), infos(infos) @@ -626,21 +626,27 @@ BPackageInfo::Parser::_ParseGlobalSettingsFileInfos( token.pos); } - BSettingsFileUpdateType updateType - = B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT; + BWritableFileUpdateType updateType + = B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT; + bool isDirectory = false; Token nextToken = parser._NextToken(); + if (nextToken.type == TOKEN_WORD && nextToken.text == "directory") { + isDirectory = true; + nextToken = parser._NextToken(); + } + if (nextToken.type == TOKEN_WORD) { - const char* const* end = kSettingsFileUpdateTypes - + B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT; - const char* const* found = std::find(kSettingsFileUpdateTypes, + const char* const* end = kWritableFileUpdateTypes + + B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT; + const char* const* found = std::find(kWritableFileUpdateTypes, end, nextToken.text); if (found == end) { throw ParseError(BString("expected an update type"), nextToken.pos); } - updateType = (BSettingsFileUpdateType)( - found - kSettingsFileUpdateTypes); + updateType = (BWritableFileUpdateType)( + found - kWritableFileUpdateTypes); } else if (nextToken.type == TOKEN_ITEM_SEPARATOR || nextToken.type == TOKEN_CLOSE_BRACE) { parser._RewindTo(nextToken); @@ -650,8 +656,8 @@ BPackageInfo::Parser::_ParseGlobalSettingsFileInfos( nextToken.pos); } - if (!infos->AddItem(new BGlobalSettingsFileInfo(token.text, - updateType))) { + if (!infos->AddItem(new BGlobalWritableFileInfo(token.text, + updateType, isDirectory))) { throw std::bad_alloc(); } } @@ -685,9 +691,13 @@ BPackageInfo::Parser::_ParseUserSettingsFileInfos( } BString templatePath; + bool isDirectory = false; Token nextToken = parser._NextToken(); - if (nextToken.type == TOKEN_WORD && nextToken.text == "template") { + if (nextToken.type == TOKEN_WORD && nextToken.text == "directory") { + isDirectory = true; + } else if (nextToken.type == TOKEN_WORD + && nextToken.text == "template") { nextToken = parser._NextToken(); if (nextToken.type != TOKEN_WORD && nextToken.type != TOKEN_QUOTED_STRING) { @@ -705,8 +715,10 @@ BPackageInfo::Parser::_ParseUserSettingsFileInfos( nextToken.pos); } - if (!infos->AddItem(new BUserSettingsFileInfo(token.text, - templatePath))) { + if (isDirectory + ? !infos->AddItem(new BUserSettingsFileInfo(token.text, true)) + : !infos->AddItem(new BUserSettingsFileInfo(token.text, + templatePath))) { throw std::bad_alloc(); } } @@ -929,9 +941,9 @@ BPackageInfo::Parser::_Parse(BPackageInfo* packageInfo) _ParseStringList(&packageInfo->fSourceURLList); break; - case B_PACKAGE_INFO_GLOBAL_SETTINGS_FILES: - _ParseGlobalSettingsFileInfos( - &packageInfo->fGlobalSettingsFileInfos); + case B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES: + _ParseGlobalWritableFileInfos( + &packageInfo->fGlobalWritableFileInfos); break; case B_PACKAGE_INFO_USER_SETTINGS_FILES: diff --git a/src/kits/package/PackageInfoParser.h b/src/kits/package/PackageInfoParser.h index 5bbbb24e90..3c94b00071 100644 --- a/src/kits/package/PackageInfoParser.h +++ b/src/kits/package/PackageInfoParser.h @@ -75,8 +75,8 @@ private: BObjectList* value, BString* _basePackage = NULL); - void _ParseGlobalSettingsFileInfos( - GlobalSettingsFileInfoList* infos); + void _ParseGlobalWritableFileInfos( + GlobalWritableFileInfoList* infos); void _ParseUserSettingsFileInfos( UserSettingsFileInfoList* infos); void _ParseUsers(UserList* users); diff --git a/src/kits/package/PackageInfoStringBuilder.h b/src/kits/package/PackageInfoStringBuilder.h index 2d140a95e8..a21aa5e95d 100644 --- a/src/kits/package/PackageInfoStringBuilder.h +++ b/src/kits/package/PackageInfoStringBuilder.h @@ -157,19 +157,25 @@ private: } } - void _WriteListElement(const BGlobalSettingsFileInfo* value) + void _WriteListElement(const BGlobalWritableFileInfo* value) { _WriteMaybeQuoted(value->Path()); + if (value->IsDirectory()) { + _Write(' '); + _Write("directory"); + } if (value->IsIncluded()) { _Write(' '); - _Write(kSettingsFileUpdateTypes[value->UpdateType()]); + _Write(kWritableFileUpdateTypes[value->UpdateType()]); } } void _WriteListElement(const BUserSettingsFileInfo* value) { _WriteMaybeQuoted(value->Path()); - if (!value->TemplatePath().IsEmpty()) { + if (value->IsDirectory()) { + _Write(" directory"); + } else if (!value->TemplatePath().IsEmpty()) { _Write(" template "); _WriteMaybeQuoted(value->TemplatePath()); } diff --git a/src/kits/package/UserSettingsFileInfo.cpp b/src/kits/package/UserSettingsFileInfo.cpp index 3993c04154..f339531899 100644 --- a/src/kits/package/UserSettingsFileInfo.cpp +++ b/src/kits/package/UserSettingsFileInfo.cpp @@ -24,7 +24,8 @@ BUserSettingsFileInfo::BUserSettingsFileInfo( const BHPKG::BUserSettingsFileInfoData& infoData) : fPath(infoData.path), - fTemplatePath(infoData.templatePath) + fTemplatePath(infoData.templatePath), + fIsDirectory(infoData.isDirectory) { } @@ -33,7 +34,18 @@ BUserSettingsFileInfo::BUserSettingsFileInfo(const BString& path, const BString& templatePath) : fPath(path), - fTemplatePath(templatePath) + fTemplatePath(templatePath), + fIsDirectory(false) +{ +} + + +BUserSettingsFileInfo::BUserSettingsFileInfo(const BString& path, + bool isDirectory) + : + fPath(path), + fTemplatePath(), + fIsDirectory(isDirectory) { } @@ -64,11 +76,28 @@ BUserSettingsFileInfo::TemplatePath() const } +bool +BUserSettingsFileInfo::IsDirectory() const +{ + return fIsDirectory; +} + + void BUserSettingsFileInfo::SetTo(const BString& path, const BString& templatePath) { fPath = path; fTemplatePath = templatePath; + fIsDirectory = false; +} + + +void +BUserSettingsFileInfo::SetTo(const BString& path, bool isDirectory) +{ + fPath = path; + fTemplatePath.Truncate(0); + fIsDirectory = isDirectory; } diff --git a/src/kits/package/hpkg/ReaderImplBase.cpp b/src/kits/package/hpkg/ReaderImplBase.cpp index 2c1557bdf2..1734ba0e73 100644 --- a/src/kits/package/hpkg/ReaderImplBase.cpp +++ b/src/kits/package/hpkg/ReaderImplBase.cpp @@ -321,11 +321,11 @@ ReaderImplBase::PackageResolvableExpressionAttributeHandler::HandleAttribute( } -// #pragma mark - GlobalSettingsFileInfoAttributeHandler +// #pragma mark - GlobalWritableFileInfoAttributeHandler -ReaderImplBase::GlobalSettingsFileInfoAttributeHandler - ::GlobalSettingsFileInfoAttributeHandler( +ReaderImplBase::GlobalWritableFileInfoAttributeHandler + ::GlobalWritableFileInfoAttributeHandler( BPackageInfoAttributeValue& packageInfoValue) : PackageInfoAttributeHandlerBase(packageInfoValue) @@ -334,21 +334,21 @@ ReaderImplBase::GlobalSettingsFileInfoAttributeHandler status_t -ReaderImplBase::GlobalSettingsFileInfoAttributeHandler::HandleAttribute( +ReaderImplBase::GlobalWritableFileInfoAttributeHandler::HandleAttribute( AttributeHandlerContext* context, uint8 id, const AttributeValue& value, AttributeHandler** _handler) { switch (id) { - case B_HPKG_ATTRIBUTE_ID_PACKAGE_SETTINGS_FILE_UPDATE_TYPE: - if (value.unsignedInt >= B_PACKAGE_RESOLVABLE_OP_ENUM_COUNT) { + case B_HPKG_ATTRIBUTE_ID_PACKAGE_WRITABLE_FILE_UPDATE_TYPE: + if (value.unsignedInt >= B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT) { context->errorOutput->PrintError( "Error: Invalid package attribute section: invalid " "global settings file update type %" B_PRIu64 " encountered\n", value.unsignedInt); return B_BAD_DATA; } - fPackageInfoValue.globalSettingsFileInfo.updateType - = (BSettingsFileUpdateType)value.unsignedInt; + fPackageInfoValue.globalWritableFileInfo.updateType + = (BWritableFileUpdateType)value.unsignedInt; break; default: @@ -604,15 +604,15 @@ ReaderImplBase::PackageAttributeHandler::HandleAttribute( fPackageInfoValue.SetTo(B_PACKAGE_INFO_INSTALL_PATH, value.string); break; - case B_HPKG_ATTRIBUTE_ID_PACKAGE_GLOBAL_SETTINGS_FILE: - fPackageInfoValue.globalSettingsFileInfo.path = value.string; - fPackageInfoValue.globalSettingsFileInfo.updateType - = B_SETTINGS_FILE_UPDATE_TYPE_ENUM_COUNT; + case B_HPKG_ATTRIBUTE_ID_PACKAGE_GLOBAL_WRITABLE_FILE: + fPackageInfoValue.globalWritableFileInfo.path = value.string; + fPackageInfoValue.globalWritableFileInfo.updateType + = B_WRITABLE_FILE_UPDATE_TYPE_ENUM_COUNT; fPackageInfoValue.attributeID - = B_PACKAGE_INFO_GLOBAL_SETTINGS_FILES; + = B_PACKAGE_INFO_GLOBAL_WRITABLE_FILES; if (_handler != NULL) { *_handler - = new(std::nothrow) GlobalSettingsFileInfoAttributeHandler( + = new(std::nothrow) GlobalWritableFileInfoAttributeHandler( fPackageInfoValue); if (*_handler == NULL) return B_NO_MEMORY; diff --git a/src/kits/package/hpkg/WriterImplBase.cpp b/src/kits/package/hpkg/WriterImplBase.cpp index d0ac820c35..21f8d40d43 100644 --- a/src/kits/package/hpkg/WriterImplBase.cpp +++ b/src/kits/package/hpkg/WriterImplBase.cpp @@ -379,18 +379,27 @@ WriterImplBase::RegisterPackageInfo(PackageAttributeList& attributeList, _AddStringAttributeList(B_HPKG_ATTRIBUTE_ID_PACKAGE_REPLACES, packageInfo.ReplacesList(), attributeList); - // global settings file info list - const BObjectList& globalSettingsFileInfos - = packageInfo.GlobalSettingsFileInfos(); - for (int32 i = 0; i < globalSettingsFileInfos.CountItems(); ++i) { - BGlobalSettingsFileInfo* info = globalSettingsFileInfos.ItemAt(i); + // global writable file info list + const BObjectList& globalWritableFileInfos + = packageInfo.GlobalWritableFileInfos(); + for (int32 i = 0; i < globalWritableFileInfos.CountItems(); ++i) { + BGlobalWritableFileInfo* info = globalWritableFileInfos.ItemAt(i); PackageAttribute* attribute = _AddStringAttribute( - B_HPKG_ATTRIBUTE_ID_PACKAGE_GLOBAL_SETTINGS_FILE, info->Path(), + B_HPKG_ATTRIBUTE_ID_PACKAGE_GLOBAL_WRITABLE_FILE, info->Path(), attributeList); + if (info->IsDirectory()) { + PackageAttribute* isDirectoryAttribute = new PackageAttribute( + B_HPKG_ATTRIBUTE_ID_PACKAGE_IS_WRITABLE_DIRECTORY, + B_HPKG_ATTRIBUTE_TYPE_UINT, + B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT); + isDirectoryAttribute->unsignedInt = 1; + attribute->children.Add(isDirectoryAttribute); + } + if (info->IsIncluded()) { PackageAttribute* updateTypeAttribute = new PackageAttribute( - B_HPKG_ATTRIBUTE_ID_PACKAGE_SETTINGS_FILE_UPDATE_TYPE, + B_HPKG_ATTRIBUTE_ID_PACKAGE_WRITABLE_FILE_UPDATE_TYPE, B_HPKG_ATTRIBUTE_TYPE_UINT, B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT); updateTypeAttribute->unsignedInt = info->UpdateType(); @@ -407,9 +416,18 @@ WriterImplBase::RegisterPackageInfo(PackageAttributeList& attributeList, B_HPKG_ATTRIBUTE_ID_PACKAGE_USER_SETTINGS_FILE, info->Path(), attributeList); - _AddStringAttributeIfNotEmpty( - B_HPKG_ATTRIBUTE_ID_PACKAGE_SETTINGS_FILE_TEMPLATE, - info->TemplatePath(), attribute->children); + if (info->IsDirectory()) { + PackageAttribute* isDirectoryAttribute = new PackageAttribute( + B_HPKG_ATTRIBUTE_ID_PACKAGE_IS_WRITABLE_DIRECTORY, + B_HPKG_ATTRIBUTE_TYPE_UINT, + B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT); + isDirectoryAttribute->unsignedInt = 1; + attribute->children.Add(isDirectoryAttribute); + } else { + _AddStringAttributeIfNotEmpty( + B_HPKG_ATTRIBUTE_ID_PACKAGE_SETTINGS_FILE_TEMPLATE, + info->TemplatePath(), attribute->children); + } } // user list