git-svn-id: https://profuse.googlecode.com/svn/branches/v2@317 aa027e90-d47c-11dd-86d7-074df07e0730

This commit is contained in:
ksherlock
2010-06-26 03:31:16 +00:00
parent 1894a178d1
commit cd1e227fc5
10 changed files with 498 additions and 1880 deletions
+28 -3
View File
@@ -29,6 +29,29 @@ enum {
kMaxFiles = 77
};
// djb hash, case insensitive.
static unsigned NameHash(const char *cp)
{
unsigned hash = 5381;
unsigned c;
while ((c = *cp++))
{
c = std::toupper(c);
hash = ((hash << 5) + hash) + c;
}
return hash & 0x7FFFFFFF;
}
static bool NameEqual(const char *a, const char *b)
{
return ::strcasecmp(a, b) == 0;
}
unsigned VolumeEntry::ValidName(const char *cp)
{
// 7 chars max. Legal values: ascii, printable,
@@ -585,14 +608,16 @@ FileEntry *VolumeEntry::create(const char *name, unsigned blocks)
prev->_maxFileSize = prev->blocks() * 512;
}
// insert() inserts an item *before* the current item.
// insert() inserts an item *before* the current item and returns an iterator to the
// element inserted.
// afterwards, iter will point to curr+1
// keep track of the index *before* the insert.
unsigned index = distance(_files.begin(), iter); // current index.
_files.insert(iter, entry.get());
_fileCount++;
iter = _files.insert(iter, entry.get());
++_fileCount;
curr = entry.release();
curr->_parent = this;