misc/libphysfs/platform_beos.cpp
author nemo
Fri, 29 Mar 2013 10:54:12 -0400
changeset 8818 8f317ba10675
parent 8524 a65e9bcf0a03
child 12213 bb5522e88ab2
permissions -rw-r--r--
This should ensure rope can still be aimed quickly when an alt weapon is active.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     1
/*
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     2
 * BeOS platform-dependent support routines for PhysicsFS.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     3
 *
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     4
 * Please see the file LICENSE.txt in the source's root directory.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     5
 *
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     6
 *  This file written by Ryan C. Gordon.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     7
 */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     8
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     9
#define __PHYSICSFS_INTERNAL__
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    10
#include "physfs_platforms.h"
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    11
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    12
#ifdef PHYSFS_PLATFORM_BEOS
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    13
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    14
#ifdef PHYSFS_PLATFORM_HAIKU
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    15
#include <os/kernel/OS.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    16
#include <os/app/Roster.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    17
#include <os/storage/Volume.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    18
#include <os/storage/VolumeRoster.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    19
#include <os/storage/Directory.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    20
#include <os/storage/Entry.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    21
#include <os/storage/Path.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    22
#include <os/kernel/fs_info.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    23
#include <os/device/scsi.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    24
#include <os/support/Locker.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    25
#else
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    26
#include <be/kernel/OS.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    27
#include <be/app/Roster.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    28
#include <be/storage/Volume.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    29
#include <be/storage/VolumeRoster.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    30
#include <be/storage/Directory.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    31
#include <be/storage/Entry.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    32
#include <be/storage/Path.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    33
#include <be/kernel/fs_info.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    34
#include <be/device/scsi.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    35
#include <be/support/Locker.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    36
#endif
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    37
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    38
#include <errno.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    39
#include <unistd.h>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    40
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    41
#include "physfs_internal.h"
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    42
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    43
int __PHYSFS_platformInit(void)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    44
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    45
    return 1;  /* always succeed. */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    46
} /* __PHYSFS_platformInit */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    47
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    48
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    49
int __PHYSFS_platformDeinit(void)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    50
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    51
    return 1;  /* always succeed. */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    52
} /* __PHYSFS_platformDeinit */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    53
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    54
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    55
static char *getMountPoint(const char *devname, char *buf, size_t bufsize)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    56
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    57
    BVolumeRoster mounts;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    58
    BVolume vol;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    59
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    60
    mounts.Rewind();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    61
    while (mounts.GetNextVolume(&vol) == B_NO_ERROR)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    62
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    63
        fs_info fsinfo;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    64
        fs_stat_dev(vol.Device(), &fsinfo);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    65
        if (strcmp(devname, fsinfo.device_name) == 0)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    66
        {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    67
            BDirectory directory;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    68
            BEntry entry;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    69
            BPath path;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    70
            const char *str;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    71
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    72
            if ( (vol.GetRootDirectory(&directory) < B_OK) ||
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    73
                 (directory.GetEntry(&entry) < B_OK) ||
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    74
                 (entry.GetPath(&path) < B_OK) ||
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    75
                 ( (str = path.Path()) == NULL) )
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    76
                return NULL;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    77
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    78
            strncpy(buf, str, bufsize-1);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    79
            buf[bufsize-1] = '\0';
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    80
            return buf;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    81
        } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    82
    } /* while */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    83
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    84
    return NULL;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    85
} /* getMountPoint */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    86
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    87
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    88
    /*
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    89
     * This function is lifted from Simple Directmedia Layer (SDL):
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    90
     *  http://www.libsdl.org/  ... this is zlib-licensed code, too.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    91
     */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    92
