MimeEntryProcessor: Add DoRecursively()
While Do() only process the specified entry, DoRecursively() also recurses into directories.
This commit is contained in:
@@ -36,6 +36,8 @@ public:
|
|||||||
virtual status_t Do(const entry_ref& entry, bool* _entryIsDir)
|
virtual status_t Do(const entry_ref& entry, bool* _entryIsDir)
|
||||||
= 0;
|
= 0;
|
||||||
|
|
||||||
|
status_t DoRecursively(const entry_ref& entry);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Database* fDatabase;
|
Database* fDatabase;
|
||||||
DatabaseLocker* fDatabaseLocker;
|
DatabaseLocker* fDatabaseLocker;
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
|
|
||||||
#include <mime/AppMetaMimeCreator.h>
|
#include <mime/AppMetaMimeCreator.h>
|
||||||
|
|
||||||
|
#include <Directory.h>
|
||||||
|
#include <Entry.h>
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
namespace Storage {
|
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 Mime
|
||||||
} // namespace Storage
|
} // namespace Storage
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|||||||
Reference in New Issue
Block a user