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
|
||||
BDirectory::GetNextEntry(BEntry* entry, bool traverse)
|
||||
{
|
||||
status_t error = (entry ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK) {
|
||||
entry_ref ref;
|
||||
error = GetNextRef(&ref);
|
||||
if (error == B_OK)
|
||||
error = entry->SetTo(&ref, traverse);
|
||||
}
|
||||
if (error != B_OK && entry != NULL)
|
||||
if (entry == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
entry_ref ref;
|
||||
status_t status = GetNextRef(&ref);
|
||||
if (status != B_OK) {
|
||||
entry->Unset();
|
||||
return error;
|
||||
return status;
|
||||
}
|
||||
return entry->SetTo(&ref, traverse);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BDirectory::GetNextRef(entry_ref* ref)
|
||||
{
|
||||
status_t error = (ref ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK && InitCheck() != B_OK)
|
||||
error = B_FILE_ERROR;
|
||||
if (error == B_OK) {
|
||||
BPrivate::Storage::LongDirEntry entry;
|
||||
bool next = true;
|
||||
while (error == B_OK && next) {
|
||||
if (GetNextDirents(&entry, sizeof(entry), 1) != 1) {
|
||||
error = B_ENTRY_NOT_FOUND;
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
if (ref == NULL)
|
||||
return B_BAD_VALUE;
|
||||
if (InitCheck() != B_OK)
|
||||
return B_FILE_ERROR;
|
||||
|
||||
BPrivate::Storage::LongDirEntry entry;
|
||||
bool next = true;
|
||||
while (next) {
|
||||
if (GetNextDirents(&entry, sizeof(entry), 1) != 1)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
next = (!strcmp(entry.d_name, ".")
|
||||
|| !strcmp(entry.d_name, ".."));
|
||||
}
|
||||
return error;
|
||||
|
||||
ref->device = entry.d_pdev;
|
||||
ref->directory = entry.d_pino;
|
||||
return ref->set_name(entry.d_name);
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
BDirectory::GetNextDirents(dirent* buf, size_t bufSize, int32 count)
|
||||
{
|
||||
if (!buf)
|
||||
if (buf == NULL)
|
||||
return B_BAD_VALUE;
|
||||
if (InitCheck() != B_OK)
|
||||
return B_FILE_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user