misc/libphyslayer/hwpacksmounter.c
author nemo
Wed, 06 Mar 2013 12:55:48 -0500
changeset 8676 c00f1df47cef
parent 8524 a65e9bcf0a03
child 8714 ab201a62d115
permissions -rw-r--r--
Add missing feedback button translation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8052
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
     1
#include <string.h>
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
     2
#include <stdio.h>
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
     3
#include <stdlib.h>
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
     4
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
     5
#include "hwpacksmounter.h"
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
     6
8119
257ffa847aa2 physfs: no carbon depency on osx, add cdecl attributes on extra functions
koda
parents: 8074
diff changeset
     7
PHYSFS_DECL void hedgewarsMountPackages()
8052
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
     8
{
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
     9
    char ** filesList = PHYSFS_enumerateFiles("/");
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    10
    char **i;
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    11
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    12
    for (i = filesList; *i != NULL; i++)
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    13
    {
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    14
        char * fileName = *i;
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    15
        int fileNameLength = strlen(fileName);
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    16
        if (fileNameLength > 4)
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    17
            if (strcmp(fileName + fileNameLength - 4, ".hwp") == 0)
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    18
            {
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    19
                const char * dir = PHYSFS_getRealDir(fileName);
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    20
                if(dir)
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    21
                {
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    22
                    char * fullPath = (char *)malloc(strlen(dir) + fileNameLength + 2);
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    23
                    strcpy(fullPath, dir);
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    24
                    strcat(fullPath, "/");
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    25
                    strcat(fullPath, fileName);
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    26
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    27
                    PHYSFS_mount(fullPath, NULL, 1);
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    28
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    29
                    free(fullPath);
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    30
                }
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    31
            }
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    32
    }
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    33
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    34
    PHYSFS_freeList(filesList);
845b5ae03841 Mount .hwt files found in Data folder
unc0rr
parents:
diff changeset
    35
}