PackageInstaller: More cleanup and code simplifications
This commit is contained in:
@@ -105,9 +105,10 @@ InstalledPackageInfo::InitCheck()
|
||||
|
||||
status_t
|
||||
InstalledPackageInfo::SetTo(const char *packageName, const char *version,
|
||||
bool create)
|
||||
bool create)
|
||||
{
|
||||
_ClearItemList();
|
||||
|
||||
fCreate = create;
|
||||
fStatus = B_NO_INIT;
|
||||
fVersion = version;
|
||||
@@ -179,8 +180,7 @@ InstalledPackageInfo::SetTo(const char *packageName, const char *version,
|
||||
fInstalledItems.AddItem(new BString(itemPath)); // Or maybe BPath better?
|
||||
}
|
||||
fIsUpToDate = true;
|
||||
}
|
||||
else if (fStatus == B_ENTRY_NOT_FOUND) {
|
||||
} else if (fStatus == B_ENTRY_NOT_FOUND) {
|
||||
if (create) {
|
||||
fStatus = B_OK;
|
||||
fIsUpToDate = false;
|
||||
@@ -315,13 +315,8 @@ InstalledPackageInfo::Save()
|
||||
void
|
||||
InstalledPackageInfo::_ClearItemList()
|
||||
{
|
||||
// Clear the items list
|
||||
BString *iter;
|
||||
uint32 i, count = fInstalledItems.CountItems();
|
||||
for (i = 0; i < count; i++) {
|
||||
iter = static_cast<BString *>(fInstalledItems.ItemAt(0));
|
||||
fInstalledItems.RemoveItem((int32)0);
|
||||
delete iter;
|
||||
}
|
||||
for (int32 i = fInstalledItems.CountItems() - 1; i >= 0; i--)
|
||||
delete static_cast<BString*>(fInstalledItems.ItemAtFast(i));
|
||||
fInstalledItems.MakeEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* Author:
|
||||
* Łukasz 'Sil2100' Zemczak <[email protected]>
|
||||
*/
|
||||
#ifndef INSTALLEDPACKAGEINFO_H
|
||||
#define INSTALLEDPACKAGEINFO_H
|
||||
#ifndef INSTALLED_PACKAGE_INFO_H
|
||||
#define INSTALLED_PACKAGE_INFO_H
|
||||
|
||||
#include <File.h>
|
||||
#include <String.h>
|
||||
@@ -25,51 +25,60 @@ extern const char * kPackagesDir;
|
||||
|
||||
// Useful function for fetching the package name and version without parsing all
|
||||
// other data
|
||||
status_t info_get_package_name(const char *filename, BString &name);
|
||||
status_t info_get_package_version(const char *filename, BString &name);
|
||||
status_t info_get_package_name(const char* filename, BString& name);
|
||||
status_t info_get_package_version(const char* filename, BString& name);
|
||||
|
||||
|
||||
class InstalledPackageInfo {
|
||||
public:
|
||||
InstalledPackageInfo();
|
||||
InstalledPackageInfo(const char *packageName, const char *version = NULL,
|
||||
bool create = false);
|
||||
~InstalledPackageInfo();
|
||||
public:
|
||||
InstalledPackageInfo();
|
||||
InstalledPackageInfo(const char* packageName,
|
||||
const char* version = NULL,
|
||||
bool create = false);
|
||||
~InstalledPackageInfo();
|
||||
|
||||
status_t InitCheck();
|
||||
status_t SetTo(const char *packageName, const char *version = NULL,
|
||||
bool create = false);
|
||||
status_t InitCheck();
|
||||
status_t SetTo(const char* packageName,
|
||||
const char* version = NULL,
|
||||
bool create = false);
|
||||
|
||||
void SetName(const char *name) { fName = name; }
|
||||
const char *GetName() { return fName.String(); }
|
||||
void SetDescription(const char *description) { fDescription = description; }
|
||||
const char *GetDescription() { return fDescription.String(); }
|
||||
//void SetVersion(const char *version) { fVersion = version; }
|
||||
const char *GetVersion() { return fVersion.String(); }
|
||||
void SetSpaceNeeded(uint64 size) { fSpaceNeeded = size; }
|
||||
uint64 GetSpaceNeeded() { return fSpaceNeeded; }
|
||||
void SetName(const char* name)
|
||||
{ fName = name; }
|
||||
const char* Name()
|
||||
{ return fName.String(); }
|
||||
void SetDescription(const char* description)
|
||||
{ fDescription = description; }
|
||||
const char* Description()
|
||||
{ return fDescription.String(); }
|
||||
const char* Version()
|
||||
{ return fVersion.String(); }
|
||||
void SetSpaceNeeded(uint64 size)
|
||||
{ fSpaceNeeded = size; }
|
||||
uint64 SpaceNeeded()
|
||||
{ return fSpaceNeeded; }
|
||||
|
||||
status_t AddItem(const char *itemName);
|
||||
status_t AddItem(const char* itemName);
|
||||
|
||||
status_t Uninstall();
|
||||
status_t Save();
|
||||
status_t Uninstall();
|
||||
status_t Save();
|
||||
|
||||
private:
|
||||
void _ClearItemList();
|
||||
private:
|
||||
void _ClearItemList();
|
||||
|
||||
status_t fStatus;
|
||||
bool fIsUpToDate;
|
||||
bool fCreate;
|
||||
private:
|
||||
status_t fStatus;
|
||||
bool fIsUpToDate;
|
||||
bool fCreate;
|
||||
|
||||
BString fName;
|
||||
BString fDescription;
|
||||
BString fVersion;
|
||||
uint64 fSpaceNeeded;
|
||||
BList fInstalledItems;
|
||||
BString fName;
|
||||
BString fDescription;
|
||||
BString fVersion;
|
||||
uint64 fSpaceNeeded;
|
||||
BList fInstalledItems;
|
||||
|
||||
BPath fPathToInfo;
|
||||
BPath fPathToInfo;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif // INSTALLED_PACKAGE_INFO_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user