misc/libphyslayer/hwpacksmounter.c
author nemo
Wed, 06 Mar 2013 08:26:14 -0500
changeset 8668 b04a3724e328
parent 8524 a65e9bcf0a03
child 8714 ab201a62d115
permissions -rw-r--r--
extend time a bit. move to defrosting on team's turn. fairer than using round order I think.

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include "hwpacksmounter.h"

PHYSFS_DECL void hedgewarsMountPackages()
{
    char ** filesList = PHYSFS_enumerateFiles("/");
    char **i;

    for (i = filesList; *i != NULL; i++)
    {
        char * fileName = *i;
        int fileNameLength = strlen(fileName);
        if (fileNameLength > 4)
            if (strcmp(fileName + fileNameLength - 4, ".hwp") == 0)
            {
                const char * dir = PHYSFS_getRealDir(fileName);
                if(dir)
                {
                    char * fullPath = (char *)malloc(strlen(dir) + fileNameLength + 2);
                    strcpy(fullPath, dir);
                    strcat(fullPath, "/");
                    strcat(fullPath, fileName);

                    PHYSFS_mount(fullPath, NULL, 1);

                    free(fullPath);
                }
            }
    }

    PHYSFS_freeList(filesList);
}