* More or less reverted r24782; most ifdef's are NOT needed when running

Haiku code, they work around buggy BeOS code not present on Haiku.
* If this code turns out to be problematic under Haiku (Bruno, did your changes
  make any difference at all?), then please fix the problems in the Storage
  Kit, don't enable work-arounds for BeOS.
* Simplified the macro check as suggested by Ingo.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24790 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-04-04 11:06:33 +00:00
parent 9181e9cbcf
commit 5ebf78f405
3 changed files with 26 additions and 35 deletions
+2 -12
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006, Haiku Inc. * Copyright 2002-2008, Haiku Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -12,18 +12,8 @@
Mime type C functions implementation. Mime type C functions implementation.
*/ */
#include <Entry.h>
#include <Messenger.h>
#include <Mime.h>
#if !defined(HAIKU_HOST_PLATFORM_DANO) && !defined(HAIKU_HOST_PLATFORM_BEOS) && !defined(HAIKU_HOST_PLATFORM_BONE) && !defined(HAIKU_HOST_PLATFORM_HAIKU)
# include <MimeType.h>
#endif
#include <mime/database_access.h> #include <mime/database_access.h>
#include <mime/UpdateMimeInfoThread.h> #include <mime/UpdateMimeInfoThread.h>
#include <Node.h>
#include <unistd.h>
#include <sys/ioctl.h>
using namespace BPrivate; using namespace BPrivate;
@@ -79,7 +69,7 @@ update_mime_info(const char *path, int recursive, int synchronous, int force)
*/ */
status_t status_t
create_app_meta_mime(const char *path, int recursive, int synchronous, create_app_meta_mime(const char *path, int recursive, int synchronous,
int force) int force)
{ {
// We don't have a MIME DB... // We don't have a MIME DB...
return B_OK; return B_OK;
@@ -31,7 +31,7 @@
namespace BPrivate { namespace BPrivate {
namespace Storage { namespace Storage {
#if defined(HAIKU_HOST_PLATFORM_DANO) || defined(HAIKU_HOST_PLATFORM_BEOS) || defined(HAIKU_HOST_PLATFORM_BONE) || defined(HAIKU_HOST_PLATFORM_HAIKU) #ifdef __BEOS__
// device_is_root_device // device_is_root_device
bool bool
device_is_root_device(dev_t device) device_is_root_device(dev_t device)
@@ -52,7 +52,7 @@ namespace Mime {
If \a replyee is non-NULL and construction succeeds, the MimeThreadObject If \a replyee is non-NULL and construction succeeds, the MimeThreadObject
assumes resposibility for its deletion. assumes resposibility for its deletion.
Also, if \c non-NULL, \a replyee is expected to be a \c B_REG_MIME_UPDATE_MIME_INFO Also, if \c non-NULL, \a replyee is expected to be a \c B_REG_MIME_UPDATE_MIME_INFO
or a \c B_REG_MIME_CREATE_APP_META_MIME message with a \c true \c "synchronous" or a \c B_REG_MIME_CREATE_APP_META_MIME message with a \c true \c "synchronous"
field detached from the registrar's mime manager looper (though this is not verified). field detached from the registrar's mime manager looper (though this is not verified).
@@ -67,7 +67,7 @@ MimeUpdateThread::MimeUpdateThread(const char *name, int32 priority,
, fForce(force) , fForce(force)
, fReplyee(replyee) , fReplyee(replyee)
, fStatus(root ? B_OK : B_BAD_VALUE) , fStatus(root ? B_OK : B_BAD_VALUE)
{ {
} }
// destructor // destructor
@@ -131,7 +131,7 @@ MimeUpdateThread::ThreadFunction()
// DeviceSupportsAttributes // DeviceSupportsAttributes
/*! \brief Returns true if the given device supports attributes, false /*! \brief Returns true if the given device supports attributes, false
if not (or if an error occurs while determining). if not (or if an error occurs while determining).
Device numbers and their corresponding support info are cached in Device numbers and their corresponding support info are cached in
a std::list to save unnecessarily \c statvfs()ing devices that have a std::list to save unnecessarily \c statvfs()ing devices that have
already been statvfs()ed (which might otherwise happen quite often already been statvfs()ed (which might otherwise happen quite often
@@ -157,11 +157,11 @@ MimeUpdateThread::UpdateEntry(const entry_ref *ref)
{ {
status_t err = ref ? B_OK : B_BAD_VALUE; status_t err = ref ? B_OK : B_BAD_VALUE;
bool entryIsDir = false; bool entryIsDir = false;
// Look to see if we're being terminated // Look to see if we're being terminated
// if (!err && fShouldExit) // if (!err && fShouldExit)
// err = B_CANCELED; // err = B_CANCELED;
// Before we update, make sure this entry lives on a device that supports // Before we update, make sure this entry lives on a device that supports
// attributes. If not, we skip it and any of its children for // attributes. If not, we skip it and any of its children for
// updates (we don't signal an error, however). // updates (we don't signal an error, however).
@@ -169,18 +169,18 @@ MimeUpdateThread::UpdateEntry(const entry_ref *ref)
//BPath path(ref); //BPath path(ref);
//printf("Updating '%s' (%s)... \n", path.Path(), //printf("Updating '%s' (%s)... \n", path.Path(),
// (DeviceSupportsAttributes(ref->device) ? "yes" : "no")); // (DeviceSupportsAttributes(ref->device) ? "yes" : "no"));
if (!err if (!err
&& (device_is_root_device(ref->device) && (device_is_root_device(ref->device)
|| DeviceSupportsAttributes(ref->device))) { || DeviceSupportsAttributes(ref->device))) {
// Update this entry // Update this entry
if (!err) if (!err)
err = DoMimeUpdate(ref, &entryIsDir); err = DoMimeUpdate(ref, &entryIsDir);
// If we're recursing and this is a directory, update // If we're recursing and this is a directory, update
// each of the directory's children as well // each of the directory's children as well
if (!err && fRecursive && entryIsDir) { if (!err && fRecursive && entryIsDir) {
BDirectory dir; BDirectory dir;
err = dir.SetTo(ref); err = dir.SetTo(ref);
if (!err) { if (!err) {
entry_ref childRef; entry_ref childRef;
@@ -193,13 +193,13 @@ MimeUpdateThread::UpdateEntry(const entry_ref *ref)
err = B_OK; err = B_OK;
break; break;
} else { } else {
err = UpdateEntry(&childRef); err = UpdateEntry(&childRef);
} }
} }
} }
} }
} }
return err; return err;
} }
} // namespace Mime } // namespace Mime
@@ -24,7 +24,7 @@
#include <Resources.h> #include <Resources.h>
#include <String.h> #include <String.h>
#if !defined(HAIKU_HOST_PLATFORM_DANO) && !defined(HAIKU_HOST_PLATFORM_BEOS) && !defined(HAIKU_HOST_PLATFORM_BONE) && !defined(HAIKU_HOST_PLATFORM_HAIKU) #if !defined(__BEOS__) || defined(__HAIKU__)
# include <MimeType.h> # include <MimeType.h>
#else #else
# define B_VECTOR_ICON_TYPE 'VICN' # define B_VECTOR_ICON_TYPE 'VICN'
@@ -56,7 +56,7 @@ update_icon(BAppFileInfo &appFileInfoRead, BAppFileInfo &appFileInfoWrite,
err = appFileInfoWrite.SetIconForType(type, &icon, iconSize); err = appFileInfoWrite.SetIconForType(type, &icon, iconSize);
else if (err == B_ENTRY_NOT_FOUND || err == B_NAME_NOT_FOUND) { else if (err == B_ENTRY_NOT_FOUND || err == B_NAME_NOT_FOUND) {
err = appFileInfoWrite.SetIconForType(type, NULL, iconSize); err = appFileInfoWrite.SetIconForType(type, NULL, iconSize);
#if defined(HAIKU_HOST_PLATFORM_DANO) || defined(HAIKU_HOST_PLATFORM_BEOS) || defined(HAIKU_HOST_PLATFORM_BONE) || defined(HAIKU_HOST_PLATFORM_HAIKU) #if defined(__BEOS__) && !defined(__HAIKU__)
// gives an error if the attribute didn't exist yet... // gives an error if the attribute didn't exist yet...
err = B_OK; err = B_OK;
#endif #endif
@@ -110,7 +110,7 @@ update_vector_icon(BFile& file, const char *type)
} }
#if defined(HAIKU_HOST_PLATFORM_DANO) || defined(HAIKU_HOST_PLATFORM_BEOS) || defined(HAIKU_HOST_PLATFORM_BONE) || defined(HAIKU_HOST_PLATFORM_HAIKU) #if defined(__BEOS__) || !defined(__HAIKU__)
// BMimeType::GuessMimeType() doesn't seem to work under BeOS // BMimeType::GuessMimeType() doesn't seem to work under BeOS
status_t status_t
guess_mime_type(const void *_buffer, int32 length, BMimeType *type) guess_mime_type(const void *_buffer, int32 length, BMimeType *type)
@@ -220,7 +220,8 @@ UpdateMimeInfoThread::DoMimeUpdate(const entry_ref *entry, bool *entryIsDir)
BMimeType type; BMimeType type;
if (!err && (updateType || updateAppInfo)) { if (!err && (updateType || updateAppInfo)) {
err = BMimeType::GuessMimeType(entry, &type); err = BMimeType::GuessMimeType(entry, &type);
#if defined(HAIKU_HOST_PLATFORM_DANO) || defined(HAIKU_HOST_PLATFORM_BEOS) || defined(HAIKU_HOST_PLATFORM_BONE) || defined(HAIKU_HOST_PLATFORM_HAIKU) #if defined(__BEOS__) && !defined(__HAIKU__)
// GuessMimeType() doesn't seem to work correctly under BeOS
if (err) if (err)
err = guess_mime_type(entry, &type); err = guess_mime_type(entry, &type);
#endif #endif
@@ -261,7 +262,7 @@ UpdateMimeInfoThread::DoMimeUpdate(const entry_ref *entry, bool *entryIsDir)
else if (err == B_ENTRY_NOT_FOUND || err == B_NAME_NOT_FOUND || err == B_BAD_VALUE) { else if (err == B_ENTRY_NOT_FOUND || err == B_NAME_NOT_FOUND || err == B_BAD_VALUE) {
// BeOS returns B_BAD_VALUE on shared libraries // BeOS returns B_BAD_VALUE on shared libraries
err = appFileInfoWrite.SetSignature(NULL); err = appFileInfoWrite.SetSignature(NULL);
#if defined(HAIKU_HOST_PLATFORM_DANO) || defined(HAIKU_HOST_PLATFORM_BEOS) || defined(HAIKU_HOST_PLATFORM_BONE) || defined(HAIKU_HOST_PLATFORM_HAIKU) #if defined(__BEOS__) && !defined(__HAIKU__)
err = B_OK; err = B_OK;
#endif #endif
} }
@@ -288,7 +289,7 @@ UpdateMimeInfoThread::DoMimeUpdate(const entry_ref *entry, bool *entryIsDir)
err = appFileInfoWrite.SetSupportedTypes(&supportedTypes); err = appFileInfoWrite.SetSupportedTypes(&supportedTypes);
hasSupportedTypes = true; hasSupportedTypes = true;
} else if (err == B_ENTRY_NOT_FOUND || err == B_NAME_NOT_FOUND || err == B_BAD_VALUE) { } else if (err == B_ENTRY_NOT_FOUND || err == B_NAME_NOT_FOUND || err == B_BAD_VALUE) {
#if defined(HAIKU_HOST_PLATFORM_DANO) || defined(HAIKU_HOST_PLATFORM_BEOS) || defined(HAIKU_HOST_PLATFORM_BONE) || defined(HAIKU_HOST_PLATFORM_HAIKU) #if defined(__BEOS__) && !defined(__HAIKU__)
file.RemoveAttr(kSupportedTypesAttr); file.RemoveAttr(kSupportedTypesAttr);
err = B_OK; err = B_OK;
#else #else
@@ -333,7 +334,7 @@ UpdateMimeInfoThread::DoMimeUpdate(const entry_ref *entry, bool *entryIsDir)
if (err == B_OK) if (err == B_OK)
err = appFileInfoWrite.SetVersionInfo(&versionInfo, kind); err = appFileInfoWrite.SetVersionInfo(&versionInfo, kind);
else if (err == B_ENTRY_NOT_FOUND || err == B_NAME_NOT_FOUND || err == B_BAD_VALUE) { else if (err == B_ENTRY_NOT_FOUND || err == B_NAME_NOT_FOUND || err == B_BAD_VALUE) {
#if !defined(HAIKU_HOST_PLATFORM_DANO) && !defined(HAIKU_HOST_PLATFORM_BEOS) && !defined(HAIKU_HOST_PLATFORM_BONE) && !defined(HAIKU_HOST_PLATFORM_HAIKU) #if !defined(HAIKU_HOST_PLATFORM_DANO) && !defined(HAIKU_HOST_PLATFORM_BEOS) && !defined(HAIKU_HOST_PLATFORM_BONE)
// BeOS crashes when calling SetVersionInfo() with a NULL pointer // BeOS crashes when calling SetVersionInfo() with a NULL pointer
err = appFileInfoWrite.SetVersionInfo(NULL, kind); err = appFileInfoWrite.SetVersionInfo(NULL, kind);
#else #else
@@ -360,7 +361,7 @@ UpdateMimeInfoThread::DoMimeUpdate(const entry_ref *entry, bool *entryIsDir)
supportedType, smallIcon, B_MINI_ICON); supportedType, smallIcon, B_MINI_ICON);
if (err != B_OK) if (err != B_OK)
return err; return err;
// large icon // large icon
err = update_icon(appFileInfoRead, appFileInfoWrite, err = update_icon(appFileInfoRead, appFileInfoWrite,
supportedType, largeIcon, B_LARGE_ICON); supportedType, largeIcon, B_LARGE_ICON);