misc/physfs/extras/hwpacksmounter.c
author dag10
Mon, 14 Jan 2013 11:19:59 +0100
changeset 8377 869f80966a77
parent 8119 257ffa847aa2
permissions -rw-r--r--
GCI2012: Improve Game Configuration Widget - Refactored mapmodel+datamanager to have two separate map models for static and mission maps, and then three static MapInfos in MapModel for the three special maps (random, maze, drawn). - Created theme selector dialog. - Created seed view/edit dialog. - Enlarged start icon on pagemultiplayer and pagenetgame, and added Start.png. - Moved "Settings" button on pagemultiplayer and pagenetgame from middle of page to page footer. - Added "load drawing" button to mapcontainer widget. - Map preview is no longer the randomize button; The randomize functionality is now in a button of its own. - Map preview no longer grays out (isn't disabled) when in slave mode. - Seed is now viewable and copyable when in slave mode -- but not editable. - You should now use the property master (isMaster() and setMaster()) on gamecfgwidget and mapcontainer instead of the enabled property. This is because some widgets (e.g. "view/edit seed" button and map preview) shouldn't be disabled, when all other widgets should be. - Added mission map descriptions w/ locale support in INI format in mapname/desc.txt if applicable. Use '|' for line break.
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
}