* 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.
*
* Authors:
@@ -12,18 +12,8 @@
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/UpdateMimeInfoThread.h>
#include <Node.h>
#include <unistd.h>
#include <sys/ioctl.h>
using namespace BPrivate;
@@ -79,7 +69,7 @@ update_mime_info(const char *path, int recursive, int synchronous, int force)
*/
status_t
create_app_meta_mime(const char *path, int recursive, int synchronous,
int force)
int force)
{
// We don't have a MIME DB...
return B_OK;
@@ -31,7 +31,7 @@
namespace BPrivate {
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
bool
device_is_root_device(dev_t device)
@@ -52,7 +52,7 @@ namespace Mime {
If \a replyee is non-NULL and construction succeeds, the MimeThreadObject
assumes resposibility for its deletion.
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"
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)
, fReplyee(replyee)
, fStatus(root ? B_OK : B_BAD_VALUE)
{
{
}
// destructor
@@ -131,7 +131,7 @@ MimeUpdateThread::ThreadFunction()
// DeviceSupportsAttributes
/*! \brief Returns true if the given device supports attributes, false
if not (or if an error occurs while determining).
Device numbers and their corresponding support info are cached in
a std::list to save unnecessarily \c statvfs()ing devices that have
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;
bool entryIsDir = false;
// Look to see if we're being terminated
// if (!err && fShouldExit)
// err = B_CANCELED;
// 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
// updates (we don't signal an error, however).
@@ -169,18 +169,18 @@ MimeUpdateThread::UpdateEntry(const entry_ref *ref)
//BPath path(ref);
//printf("Updating '%s' (%s)... \n", path.Path(),
// (DeviceSupportsAttributes(ref->device) ? "yes" : "no"));
if (!err
&& (device_is_root_device(ref->device)
|| DeviceSupportsAttributes(ref->device))) {
|| DeviceSupportsAttributes(ref->device))) {
// Update this entry
if (!err)
err = DoMimeUpdate(ref, &entryIsDir);
// If we're recursing and this is a directory, update
// each of the directory's children as well
if (!err && fRecursive && entryIsDir) {
BDirectory dir;
if (!err && fRecursive && entryIsDir) {
BDirectory dir;
err = dir.SetTo(ref);
if (!err) {
entry_ref childRef;
@@ -193,13 +193,13 @@ MimeUpdateThread::UpdateEntry(const entry_ref *ref)
err = B_OK;
break;
} else {
err = UpdateEntry(&childRef);
}
}
}
err = UpdateEntry(&childRef);
}
}
}
}
}
return err;
return err;
}
} // namespace Mime
@@ -24,7 +24,7 @@
#include <Resources.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>
#else
# define B_VECTOR_ICON_TYPE 'VICN'
@@ -56,7 +56,7 @@ update_icon(BAppFileInfo &appFileInfoRead, BAppFileInfo &appFileInfoWrite,
err = appFileInfoWrite.SetIconForType(type, &icon, iconSize);
else if (err == B_ENTRY_NOT_FOUND || err == B_NAME_NOT_FOUND) {
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...
err = B_OK;
#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
status_t
guess_mime_type(const void *_buffer, int32 length, BMimeType *type)
@@ -220,7 +220,8 @@ UpdateMimeInfoThread::DoMimeUpdate(const entry_ref *entry, bool *entryIsDir)
BMimeType type;
if (!err && (updateType || updateAppInfo)) {
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)
err = guess_mime_type(entry, &type);
#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) {
// BeOS returns B_BAD_VALUE on shared libraries
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;
#endif
}
@@ -288,7 +289,7 @@ UpdateMimeInfoThread::DoMimeUpdate(const entry_ref *entry, bool *entryIsDir)
err = appFileInfoWrite.SetSupportedTypes(&supportedTypes);
hasSupportedTypes = true;
} 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);
err = B_OK;
#else
@@ -333,7 +334,7 @@ UpdateMimeInfoThread::DoMimeUpdate(const entry_ref *entry, bool *entryIsDir)
if (err == B_OK)
err = appFileInfoWrite.SetVersionInfo(&versionInfo, kind);
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
err = appFileInfoWrite.SetVersionInfo(NULL, kind);
#else
@@ -360,7 +361,7 @@ UpdateMimeInfoThread::DoMimeUpdate(const entry_ref *entry, bool *entryIsDir)
supportedType, smallIcon, B_MINI_ICON);
if (err != B_OK)
return err;
// large icon
err = update_icon(appFileInfoRead, appFileInfoWrite,
supportedType, largeIcon, B_LARGE_ICON);