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