src/platform_posix.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 22 Jun 2011 15:56:10 -0400
changeset 1167 9d84f8652839
parent 1129 d81afe4b0a97
child 1173 77b2df665bd1
permissions -rw-r--r--
POSIX version of __PHYSFS_platformStat() forgot to set *exists properly. Thanks to Frank Becker for the fix.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/*
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * Posix-esque support routines for PhysicsFS.
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 *
809
116b8fe30371 Renamed LICENSE to LICENSE.txt
Ryan C. Gordon <icculus@icculus.org>
parents: 808
diff changeset
     4
 * Please see the file LICENSE.txt in the source's root directory.
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
 *
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
 *  This file written by Ryan C. Gordon.
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
 */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
818
e36f23f49042 Now compiles everything whether we need it or not, removing whole files with
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
     9
#define __PHYSICSFS_INTERNAL__
e36f23f49042 Now compiles everything whether we need it or not, removing whole files with
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
    10
#include "physfs_platforms.h"
e36f23f49042 Now compiles everything whether we need it or not, removing whole files with
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
    11
e36f23f49042 Now compiles everything whether we need it or not, removing whole files with
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
    12
#ifdef PHYSFS_PLATFORM_POSIX
310
f8bca4a93fd5 Patched to compile on Cygwin.
Ryan C. Gordon <icculus@icculus.org>
parents: 292
diff changeset
    13
251
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
    14
#include <unistd.h>
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
#include <ctype.h>
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
#include <sys/types.h>
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
#include <sys/stat.h>
251
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
    18
#include <pwd.h>
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
#include <dirent.h>
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
#include <errno.h>
251
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
    21
#include <fcntl.h>
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
259
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
    23
#ifdef PHYSFS_HAVE_LLSEEK
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
    24
#include <linux/unistd.h>
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
    25
#endif
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
    26
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
#include "physfs_internal.h"
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
847
5e5e6c067413 Split out Mac OS X code from unix.c and added some Carbon-specific code...
Ryan C. Gordon <icculus@icculus.org>
parents: 845
diff changeset
    30
const char *__PHYSFS_platformDirSeparator = "/";
5e5e6c067413 Split out Mac OS X code from unix.c and added some Carbon-specific code...
Ryan C. Gordon <icculus@icculus.org>
parents: 845
diff changeset
    31
