BDirectory: Rewrite some functions for clarity.
No functional change intended. Whoever wrote these functions before seems to have been allergic to more than one "return" statement in a function...
This commit is contained in:
@@ -331,50 +331,47 @@ BDirectory::Contains(const BEntry* entry, int32 nodeFlags) const
|
|||||||
status_t
|
status_t
|
||||||
BDirectory::GetNextEntry(BEntry* entry, bool traverse)
|
BDirectory::GetNextEntry(BEntry* entry, bool traverse)
|
||||||
{
|
{
|
||||||
status_t error = (entry ? B_OK : B_BAD_VALUE);
|
if (entry == NULL)
|
||||||
if (error == B_OK) {
|
return B_BAD_VALUE;
|
||||||
entry_ref ref;
|
|
||||||
error = GetNextRef(&ref);
|
entry_ref ref;
|
||||||
if (error == B_OK)
|
status_t status = GetNextRef(&ref);
|
||||||
error = entry->SetTo(&ref, traverse);
|
if (status != B_OK) {
|
||||||
}
|
|
||||||
if (error != B_OK && entry != NULL)
|
|
||||||
entry->Unset();
|
entry->Unset();
|
||||||
return error;
|
return status;
|
||||||
|
}
|
||||||
|
return entry->SetTo(&ref, traverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BDirectory::GetNextRef(entry_ref* ref)
|
BDirectory::GetNextRef(entry_ref* ref)
|
||||||
{
|
{
|
||||||
status_t error = (ref ? B_OK : B_BAD_VALUE);
|
if (ref == NULL)
|
||||||
if (error == B_OK && InitCheck() != B_OK)
|
return B_BAD_VALUE;
|
||||||
error = B_FILE_ERROR;
|
if (InitCheck() != B_OK)
|
||||||
if (error == B_OK) {
|
return B_FILE_ERROR;
|
||||||
BPrivate::Storage::LongDirEntry entry;
|
|
||||||
bool next = true;
|
BPrivate::Storage::LongDirEntry entry;
|
||||||
while (error == B_OK && next) {
|
bool next = true;
|
||||||
if (GetNextDirents(&entry, sizeof(entry), 1) != 1) {
|
while (next) {
|
||||||
error = B_ENTRY_NOT_FOUND;
|
if (GetNextDirents(&entry, sizeof(entry), 1) != 1)
|
||||||
} else {
|
return B_ENTRY_NOT_FOUND;
|
||||||
next = (!strcmp(entry.d_name, ".")
|
|
||||||
|| !strcmp(entry.d_name, ".."));
|
next = (!strcmp(entry.d_name, ".")
|
||||||
}
|
|| !strcmp(entry.d_name, ".."));
|
||||||
}
|
|
||||||
if (error == B_OK) {
|
|
||||||
ref->device = entry.d_pdev;
|
|
||||||
ref->directory = entry.d_pino;
|
|
||||||
error = ref->set_name(entry.d_name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return error;
|
|
||||||
|
ref->device = entry.d_pdev;
|
||||||
|
ref->directory = entry.d_pino;
|
||||||
|
return ref->set_name(entry.d_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
BDirectory::GetNextDirents(dirent* buf, size_t bufSize, int32 count)
|
BDirectory::GetNextDirents(dirent* buf, size_t bufSize, int32 count)
|
||||||
{
|
{
|
||||||
if (!buf)
|
if (buf == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
if (InitCheck() != B_OK)
|
if (InitCheck() != B_OK)
|
||||||
return B_FILE_ERROR;
|
return B_FILE_ERROR;
|
||||||
|
|||||||
Reference in New Issue
Block a user