mimeset: Complete custom mime DB support
* Don't require the first MIME DB directory to exist anymore. Database creates it anyway. * Make use of MimeInfoUpdater to support updating MIME info with a custom MIME DB. * Make use of MimeEntryProcessor::DoRecursively() to support recursive operation with a custom MIME DB.
This commit is contained in:
+15
-14
@@ -16,6 +16,7 @@
|
|||||||
#include <mime/AppMetaMimeCreator.h>
|
#include <mime/AppMetaMimeCreator.h>
|
||||||
#include <mime/Database.h>
|
#include <mime/Database.h>
|
||||||
#include <mime/DatabaseLocation.h>
|
#include <mime/DatabaseLocation.h>
|
||||||
|
#include <mime/MimeInfoUpdater.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace BPrivate::Storage::Mime;
|
using namespace BPrivate::Storage::Mime;
|
||||||
@@ -78,15 +79,23 @@ usage(int status)
|
|||||||
static status_t
|
static status_t
|
||||||
process_file_with_custom_mime_db(const BEntry& entry)
|
process_file_with_custom_mime_db(const BEntry& entry)
|
||||||
{
|
{
|
||||||
// TODO: Support recursion!
|
AppMetaMimeCreator appMetaMimeCreator(sDatabase, NULL, gForce);
|
||||||
// TODO: Support MIME update!
|
MimeInfoUpdater mimeInfoUpdater(sDatabase, NULL, gForce);
|
||||||
AppMetaMimeCreator creator(sDatabase, NULL, gForce);
|
|
||||||
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
status_t error = entry.GetRef(&ref);
|
status_t error = entry.GetRef(&ref);
|
||||||
bool entryIsDir = false;
|
|
||||||
if (error == B_OK)
|
if (gFiles && error == B_OK)
|
||||||
error = creator.Do(ref, &entryIsDir);
|
error = mimeInfoUpdater.DoRecursively(ref);
|
||||||
|
if (gApps && error == B_OK) {
|
||||||
|
error = appMetaMimeCreator.DoRecursively(ref);
|
||||||
|
if (error == B_BAD_TYPE) {
|
||||||
|
// Ignore B_BAD_TYPE silently. The most likely cause is that the
|
||||||
|
// file doesn't have a "BEOS:APP_SIG" attribute.
|
||||||
|
error = B_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
BPath path;
|
BPath path;
|
||||||
fprintf(stderr, "%s: \"%s\": %s\n",
|
fprintf(stderr, "%s: \"%s\": %s\n",
|
||||||
@@ -191,14 +200,6 @@ main(int argc, const char** argv)
|
|||||||
// set up custom MIME DB, if specified
|
// set up custom MIME DB, if specified
|
||||||
DatabaseLocation databaseLocation;
|
DatabaseLocation databaseLocation;
|
||||||
if (!databaseDirectories.IsEmpty()) {
|
if (!databaseDirectories.IsEmpty()) {
|
||||||
// the first directory must exist
|
|
||||||
if (!BEntry(databaseDirectories.StringAt(0)).IsDirectory()) {
|
|
||||||
fprintf(stderr, "%s: Specified path \"%s\" doesn't exist or isn't "
|
|
||||||
"a directory.", sProgramName,
|
|
||||||
databaseDirectories.StringAt(0).String());
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 count = databaseDirectories.CountStrings();
|
int32 count = databaseDirectories.CountStrings();
|
||||||
for (int32 i = 0; i < count; i++)
|
for (int32 i = 0; i < count; i++)
|
||||||
databaseLocation.AddDirectory(databaseDirectories.StringAt(i));
|
databaseLocation.AddDirectory(databaseDirectories.StringAt(i));
|
||||||
|
|||||||
Reference in New Issue
Block a user