Skip to content

Commit

Permalink
Darwin support by Patrick Stein.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Mar 5, 2002
1 parent 7484d7c commit cb2a15d
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion platform/unix.c
Expand Up @@ -6,6 +6,12 @@
* This file written by Ryan C. Gordon.
*/

#if ((defined __APPLE__) && (defined __MACH__))
# if (!defined __DARWIN__)
# define __DARWIN__
# endif
#endif

#if (defined __STRICT_ANSI__)
#define __PHYSFS_DOING_STRICT_ANSI__
#endif
Expand Down Expand Up @@ -40,13 +46,65 @@
#include <time.h>
#include <errno.h>
#include <mntent.h>
#include <sys/mount.h>

#if (defined __DARWIN__)
#include <sys/ucred.h>
#endif

#define __PHYSICSFS_INTERNAL__
#include "physfs_internal.h"


const char *__PHYSFS_platformDirSeparator = "/";


#if (defined __DARWIN__)

char **__PHYSFS_platformDetectAvailableCDs(void)
{
char **retval = (char **) malloc(sizeof (char *));
int cd_count = 1; /* We count the NULL entry. */
struct statfs* mntbufp = NULL;
int mounts;
int ii;

mounts = getmntinfo( &mntbufp, MNT_WAIT );

for ( ii=0; ii < mounts; ++ii ) {
int add_it = 0;

if ( strcmp( mntbufp[ii].f_fstypename, "iso9660") == 0 )
add_it = 1;
/* !!! other mount types? */

if (add_it)
{
char **tmp = realloc(retval, sizeof (char *) * cd_count + 1);
if (tmp)
{
retval = tmp;
retval[cd_count-1] = (char *)
malloc(strlen(mntbufp[ ii ].f_mntonname) + 1);
if (retval[cd_count-1])
{
strcpy(retval[cd_count-1], mntbufp[ ii ].f_mntonname);
cd_count++;
} /* if */
} /* if */
} /* if */
}

free( mntbufp );

retval[cd_count - 1] = NULL;
return(retval);
} /* __PHYSFS_platformDetectAvailableCDs */


#else /* non-Darwin implementation... */


char **__PHYSFS_platformDetectAvailableCDs(void)
{
char **retval = (char **) malloc(sizeof (char *));
Expand Down Expand Up @@ -85,7 +143,9 @@ char **__PHYSFS_platformDetectAvailableCDs(void)

retval[cd_count - 1] = NULL;
return(retval);
} /* __PHYSFS_detectAvailableCDs */
} /* __PHYSFS_platformDetectAvailableCDs */

#endif


static char *copyEnvironmentVariable(const char *varname)
Expand Down

0 comments on commit cb2a15d

Please sign in to comment.