MimeEntryProcessor: Add DoRecursively()

While Do() only process the specified entry, DoRecursively() also
recurses into directories.
This commit is contained in:
Ingo Weinhold 2013-05-09 03:18:46 +02:00
parent f132bdfe9f
commit 5fb3348319
2 changed files with 28 additions and 0 deletions

View File

@ -36,6 +36,8 @@ public:
virtual status_t Do(const entry_ref& entry, bool* _entryIsDir)
= 0;
status_t DoRecursively(const entry_ref& entry);
protected:
Database* fDatabase;
DatabaseLocker* fDatabaseLocker;

View File

@ -9,6 +9,9 @@
#include <mime/AppMetaMimeCreator.h>
#include <Directory.h>
#include <Entry.h>
namespace BPrivate {
namespace Storage {
@ -41,6 +44,29 @@ MimeEntryProcessor::~MimeEntryProcessor()
}
status_t
MimeEntryProcessor::DoRecursively(const entry_ref& entry)
{
bool entryIsDir = false;
status_t error = Do(entry, &entryIsDir);
if (error != B_OK)
return error;
if (entryIsDir) {
BDirectory directory;
error = directory.SetTo(&entry);
if (error != B_OK)
return error;
entry_ref childEntry;
while (directory.GetNextRef(&childEntry) == B_OK)
DoRecursively(childEntry);
}
return B_OK;
}
} // namespace Mime
} // namespace Storage
} // namespace BPrivate