Rename Package "name" property to "fileName"
This commit is contained in:
parent
6e6ca8c530
commit
ddabac20de
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
Package::Package(PackageDomain* domain, dev_t deviceID, ino_t nodeID)
|
||||
:
|
||||
fDomain(domain),
|
||||
fName(NULL),
|
||||
fFileName(NULL),
|
||||
fFD(-1),
|
||||
fOpenCount(0),
|
||||
fNodeID(nodeID),
|
||||
@ -36,17 +36,17 @@ Package::~Package()
|
||||
while (PackageNode* node = fNodes.RemoveHead())
|
||||
node->ReleaseReference();
|
||||
|
||||
free(fName);
|
||||
free(fFileName);
|
||||
|
||||
mutex_destroy(&fLock);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Package::Init(const char* name)
|
||||
Package::Init(const char* fileName)
|
||||
{
|
||||
fName = strdup(name);
|
||||
if (fName == NULL)
|
||||
fFileName = strdup(fileName);
|
||||
if (fFileName == NULL)
|
||||
RETURN_ERROR(B_NO_MEMORY);
|
||||
|
||||
return B_OK;
|
||||
@ -71,16 +71,16 @@ Package::Open()
|
||||
}
|
||||
|
||||
// open the file
|
||||
fFD = openat(fDomain->DirectoryFD(), fName, O_RDONLY);
|
||||
fFD = openat(fDomain->DirectoryFD(), fFileName, O_RDONLY);
|
||||
if (fFD < 0) {
|
||||
ERROR("Failed to open package file \"%s\"\n", fName);
|
||||
ERROR("Failed to open package file \"%s\"\n", fFileName);
|
||||
return errno;
|
||||
}
|
||||
|
||||
// stat it to verify that it's still the same file
|
||||
struct stat st;
|
||||
if (fstat(fFD, &st) < 0) {
|
||||
ERROR("Failed to stat package file \"%s\"\n", fName);
|
||||
ERROR("Failed to stat package file \"%s\"\n", fFileName);
|
||||
close(fFD);
|
||||
fFD = -1;
|
||||
return errno;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef PACKAGE_H
|
||||
@ -25,28 +25,28 @@ public:
|
||||
ino_t nodeID);
|
||||
~Package();
|
||||
|
||||
status_t Init(const char* name);
|
||||
status_t Init(const char* fileName);
|
||||
|
||||
PackageDomain* Domain() const { return fDomain; }
|
||||
const char* Name() const { return fName; }
|
||||
PackageDomain* Domain() const { return fDomain; }
|
||||
const char* FileName() const { return fFileName; }
|
||||
|
||||
Package*& HashTableNext() { return fHashTableNext; }
|
||||
Package*& FileNameHashTableNext()
|
||||
{ return fFileNameHashTableNext; }
|
||||
|
||||
void AddNode(PackageNode* node);
|
||||
|
||||
int Open();
|
||||
void Close();
|
||||
|
||||
const PackageNodeList& Nodes() const
|
||||
{ return fNodes; }
|
||||
const PackageNodeList& Nodes() const { return fNodes; }
|
||||
|
||||
private:
|
||||
mutex fLock;
|
||||
PackageDomain* fDomain;
|
||||
char* fName;
|
||||
char* fFileName;
|
||||
int fFD;
|
||||
uint32 fOpenCount;
|
||||
Package* fHashTableNext;
|
||||
Package* fFileNameHashTableNext;
|
||||
ino_t fNodeID;
|
||||
dev_t fDeviceID;
|
||||
PackageNodeList fNodes;
|
||||
@ -76,7 +76,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
struct PackageHashDefinition {
|
||||
struct PackageFileNameHashDefinition {
|
||||
typedef const char* KeyType;
|
||||
typedef Package ValueType;
|
||||
|
||||
@ -87,22 +87,22 @@ struct PackageHashDefinition {
|
||||
|
||||
size_t Hash(const Package* value) const
|
||||
{
|
||||
return HashKey(value->Name());
|
||||
return HashKey(value->FileName());
|
||||
}
|
||||
|
||||
bool Compare(const char* key, const Package* value) const
|
||||
{
|
||||
return strcmp(value->Name(), key) == 0;
|
||||
return strcmp(value->FileName(), key) == 0;
|
||||
}
|
||||
|
||||
Package*& GetLink(Package* value) const
|
||||
{
|
||||
return value->HashTableNext();
|
||||
return value->FileNameHashTableNext();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef BOpenHashTable<PackageHashDefinition> PackageHashTable;
|
||||
typedef BOpenHashTable<PackageFileNameHashDefinition> PackageFileNameHashTable;
|
||||
|
||||
|
||||
#endif // PACKAGE_H
|
||||
|
@ -41,7 +41,7 @@ PackageDomain::~PackageDomain()
|
||||
|
||||
Package* package = fPackages.Clear(true);
|
||||
while (package != NULL) {
|
||||
Package* next = package->HashTableNext();
|
||||
Package* next = package->FileNameHashTableNext();
|
||||
package->ReleaseReference();
|
||||
package = next;
|
||||
}
|
||||
@ -113,7 +113,7 @@ PackageDomain::RemovePackage(Package* package)
|
||||
|
||||
|
||||
Package*
|
||||
PackageDomain::FindPackage(const char* name) const
|
||||
PackageDomain::FindPackage(const char* fileName) const
|
||||
{
|
||||
return fPackages.Lookup(name);
|
||||
return fPackages.Lookup(fileName);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef PACKAGE_DOMAIN_H
|
||||
@ -34,9 +34,9 @@ public:
|
||||
void AddPackage(Package* package);
|
||||
void RemovePackage(Package* package);
|
||||
|
||||
Package* FindPackage(const char* name) const;
|
||||
Package* FindPackage(const char* fileName) const;
|
||||
|
||||
const PackageHashTable& Packages() const
|
||||
const PackageFileNameHashTable& Packages() const
|
||||
{ return fPackages; }
|
||||
|
||||
private:
|
||||
@ -45,7 +45,7 @@ private:
|
||||
dev_t fDeviceID;
|
||||
ino_t fNodeID;
|
||||
NotificationListener* fListener;
|
||||
PackageHashTable fPackages;
|
||||
PackageFileNameHashTable fPackages;
|
||||
};
|
||||
|
||||
|
||||
|
@ -603,8 +603,8 @@ Volume::_AddPackageDomain(PackageDomain* domain, bool notify)
|
||||
|
||||
// add the packages to the node tree
|
||||
VolumeWriteLocker volumeLocker(this);
|
||||
for (PackageHashTable::Iterator it = domain->Packages().GetIterator();
|
||||
Package* package = it.Next();) {
|
||||
for (PackageFileNameHashTable::Iterator it
|
||||
= domain->Packages().GetIterator(); Package* package = it.Next();) {
|
||||
error = _AddPackageContent(package, notify);
|
||||
if (error != B_OK) {
|
||||
for (it.Rewind(); Package* activePackage = it.Next();) {
|
||||
|
Loading…
Reference in New Issue
Block a user