5e5e6c067413 Split out Mac OS X code from unix.c and added some Carbon-specific code...
Ryan C. Gordon <icculus@icculus.org>
parents: 845
diff changeset
    32
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
char *__PHYSFS_platformCopyEnvironmentVariable(const char *varname)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
{
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
    const char *envr = getenv(varname);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
    char *retval = NULL;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
    if (envr != NULL)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
    {
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
    40
        retval = (char *) allocator.Malloc(strlen(envr) + 1);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
        if (retval != NULL)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
            strcpy(retval, envr);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
    } /* if */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
    45
    return retval;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
} /* __PHYSFS_platformCopyEnvironmentVariable */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
static char *getUserNameByUID(void)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
{
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
    uid_t uid = getuid();
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
    struct passwd *pw;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
    char *retval = NULL;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
    pw = getpwuid(uid);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
    if ((pw != NULL) && (pw->pw_name != NULL))
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
    {
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
    58
        retval = (char *) allocator.Malloc(strlen(pw->pw_name) + 1);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
        if (retval != NULL)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
            strcpy(retval, pw->pw_name);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
    } /* if */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
    
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
    63
    return retval;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
} /* getUserNameByUID */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
static char *getUserDirByUID(void)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
{
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
    uid_t uid = getuid();
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
    struct passwd *pw;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
    char *retval = NULL;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
    pw = getpwuid(uid);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
    if ((pw != NULL) && (pw->pw_dir != NULL))
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
    {
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
    76
        retval = (char *) allocator.Malloc(strlen(pw->pw_dir) + 1);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
        if (retval != NULL)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
            strcpy(retval, pw->pw_dir);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
    } /* if */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
    
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
    81
    return retval;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
} /* getUserDirByUID */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
char *__PHYSFS_platformGetUserName(void)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
{
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
    char *retval = getUserNameByUID();
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
    if (retval == NULL)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
        retval = __PHYSFS_platformCopyEnvironmentVariable("USER");
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
    90
    return retval;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
} /* __PHYSFS_platformGetUserName */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
char *__PHYSFS_platformGetUserDir(void)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
{
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
    char *retval = __PHYSFS_platformCopyEnvironmentVariable("HOME");
1073
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
    97
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
    98
    /* if the environment variable was set, make sure it's really a dir. */
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
    99
    if (retval != NULL)
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
   100
    {
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
   101
        struct stat statbuf;
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
   102
        if ((stat(retval, &statbuf) == -1) || (S_ISDIR(statbuf.st_mode) == 0))
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
   103
        {
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
   104
            allocator.Free(retval);
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
   105
            retval = NULL;
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
   106
        } /* if */
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
   107
    } /* if */
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
   108
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
    if (retval == NULL)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
        retval = getUserDirByUID();
1073
b45193ab2033 See if $HOME is bogus, and if so, use getpwuid() instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
   111
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   112
    return retval;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
} /* __PHYSFS_platformGetUserDir */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
char *__PHYSFS_platformCvtToDependent(const char *prepend,
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
                                      const char *dirName,
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
                                      const char *append)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
{
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
    int len = ((prepend) ? strlen(prepend) : 0) +
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
              ((append) ? strlen(append) : 0) +
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
              strlen(dirName) + 1;
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   123
    char *retval = (char *) allocator.Malloc(len);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   124
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   126
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
    /* platform-independent notation is Unix-style already.  :)  */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
    if (prepend)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
        strcpy(retval, prepend);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
    else
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
        retval[0] = '\0';
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
    strcat(retval, dirName);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
    if (append)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
        strcat(retval, append);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   139
    return retval;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
} /* __PHYSFS_platformCvtToDependent */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   142
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   144
void __PHYSFS_platformEnumerateFiles(const char *dirname,
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   145
                                     int omitSymLinks,
754
e7cd7411eadf API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents: 747
diff changeset
   146
                                     PHYSFS_EnumFilesCallback callback,
e7cd7411eadf API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents: 747
diff changeset
   147
                                     const char *origdir,
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   148
                                     void *callbackdata)
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
{
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   150
    DIR *dir;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   151
    struct dirent *ent;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   152
    int bufsize = 0;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   153
    char *buf = NULL;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
    int dlen = 0;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   155
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   156
    if (omitSymLinks)  /* !!! FIXME: this malloc sucks. */
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
    {
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   158
        dlen = strlen(dirname);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   159
        bufsize = dlen + 256;
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   160
        buf = (char *) allocator.Malloc(bufsize);
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   161
        if (buf == NULL)
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   162
            return;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
        strcpy(buf, dirname);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   164
        if (buf[dlen - 1] != '/')
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
        {
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
            buf[dlen++] = '/';
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
            buf[dlen] = '\0';
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   168
        } /* if */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169
    } /* if */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   170
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   171
    errno = 0;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
    dir = opendir(dirname);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
    if (dir == NULL)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
    {
852
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 847
diff changeset
   175
        allocator.Free(buf);
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   176
        return;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
    } /* if */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178
362
ac8c846a0a66 Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents: 310
diff changeset
   179
    while ((ent = readdir(dir)) != NULL)
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   180
    {
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   181
        if (strcmp(ent->d_name, ".") == 0)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   182
            continue;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   183
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   184
        if (strcmp(ent->d_name, "..") == 0)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   185
            continue;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   186
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   187
        if (omitSymLinks)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   188
        {
1125
bcff76dbd9fd Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   189
            PHYSFS_Stat statbuf;
bcff76dbd9fd Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   190
            int exists = 0;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   191
            char *p;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   192
            int len = strlen(ent->d_name) + dlen + 1;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
            if (len > bufsize)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   194
            {
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   195
                p = (char *) allocator.Realloc(buf, len);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   196
                if (p == NULL)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
                    continue;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   198
                buf = p;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   199
                bufsize = len;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   200
            } /* if */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   201
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   202
            strcpy(buf + dlen, ent->d_name);
1125
bcff76dbd9fd Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   203
bcff76dbd9fd Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   204
            if (__PHYSFS_platformStat(buf, &exists, &statbuf))
bcff76dbd9fd Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   205
            {
bcff76dbd9fd Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   206
                if (!exists)
bcff76dbd9fd Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   207
                    continue;
bcff76dbd9fd Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   208
                else if (statbuf.filetype == PHYSFS_FILETYPE_SYMLINK)
bcff76dbd9fd Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   209
                    continue;
bcff76dbd9fd Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   210
            } /* if */
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   211
        } /* if */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   212
754
e7cd7411eadf API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents: 747
diff changeset
   213
        callback(callbackdata, origdir, ent->d_name);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   214
    } /* while */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   215
852
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 847
diff changeset
   216
    allocator.Free(buf);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   217
    closedir(dir);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   218
} /* __PHYSFS_platformEnumerateFiles */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   219
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   220
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   221
int __PHYSFS_platformMkDir(const char *path)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   222
{
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   223
    int rc;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   224
    errno = 0;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   225
    rc = mkdir(path, S_IRWXU);
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   226
    BAIL_IF_MACRO(rc == -1, strerror(errno), 0);
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   227
    return 1;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   228
} /* __PHYSFS_platformMkDir */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   229
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   230
251
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   231
static void *doOpen(const char *filename, int mode)
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   232
{
939
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   233
    const int appending = (mode & O_APPEND);
251
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   234
    int fd;
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   235
    int *retval;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   236
    errno = 0;
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   237
939
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   238
    /* O_APPEND doesn't actually behave as we'd like. */
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   239
    mode &= ~O_APPEND;
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   240
251
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   241
    fd = open(filename, mode, S_IRUSR | S_IWUSR);
292
99bf6ef5639a Patched a bug where doOpen() reported success when the file couldn't be
Ryan C. Gordon <icculus@icculus.org>
parents: 259
diff changeset
   242
    BAIL_IF_MACRO(fd < 0, strerror(errno), NULL);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   243
939
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   244
    if (appending)
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   245
    {
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   246
        if (lseek(fd, 0, SEEK_END) < 0)
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   247
        {
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   248
            close(fd);
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   249
            BAIL_MACRO(strerror(errno), NULL);
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   250
        } /* if */
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   251
    } /* if */
684c583cb586 Fixed PHYSFS_openAppend() on Unix.
Ryan C. Gordon <icculus@icculus.org>
parents: 852
diff changeset
   252
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   253
    retval = (int *) allocator.Malloc(sizeof (int));
251
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   254
    if (retval == NULL)
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   255
    {
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   256
        close(fd);
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   257
        BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   258
    } /* if */
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   259
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   260
    *retval = fd;
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   261
    return ((void *) retval);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   262
} /* doOpen */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   263
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   264
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   265
void *__PHYSFS_platformOpenRead(const char *filename)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   266
{
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   267
    return doOpen(filename, O_RDONLY);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   268
} /* __PHYSFS_platformOpenRead */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   269
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   270
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   271
void *__PHYSFS_platformOpenWrite(const char *filename)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   272
{
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   273
    return doOpen(filename, O_WRONLY | O_CREAT | O_TRUNC);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   274
} /* __PHYSFS_platformOpenWrite */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   275
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   276
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   277
void *__PHYSFS_platformOpenAppend(const char *filename)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   278
{
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   279
    return doOpen(filename, O_WRONLY | O_CREAT | O_APPEND);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   280
} /* __PHYSFS_platformOpenAppend */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   281
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   282
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   283
PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer,
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   284
                                    PHYSFS_uint64 len)
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   285
{
1117
968e1567f4f4 Constification.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   286
    const int fd = *((int *) opaque);
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   287
    ssize_t rc = 0;
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   288
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   289
    BAIL_IF_MACRO(!__PHYSFS_ui64FitsAddressSpace(len),ERR_INVALID_ARGUMENT,-1);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   290
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   291
    rc = read(fd, buffer, (size_t) len);
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   292
    BAIL_IF_MACRO(rc == -1, strerror(errno), (PHYSFS_sint64) rc);
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   293
    assert(rc >= 0);
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   294
    assert(rc <= len);
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   295
    return (PHYSFS_sint64) rc;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   296
} /* __PHYSFS_platformRead */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   297
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   298
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   299
PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer,
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   300
                                     PHYSFS_uint64 len)
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   301
{
1117
968e1567f4f4 Constification.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   302
    const int fd = *((int *) opaque);
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   303
    ssize_t rc = 0;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   304
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   305
    BAIL_IF_MACRO(!__PHYSFS_ui64FitsAddressSpace(len),ERR_INVALID_ARGUMENT,-1);
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   306
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   307
    rc = write(fd, (void *) buffer, (size_t) len);
251
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   308
    BAIL_IF_MACRO(rc == -1, strerror(errno), rc);
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   309
    assert(rc >= 0);
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   310
    assert(rc <= len);
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1073
diff changeset
   311
    return (PHYSFS_sint64) rc;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   312
} /* __PHYSFS_platformWrite */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   313
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   314
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   315
int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   316
{
1117
968e1567f4f4 Constification.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   317
    const int fd = *((int *) opaque);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   318
259
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   319
    #ifdef PHYSFS_HAVE_LLSEEK
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   320
      unsigned long offset_high = ((pos >> 32) & 0xFFFFFFFF);
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   321
      unsigned long offset_low = (pos & 0xFFFFFFFF);
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   322
      loff_t retoffset;
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   323
      int rc = llseek(fd, offset_high, offset_low, &retoffset, SEEK_SET);
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   324
      BAIL_IF_MACRO(rc == -1, strerror(errno), 0);
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   325
    #else
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   326
      BAIL_IF_MACRO(lseek(fd, (int) pos, SEEK_SET) == -1, strerror(errno), 0);
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   327
    #endif
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   328
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   329
    return 1;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   330
} /* __PHYSFS_platformSeek */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   331
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   332
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   333
PHYSFS_sint64 __PHYSFS_platformTell(void *opaque)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   334
{
1117
968e1567f4f4 Constification.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   335
    const int fd = *((int *) opaque);
259
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   336
    PHYSFS_sint64 retval;
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   337
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   338
    #ifdef PHYSFS_HAVE_LLSEEK
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   339
      loff_t retoffset;
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   340
      int rc = llseek(fd, 0, &retoffset, SEEK_CUR);
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   341
      BAIL_IF_MACRO(rc == -1, strerror(errno), -1);
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   342
      retval = (PHYSFS_sint64) retoffset;
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   343
    #else
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   344
      retval = (PHYSFS_sint64) lseek(fd, 0, SEEK_CUR);
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   345
      BAIL_IF_MACRO(retval == -1, strerror(errno), -1);
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   346
    #endif
bd65a0d74e9a 64-bit _llseek() support for the future.
Ryan C. Gordon <icculus@icculus.org>
parents: 255
diff changeset
   347
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   348
    return retval;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   349
} /* __PHYSFS_platformTell */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   350
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   351
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   352
PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   353
{
1117
968e1567f4f4 Constification.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   354
    const int fd = *((int *) opaque);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   355
    struct stat statbuf;
251
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   356
    BAIL_IF_MACRO(fstat(fd, &statbuf) == -1, strerror(errno), -1);
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   357
    return ((PHYSFS_sint64) statbuf.st_size);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   358
} /* __PHYSFS_platformFileLength */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   359
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   360
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   361
int __PHYSFS_platformEOF(void *opaque)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   362
{
1117
968e1567f4f4 Constification.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   363
    const PHYSFS_sint64 pos = __PHYSFS_platformTell(opaque);
968e1567f4f4 Constification.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   364
    const PHYSFS_sint64 len = __PHYSFS_platformFileLength(opaque);
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   365
    return (pos >= len);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   366
} /* __PHYSFS_platformEOF */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   367
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   368
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   369
int __PHYSFS_platformFlush(void *opaque)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   370
{
1117
968e1567f4f4 Constification.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   371
    const int fd = *((int *) opaque);
251
0f4615263e32 Actual POSIX calls to replace ANSI stdio routines.
Ryan C. Gordon <icculus@icculus.org>
parents: 249
diff changeset
   372
    BAIL_IF_MACRO(fsync(fd) == -1, strerror(errno), 0);
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   373
    return 1;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   374
} /* __PHYSFS_platformFlush */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   375
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   376
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1117
diff changeset
   377
