* 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
+1 -11
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;
@@ -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)
@@ -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