MimeEntryProcessor: Add DoRecursively()
While Do() only process the specified entry, DoRecursively() also recurses into directories.
This commit is contained in:
parent
f132bdfe9f
commit
5fb3348319
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user