* Reverted r27196 and solved it differently (in a more robust way): instead of

guessing that the first attribute will be a name attribute, fCurrentSmallData
  now takes hidden attributes into account.
* I haven't tested this change, though, so if it messes things up again, please
  yell at me :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27441 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-09-12 09:25:17 +00:00
parent 2e2bff94a9
commit c4b2fd5be3
1 changed files with 12 additions and 21 deletions

View File

@ -2599,16 +2599,13 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type,
RecursiveLocker _(&fInode->SmallDataLock()); RecursiveLocker _(&fInode->SmallDataLock());
int32 i = 0; int32 index = 0;
for (;;item = item->Next()) { for (; !item->IsLast(node); item = item->Next(), index++) {
if (item->IsLast(node))
break;
if (item->NameSize() == FILE_NAME_NAME_LENGTH if (item->NameSize() == FILE_NAME_NAME_LENGTH
&& *item->Name() == FILE_NAME_NAME) && *item->Name() == FILE_NAME_NAME)
continue; continue;
if (i++ == fCurrentSmallData) if (index >= fCurrentSmallData)
break; break;
} }
@ -2618,15 +2615,12 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type,
*_length = item->NameSize(); *_length = item->NameSize();
*_id = (ino_t)fCurrentSmallData; *_id = (ino_t)fCurrentSmallData;
fCurrentSmallData = i; fCurrentSmallData = index;
} return B_OK;
else {
// stop traversing the small_data section
fCurrentSmallData = -1;
} }
if (fCurrentSmallData != -1) // stop traversing the small_data section
return B_OK; fCurrentSmallData = -1;
} }
// read attributes out of the attribute directory // read attributes out of the attribute directory
@ -2676,11 +2670,8 @@ AttributeIterator::GetNext(char* name, size_t* _length, uint32* _type,
void void
AttributeIterator::Update(uint16 index, int8 change) AttributeIterator::Update(uint16 index, int8 change)
{ {
// fCurrentSmallData points already to the next item. OTOH, index is always // fCurrentSmallData points already to the next item
// the position when considering the special name attribute while the if (index < fCurrentSmallData)
// attribute iterators do ignore that (they always start at the second
// position in the small data section, not the first).
if (index <= fCurrentSmallData)
fCurrentSmallData += change; fCurrentSmallData += change;
} }