void __PHYSFS_platformClose(void *opaque)
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   378
{
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1117
diff changeset
   379
    const int fd = *((int *) opaque);
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1117
diff changeset
   380
    (void) close(fd);  /* we don't check this. You should have used flush! */
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   381
    allocator.Free(opaque);
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   382
} /* __PHYSFS_platformClose */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   383
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   384
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   385
int __PHYSFS_platformDelete(const char *path)
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   386
{
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   387
    BAIL_IF_MACRO(remove(path) == -1, strerror(errno), 0);
1016
957c97389257 Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 972
diff changeset
   388
    return 1;
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   389
} /* __PHYSFS_platformDelete */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   390
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 235
diff changeset
   391
1054
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   392
int __PHYSFS_platformStat(const char *filename, int *exists, PHYSFS_Stat *st)
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   393
{
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   394
    struct stat statbuf;
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   395
1126
f7877496507c Use lstat() instead of stat() for POSIX __PHYSFS_platformStat().
Ryan C. Gordon <icculus@icculus.org>
parents: 1125
diff changeset
   396
    if (lstat(filename, &statbuf))
1054
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   397
    {
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   398
        if (errno == ENOENT)
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   399
        {
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   400
            *exists = 0;
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   401
            return 0;
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   402
        } /* if */
1106
94c3669d0311 Fixed PHYSFS_stat()'s return value to match rest of PhysicsFS API.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
   403
94c3669d0311 Fixed PHYSFS_stat()'s return value to match rest of PhysicsFS API.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
   404
        BAIL_MACRO(strerror(errno), 0);
1054
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   405
    } /* if */
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   406
1167
9d84f8652839 POSIX version of __PHYSFS_platformStat() forgot to set *exists properly.
Ryan C. Gordon <icculus@icculus.org>
parents: 1129
diff changeset
   407
    *exists = 1;
9d84f8652839 POSIX version of __PHYSFS_platformStat() forgot to set *exists properly.
Ryan C. Gordon <icculus@icculus.org>
parents: 1129
diff changeset
   408
1054
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   409
    if (S_ISREG(statbuf.st_mode))
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   410
    {
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   411
        st->filetype = PHYSFS_FILETYPE_REGULAR;
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   412
        st->filesize = statbuf.st_size;
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   413
    } /* if */
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   414
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   415
    else if(S_ISDIR(statbuf.st_mode))
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   416
    {
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   417
        st->filetype = PHYSFS_FILETYPE_DIRECTORY;
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   418
        st->filesize = 0;
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   419
    } /* else if */
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   420
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   421
    else
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   422
    {
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   423
        st->filetype = PHYSFS_FILETYPE_OTHER;
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   424
        st->filesize = statbuf.st_size;
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   425
    } /* else */
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   426
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   427
    st->modtime = statbuf.st_mtime;
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   428
    st->createtime = statbuf.st_ctime;
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   429
    st->accesstime = statbuf.st_atime;
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   430
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   431
    /* !!! FIXME: maybe we should just report full permissions? */
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   432
    st->readonly = access(filename, W_OK);
1106
94c3669d0311 Fixed PHYSFS_stat()'s return value to match rest of PhysicsFS API.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
   433
    return 1;
1054
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   434
} /* __PHYSFS_platformStat */
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   435
818
e36f23f49042 Now compiles everything whether we need it or not, removing whole files with
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   436
#endif  /* PHYSFS_PLATFORM_POSIX */
310
f8bca4a93fd5 Patched to compile on Cygwin.
Ryan C. Gordon <icculus@icculus.org>
parents: 292
diff changeset
   437
235
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   438
/* end of posix.c ... */
4ad12914f652 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   439