platform/unix.c
changeset 381 b65d27fdc8a9
parent 351 bc4fa7896225
child 390 6649d6caecf2
equal deleted inserted replaced
380:ac96d444dd57 381:b65d27fdc8a9
    56 {
    56 {
    57     return(1);  /* always succeed. */
    57     return(1);  /* always succeed. */
    58 } /* __PHYSFS_platformDeinit */
    58 } /* __PHYSFS_platformDeinit */
    59 
    59 
    60 
    60 
       
    61 #ifdef PHYSFS_NO_CDROM_SUPPORT
       
    62 
       
    63 /* Stub version for platforms without CD-ROM support. */
       
    64 char **__PHYSFS_platformDetectAvailableCDs(void)
       
    65 {
       
    66     char **retval = (char **) malloc(sizeof (char *));
       
    67     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
       
    68     *retval = NULL;
       
    69     return(retval);
       
    70 } /* __PHYSFS_platformDetectAvailableCDs */
       
    71 
       
    72 #else
       
    73 
    61 
    74 
    62 #ifdef PHYSFS_HAVE_SYS_UCRED_H
    75 #ifdef PHYSFS_HAVE_SYS_UCRED_H
    63 
    76 
    64 char **__PHYSFS_platformDetectAvailableCDs(void)
    77 char **__PHYSFS_platformDetectAvailableCDs(void)
    65 {
    78 {
    66     char **retval = (char **) malloc(sizeof (char *));
    79     char **retval = (char **) malloc(sizeof (char *));
    67     int cd_count = 1;  /* We count the NULL entry. */
    80     int cd_count = 1;  /* We count the NULL entry. */
    68     struct statfs* mntbufp = NULL;
    81     struct statfs *mntbufp = NULL;
    69     int mounts;
    82     int mounts;
    70     int ii;
    83     int i;
    71 
    84 
    72     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
    85     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
    73 
    86 
    74     mounts = getmntinfo( &mntbufp, MNT_WAIT );
    87     mounts = getmntinfo(&mntbufp, MNT_WAIT);
    75 
    88 
    76     for ( ii=0; ii < mounts; ++ii ) {
    89     for (i = 0; i < mounts; i++)
       
    90     {
    77         int add_it = 0;
    91         int add_it = 0;
    78 
    92 
    79         if ( strcmp( mntbufp[ii].f_fstypename, "iso9660") == 0 )
    93         if (strcmp(mntbufp[i].f_fstypename, "iso9660") == 0)
    80             add_it = 1;
    94             add_it = 1;
    81         else if ( strcmp( mntbufp[ii].f_fstypename, "cd9660") == 0 )
    95         else if (strcmp( mntbufp[i].f_fstypename, "cd9660") == 0)
    82             add_it = 1;
    96             add_it = 1;
    83 
    97 
    84         /* add other mount types here */
    98         /* add other mount types here */
    85 
    99 
    86         if (add_it)
   100         if (add_it)
    88             char **tmp = realloc(retval, sizeof (char *) * (cd_count + 1));
   102             char **tmp = realloc(retval, sizeof (char *) * (cd_count + 1));
    89             if (tmp)
   103             if (tmp)
    90             {
   104             {
    91                 retval = tmp;
   105                 retval = tmp;
    92                 retval[cd_count - 1] = (char *)
   106                 retval[cd_count - 1] = (char *)
    93                                 malloc(strlen(mntbufp[ii].f_mntonname) + 1);
   107                                 malloc(strlen(mntbufp[i].f_mntonname) + 1);
    94                 if (retval[cd_count - 1])
   108                 if (retval[cd_count - 1])
    95                 {
   109                 {
    96                     strcpy(retval[cd_count - 1], mntbufp[ii].f_mntonname);
   110                     strcpy(retval[cd_count - 1], mntbufp[i].f_mntonname);
    97                     cd_count++;
   111                     cd_count++;
    98                 } /* if */
   112                 } /* if */
    99             } /* if */
   113             } /* if */
   100         } /* if */
   114         } /* if */
   101     }
   115     } /* for */
   102 
   116 
   103     retval[cd_count - 1] = NULL;
   117     retval[cd_count - 1] = NULL;
   104     return(retval);
   118     return(retval);
   105 } /* __PHYSFS_platformDetectAvailableCDs */
   119 } /* __PHYSFS_platformDetectAvailableCDs */
   106 
   120 
   152     return(retval);
   166     return(retval);
   153 } /* __PHYSFS_platformDetectAvailableCDs */
   167 } /* __PHYSFS_platformDetectAvailableCDs */
   154 
   168 
   155 #endif
   169 #endif
   156 
   170 
       
   171 #endif  /* !PHYSFS_NO_CDROM_SUPPORT */
       
   172 
   157 
   173 
   158 /* this is in posix.c ... */
   174 /* this is in posix.c ... */
   159 extern char *__PHYSFS_platformCopyEnvironmentVariable(const char *varname);
   175 extern char *__PHYSFS_platformCopyEnvironmentVariable(const char *varname);
   160 
   176 
   161 
   177 
   240 } /* __PHYSFS_platformCalcBaseDir */
   256 } /* __PHYSFS_platformCalcBaseDir */
   241 
   257 
   242 
   258 
   243 PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
   259 PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
   244 {
   260 {
   245     return((PHYSFS_uint64) ((PHYSFS_uint32) pthread_self()));
   261     return((PHYSFS_uint64) pthread_self());
   246 } /* __PHYSFS_platformGetThreadID */
   262 } /* __PHYSFS_platformGetThreadID */
   247 
   263 
   248 
   264 
   249 /* Much like my college days, try to sleep for 10 milliseconds at a time... */
   265 /* Much like my college days, try to sleep for 10 milliseconds at a time... */
   250 void __PHYSFS_platformTimeslice(void)
   266 void __PHYSFS_platformTimeslice(void)