platform/win32.c
changeset 362 ac8c846a0a66
parent 338 4f6d300bf1d7
child 427 c38ace41039f
equal deleted inserted replaced
361:0f945e89d537 362:ac8c846a0a66
   422 
   422 
   423 
   423 
   424 LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
   424 LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
   425                                                   int omitSymLinks)
   425                                                   int omitSymLinks)
   426 {
   426 {
   427     LinkedStringList *retval = NULL;
   427     LinkedStringList *retval = NULL, *p = NULL;
   428     LinkedStringList *l = NULL;
       
   429     LinkedStringList *prev = NULL;
       
   430     HANDLE dir;
   428     HANDLE dir;
   431     WIN32_FIND_DATA ent;
   429     WIN32_FIND_DATA ent;
   432     char *SearchPath;
   430     char *SearchPath;
   433     size_t len = strlen(dirname);
   431     size_t len = strlen(dirname);
   434 
   432 
   458             continue;
   456             continue;
   459 
   457 
   460         if (strcmp(ent.cFileName, "..") == 0)
   458         if (strcmp(ent.cFileName, "..") == 0)
   461             continue;
   459             continue;
   462 
   460 
   463         l = (LinkedStringList *) malloc(sizeof (LinkedStringList));
   461         retval = __PHYSFS_addToLinkedStringList(retval, &p, ent.cFileName, -1);
   464         if (l == NULL)
       
   465             break;
       
   466 
       
   467         l->str = (char *) malloc(strlen(ent.cFileName) + 1);
       
   468         if (l->str == NULL)
       
   469         {
       
   470             free(l);
       
   471             break;
       
   472         } /* if */
       
   473 
       
   474         strcpy(l->str, ent.cFileName);
       
   475 
       
   476         if (retval == NULL)
       
   477             retval = l;
       
   478         else
       
   479             prev->next = l;
       
   480 
       
   481         prev = l;
       
   482         l->next = NULL;
       
   483     } while (FindNextFile(dir, &ent) != 0);
   462     } while (FindNextFile(dir, &ent) != 0);
   484 
   463 
   485     FindClose(dir);
   464     FindClose(dir);
   486     return(retval);
   465     return(retval);
   487 } /* __PHYSFS_platformEnumerateFiles */
   466 } /* __PHYSFS_platformEnumerateFiles */