author | koda |
Tue, 20 Nov 2012 18:51:42 +0100 | |
changeset 8074 | 768427321cab |
parent 8052 | 845b5ae03841 |
child 8119 | 257ffa847aa2 |
permissions | -rw-r--r-- |
8052 | 1 |
#include <string.h> |
2 |
#include <stdio.h> |
|
3 |
#include <stdlib.h> |
|
8074
768427321cab
thou shall not use system headers for crossplatformness
koda
parents:
8052
diff
changeset
|
4 |
#include "physfs.h" |
8052 | 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 |
} |