static void tryDir(const char *d, PHYSFS_StringCallback callback, void *data)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    93
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    94
    BDirectory dir;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    95
    dir.SetTo(d);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    96
    if (dir.InitCheck() != B_NO_ERROR)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    97
        return;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    98
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    99
    dir.Rewind();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   100
    BEntry entry;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   101
    while (dir.GetNextEntry(&entry) >= 0)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   102
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   103
        BPath path;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   104
        const char *name;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   105
        entry_ref e;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   106
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   107
        if (entry.GetPath(&path) != B_NO_ERROR)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   108
            continue;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   109
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   110
        name = path.Path();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   111
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   112
        if (entry.GetRef(&e) != B_NO_ERROR)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   113
            continue;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   114
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   115
        if (entry.IsDirectory())
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   116
        {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   117
            if (strcmp(e.name, "floppy") != 0)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   118
                tryDir(name, callback, data);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   119
            continue;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   120
        } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   121
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   122
        if (strcmp(e.name, "raw") != 0)  /* ignore partitions. */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   123
            continue;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   124
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   125
        const int devfd = open(name, O_RDONLY);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   126
        if (devfd < 0)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   127
            continue;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   128
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   129
        device_geometry g;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   130
        const int rc = ioctl(devfd, B_GET_GEOMETRY, &g, sizeof (g));
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   131
        close(devfd);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   132
        if (rc < 0)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   133
            continue;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   134
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   135
        if (g.device_type != B_CD)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   136
            continue;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   137
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   138
        char mntpnt[B_FILE_NAME_LENGTH];
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   139
        if (getMountPoint(name, mntpnt, sizeof (mntpnt)))
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   140
            callback(data, mntpnt);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   141
    } /* while */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   142
} /* tryDir */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   143
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   144
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   145
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   146
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   147
    tryDir("/dev/disk", cb, data);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   148
} /* __PHYSFS_platformDetectAvailableCDs */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   149
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   150
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   151
static team_id getTeamID(void)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   152
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   153
    thread_info info;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   154
    thread_id tid = find_thread(NULL);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   155
    get_thread_info(tid, &info);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   156
    return info.team;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   157
} /* getTeamID */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   158
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   159
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   160
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   161
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   162
    image_info info;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   163
    int32 cookie = 0;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   164
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   165
    while (get_next_image_info(0, &cookie, &info) == B_OK)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   166
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   167
        if (info.type == B_APP_IMAGE)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   168
            break;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   169
    } /* while */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   170
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   171
    BEntry entry(info.name, true);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   172
    BPath path;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   173
    status_t rc = entry.GetPath(&path);  /* (path) now has binary's path. */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   174
    assert(rc == B_OK);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   175
    rc = path.GetParent(&path); /* chop filename, keep directory. */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   176
    assert(rc == B_OK);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   177
    const char *str = path.Path();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   178
    assert(str != NULL);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   179
    const size_t len = strlen(str);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   180
    char *retval = (char *) allocator.Malloc(len + 2);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   181
    BAIL_IF_MACRO(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   182
    strcpy(retval, str);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   183
    retval[len] = '/';
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   184
    retval[len+1] = '\0';
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   185
    return retval;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   186
} /* __PHYSFS_platformCalcBaseDir */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   187
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   188
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   189
char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   190
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   191
    const char *userdir = __PHYSFS_getUserDir();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   192
    const char *append = "config/settings/";
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   193
    const size_t len = strlen(userdir) + strlen(append) + strlen(app) + 2;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   194
    char *retval = allocator.Malloc(len);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   195
    BAIL_IF_MACRO(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   196
    snprintf(retval, len, "%s%s%s/", userdir, append, app);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   197
    return retval;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   198
} /* __PHYSFS_platformCalcPrefDir */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   199
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   200
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   201
void *__PHYSFS_platformGetThreadID(void)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   202
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   203
    return (void *) find_thread(NULL);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   204
} /* __PHYSFS_platformGetThreadID */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   205
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   206
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   207
void *__PHYSFS_platformCreateMutex(void)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   208
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   209
    return new BLocker("PhysicsFS lock", true);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   210
} /* __PHYSFS_platformCreateMutex */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   211
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   212
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   213
void __PHYSFS_platformDestroyMutex(void *mutex)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   214
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   215
    delete ((BLocker *) mutex);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   216
} /* __PHYSFS_platformDestroyMutex */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   217
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   218
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   219
int __PHYSFS_platformGrabMutex(void *mutex)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   220
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   221
    return ((BLocker *) mutex)->Lock() ? 1 : 0;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   222
} /* __PHYSFS_platformGrabMutex */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   223
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   224
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   225
void __PHYSFS_platformReleaseMutex(void *mutex)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   226
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   227
    ((BLocker *) mutex)->Unlock();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   228
} /* __PHYSFS_platformReleaseMutex */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   229
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   230
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   231
int __PHYSFS_platformSetDefaultAllocator(PHYSFS_Allocator *a)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   232
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   233
    return 0;  /* just use malloc() and friends. */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   234
} /* __PHYSFS_platformSetDefaultAllocator */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   235
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   236
#endif  /* PHYSFS_PLATFORM_BEOS */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   237
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   238
/* end of beos.cpp ... */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   239