src/physfs_platform_qnx.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 17 May 2020 01:41:52 -0400
changeset 1691 c66c9326b05d
parent 1588 59a7ec36bd8c
permissions -rw-r--r--
7z: Make error handling a little more robust.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1588
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/*
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * QNX support routines for PhysicsFS.
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 *
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
 * Please see the file LICENSE.txt in the source's root directory.
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
 *
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
 *  This file written by Ryan C. Gordon.
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
 */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
/* This is tested against QNX 7 at the moment. */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
#define __PHYSICSFS_INTERNAL__
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
#include "physfs_platforms.h"
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
#ifdef PHYSFS_PLATFORM_QNX
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
#include <fcntl.h>
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
#include <unistd.h>
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
#include <sys/types.h>
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
#include <limits.h>
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
#include "physfs_internal.h"
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
int __PHYSFS_platformInit(void)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
{
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
    return 1;  /* always succeed. */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
} /* __PHYSFS_platformInit */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
void __PHYSFS_platformDeinit(void)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
{
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
    /* no-op */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
} /* __PHYSFS_platformDeinit */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
{
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
    char *retval = (char *) allocator.Malloc(PATH_MAX+1);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
    if (retval == NULL)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
        BAIL(PHYSFS_ERR_OUT_OF_MEMORY, NULL);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
    else
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
    {
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
        const int fd = open("/proc/self/exefile", O_RDONLY);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
        const ssize_t br = (fd == -1) ? -1 : read(fd, retval, PATH_MAX);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
        char *ptr;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
        if (fd != -1)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
            close(fd);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
        if ((br < 0) || (br > PATH_MAX))
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
        {
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
            allocator.Free(retval);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
            BAIL(PHYSFS_ERR_OS_ERROR, NULL);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
        } /* if */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
        retval[br] = '\0';
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
        ptr = strrchr(retval, '/');
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
        if (ptr == NULL)  /* uhoh! */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
        {
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
            allocator.Free(retval);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
            BAIL(PHYSFS_ERR_OS_ERROR, NULL);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
        } /* if */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
        ptr[1] = '\0';  /* chop off filename, leave dirs and '/' */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
        ptr = (char *) allocator.Realloc(retval, (ptr - retval) + 2);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
        if (ptr != NULL)  /* just shrinking buffer; don't care if it failed. */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
            retval = ptr;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
    } /* else */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
    return retval;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
} /* __PHYSFS_platformCalcBaseDir */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
{
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
    /* !!! FIXME: this might be wrong; I don't know if there's a better method
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
        on QNX, or if it follows XDG specs, etc. */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
    char *retval = NULL;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
    const char *home = __PHYSFS_getUserDir();
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
    if (home)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
    {
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
        const size_t len = strlen(home) + strlen(app) + 3;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
        retval = (char *) allocator.Malloc(len);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
        BAIL_IF(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
        snprintf(retval, len, "%s.%s/", home, app);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
    } /* if */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
    return retval;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
} /* __PHYSFS_platformCalcPrefDir */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
#if !PHYSFS_NO_CDROM_SUPPORT
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
#include <devctl.h>
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
#include <sys/dcmd_blk.h>
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
#include <dirent.h>
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
#include <sys/stat.h>
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
#include <sys/statvfs.h>
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
static void checkPathForCD(const char *path, PHYSFS_StringCallback cb, void *d)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
{
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
    struct stat statbuf;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
    int fd;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
    /* The devctl() thing is QNX-specific. In this case, we query what is
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
       probably the mountpoint for the device. statvfs() on that mountpoint
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
       will tell use its filesystem type. */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
    if ( (stat(path, &statbuf) == 0) &&
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
         (S_ISBLK(statbuf.st_mode)) &&
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
         ((fd = open(path, O_RDONLY | O_NONBLOCK)) != -1) )
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
    {
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
        char mnt[256] = { 0 };
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
        const int rc = devctl(fd, DCMD_FSYS_MOUNTED_BY, mnt, sizeof (mnt), 0);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
        close(fd);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
        if ( (rc == EOK) && (mnt[0]) )
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
        {
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
            struct statvfs statvfsbuf;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
            if (statvfs(mnt, &statvfsbuf) == 0)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
            {
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
                /* I don't know if this is a complete or accurate list. */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
                const char *fstype = statvfsbuf.f_basetype;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
                const int iscd = ( (strcmp(fstype, "cd") == 0) ||
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
                                   (strcmp(fstype, "udf") == 0) );
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
                if (iscd)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   124
                    cb(d, mnt);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
            } /* if */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   126
        } /* if */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
    } /* if */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
} /* checkPathForCD */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
static void checkDevForCD(const char *dev, PHYSFS_StringCallback cb, void *d)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
{
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
    size_t len;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
    char *path;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
    if (dev[0] == '.')  /* ignore "." and ".." */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
    {
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
        if ((dev[1] == '\0') || ((dev[1] == '.') && (dev[2] == '\0')))
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
            return;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   139
    } /* if */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
    len = strlen(dev) + 6;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   142
    path = (char *) __PHYSFS_smallAlloc(len);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
    if (!path)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
        return;  /* oh well. */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   145
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
    snprintf(path, len, "/dev/%s", dev);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   147
    checkPathForCD(path, cb, d);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   148
    __PHYSFS_smallFree(path);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
} /* checkDevForCD */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   150
#endif /* !PHYSFS_NO_CDROM_SUPPORT */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   151
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   152
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   153
{
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
#if !PHYSFS_NO_CDROM_SUPPORT
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   155
    DIR *dirp = opendir("/dev");
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   156
    if (dirp)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
    {
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   158
        struct dirent *dent;
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   159
        while ((dent = readdir(dirp)) != NULL)
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   160
            checkDevForCD(dent->d_name, cb, data);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   161
        closedir(dirp);
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   162
    } /* if */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
#endif
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   164
} /* __PHYSFS_platformDetectAvailableCDs */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
#endif /* PHYSFS_PLATFORM_QNX */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   168
/* end of physfs_platform_qnx.c ... */
59a7ec36bd8c qnx: Added more proper support for QNX.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169