misc/physfs/extras/hwpacksmounter.c
branchicegun
changeset 8604 fa44e3218a08
parent 8589 3bb505fc707e
parent 8603 1b58da1fd9bf
child 8606 45f6c35ffd33
equal deleted inserted replaced
8589:3bb505fc707e 8604:fa44e3218a08
     1 #include <string.h>
       
     2 #include <stdio.h>
       
     3 #include <stdlib.h>
       
     4 
       
     5 #include "hwpacksmounter.h"
       
     6 
       
     7 PHYSFS_DECL void hedgewarsMountPackages()
       
     8 {
       
     9     char ** filesList = PHYSFS_enumerateFiles("/");
       
    10     char **i;
       
    11 
       
    12     for (i = filesList; *i != NULL; i++)
       
    13     {
       
    14         char * fileName = *i;
       
    15         int fileNameLength = strlen(fileName);
       
    16         if (fileNameLength > 4)
       
    17             if (strcmp(fileName + fileNameLength - 4, ".hwp") == 0)
       
    18             {
       
    19                 const char * dir = PHYSFS_getRealDir(fileName);
       
    20                 if(dir)
       
    21                 {
       
    22                     char * fullPath = (char *)malloc(strlen(dir) + fileNameLength + 2);
       
    23                     strcpy(fullPath, dir);
       
    24                     strcat(fullPath, "/");
       
    25                     strcat(fullPath, fileName);
       
    26 
       
    27                     PHYSFS_mount(fullPath, NULL, 1);
       
    28 
       
    29                     free(fullPath);
       
    30                 }
       
    31             }
       
    32     }
       
    33 
       
    34     PHYSFS_freeList(filesList);
       
    35 }