Rename Package "name" property to "fileName"

This commit is contained in:
Ingo Weinhold 2011-06-22 01:59:24 +02:00
parent f1ae591771
commit cc1dc4db4c
5 changed files with 32 additions and 32 deletions

View File

@ -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. * Distributed under the terms of the MIT License.
*/ */
@ -21,7 +21,7 @@
Package::Package(PackageDomain* domain, dev_t deviceID, ino_t nodeID) Package::Package(PackageDomain* domain, dev_t deviceID, ino_t nodeID)
: :
fDomain(domain), fDomain(domain),
fName(NULL), fFileName(NULL),
fFD(-1), fFD(-1),
fOpenCount(0), fOpenCount(0),
fNodeID(nodeID), fNodeID(nodeID),
@ -36,17 +36,17 @@ Package::~Package()
while (PackageNode* node = fNodes.RemoveHead()) while (PackageNode* node = fNodes.RemoveHead())
node->ReleaseReference(); node->ReleaseReference();
free(fName); free(fFileName);
mutex_destroy(&fLock); mutex_destroy(&fLock);
} }
status_t status_t
Package::Init(const char* name) Package::Init(const char* fileName)
{ {
fName = strdup(name); fFileName = strdup(fileName);
if (fName == NULL) if (fFileName == NULL)
RETURN_ERROR(B_NO_MEMORY); RETURN_ERROR(B_NO_MEMORY);
return B_OK; return B_OK;
@ -71,16 +71,16 @@ Package::Open()
} }
// open the file // open the file
fFD = openat(fDomain->DirectoryFD(), fName, O_RDONLY); fFD = openat(fDomain->DirectoryFD(), fFileName, O_RDONLY);
if (fFD < 0) { if (fFD < 0) {
ERROR("Failed to open package file \"%s\"\n", fName); ERROR("Failed to open package file \"%s\"\n", fFileName);
return errno; return errno;
} }
// stat it to verify that it's still the same file // stat it to verify that it's still the same file
struct stat st; struct stat st;
if (fstat(fFD, &st) < 0) { 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); close(fFD);
fFD = -1; fFD = -1;
return errno; return errno;

View File

@ -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. * Distributed under the terms of the MIT License.
*/ */
#ifndef PACKAGE_H #ifndef PACKAGE_H
@ -25,28 +25,28 @@ public:
ino_t nodeID); ino_t nodeID);
~Package(); ~Package();
status_t Init(const char* name); status_t Init(const char* fileName);
PackageDomain* Domain() const { return fDomain; } PackageDomain* Domain() const { return fDomain; }
const char* Name() const { return fName; } const char* FileName() const { return fFileName; }
Package*& HashTableNext() { return fHashTableNext; } Package*& FileNameHashTableNext()
{ return fFileNameHashTableNext; }
void AddNode(PackageNode* node); void AddNode(PackageNode* node);
int Open(); int Open();
void Close(); void Close();
const PackageNodeList& Nodes() const const PackageNodeList& Nodes() const { return fNodes; }
{ return fNodes; }
private: private:
mutex fLock; mutex fLock;
PackageDomain* fDomain; PackageDomain* fDomain;
char* fName; char* fFileName;
int fFD; int fFD;
uint32 fOpenCount; uint32 fOpenCount;
Package* fHashTableNext; Package* fFileNameHashTableNext;
ino_t fNodeID; ino_t fNodeID;
dev_t fDeviceID; dev_t fDeviceID;
PackageNodeList fNodes; PackageNodeList fNodes;
@ -76,7 +76,7 @@ private:
}; };
struct PackageHashDefinition { struct PackageFileNameHashDefinition {
typedef const char* KeyType; typedef const char* KeyType;
typedef Package ValueType; typedef Package ValueType;
@ -87,22 +87,22 @@ struct PackageHashDefinition {
size_t Hash(const Package* value) const size_t Hash(const Package* value) const
{ {
return HashKey(value->Name()); return HashKey(value->FileName());
} }
bool Compare(const char* key, const Package* value) const 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 Package*& GetLink(Package* value) const
{ {
return value->HashTableNext(); return value->FileNameHashTableNext();
} }
}; };
typedef BOpenHashTable<PackageHashDefinition> PackageHashTable; typedef BOpenHashTable<PackageFileNameHashDefinition> PackageFileNameHashTable;
#endif // PACKAGE_H #endif // PACKAGE_H

View File

@ -41,7 +41,7 @@ PackageDomain::~PackageDomain()
Package* package = fPackages.Clear(true); Package* package = fPackages.Clear(true);
while (package != NULL) { while (package != NULL) {
Package* next = package->HashTableNext(); Package* next = package->FileNameHashTableNext();
package->ReleaseReference(); package->ReleaseReference();
package = next; package = next;
} }
@ -113,7 +113,7 @@ PackageDomain::RemovePackage(Package* package)
Package* Package*
PackageDomain::FindPackage(const char* name) const PackageDomain::FindPackage(const char* fileName) const
{ {
return fPackages.Lookup(name); return fPackages.Lookup(fileName);
} }

View File

@ -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. * Distributed under the terms of the MIT License.
*/ */
#ifndef PACKAGE_DOMAIN_H #ifndef PACKAGE_DOMAIN_H
@ -34,9 +34,9 @@ public:
void AddPackage(Package* package); void AddPackage(Package* package);
void RemovePackage(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; } { return fPackages; }
private: private:
@ -45,7 +45,7 @@ private:
dev_t fDeviceID; dev_t fDeviceID;
ino_t fNodeID; ino_t fNodeID;
NotificationListener* fListener; NotificationListener* fListener;
PackageHashTable fPackages; PackageFileNameHashTable fPackages;
}; };

View File

@ -603,8 +603,8 @@ Volume::_AddPackageDomain(PackageDomain* domain, bool notify)
// add the packages to the node tree // add the packages to the node tree
VolumeWriteLocker volumeLocker(this); VolumeWriteLocker volumeLocker(this);
for (PackageHashTable::Iterator it = domain->Packages().GetIterator(); for (PackageFileNameHashTable::Iterator it
Package* package = it.Next();) { = domain->Packages().GetIterator(); Package* package = it.Next();) {
error = _AddPackageContent(package, notify); error = _AddPackageContent(package, notify);
if (error != B_OK) { if (error != B_OK) {
for (it.Rewind(); Package* activePackage = it.Next();) { for (it.Rewind(); Package* activePackage = it.Next();) {