1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
#ifdef _WIN32
#include "windows.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* Paths: */
extern char **g_paths;
extern int n_g_paths,act_g_path;
extern char *g_path;
extern char **s_paths;
extern int n_s_paths,act_s_path;
extern char *s_path;
#ifdef _WIN32
void init_paths(void)
{
if (g_paths==NULL) {
WIN32_FIND_DATA finfo;
HANDLE h;
int i,j;
char **tmp_g_paths;
n_g_paths=0;
h=FindFirstFile("graphics\\*.*",&finfo);
if (h!=INVALID_HANDLE_VALUE) {
if (strcmp(finfo.cFileName,".")!=0 &&
strcmp(finfo.cFileName,"..")!=0) {
i=0;
n_g_paths=1;
g_paths=new char *[1];
g_paths[i]=new char[256];
sprintf(g_paths[i++],"graphics\\%s\\",strupr(finfo.cFileName));
} /* if */
while(FindNextFile(h,&finfo)==TRUE) {
if (strcmp(finfo.cFileName,".")!=0 &&
strcmp(finfo.cFileName,"..")!=0) {
if (n_g_paths==0) {
i=0;
n_g_paths=1;
g_paths=new char *[1];
g_paths[i]=new char[256];
sprintf(g_paths[i++],"graphics\\%s\\",strupr(finfo.cFileName));
} else {
tmp_g_paths=g_paths;
n_g_paths++;
g_paths=new char *[i+1];
for(j=0;j<i;j++) {
g_paths[j]=tmp_g_paths[j];
} /* for */
delete tmp_g_paths;
g_paths[i]=new char[256];
sprintf(g_paths[i++],"graphics\\%s\\",strupr(finfo.cFileName));
} /* if */
} /* if */
} /* while */
} else {
g_paths=new char *[2];
g_paths[0]=new char[256];
g_paths[1]=new char[256];
strcpy(g_paths[0],"graphics\\original\\");
strcpy(g_paths[1],"graphics\\alternate\\");
} /* if */
act_g_path=0;
g_path=g_paths[act_g_path];
} /* if */
if (s_paths==NULL) {
WIN32_FIND_DATA finfo;
HANDLE h;
int i,j;
char **tmp_s_paths;
n_s_paths=0;
h=FindFirstFile("sound\\*.*",&finfo);
if (h!=INVALID_HANDLE_VALUE) {
if (strcmp(finfo.cFileName,".")!=0 &&
strcmp(finfo.cFileName,"..")!=0) {
i=0;
n_s_paths=1;
s_paths=new char *[1];
s_paths[i]=new char[256];
sprintf(s_paths[i++],"sound\\%s\\",strupr(finfo.cFileName));
} /* if */
while(FindNextFile(h,&finfo)==TRUE) {
if (strcmp(finfo.cFileName,".")!=0 &&
strcmp(finfo.cFileName,"..")!=0) {
if (n_s_paths==0) {
i=0;
n_s_paths=1;
s_paths=new char *[1];
s_paths[i]=new char[256];
sprintf(s_paths[i++],"sound\\%s\\",strupr(finfo.cFileName));
} else {
tmp_s_paths=s_paths;
n_s_paths++;
s_paths=new char *[i+1];
for(j=0;j<i;j++) {
s_paths[j]=tmp_s_paths[j];
} /* for */
delete tmp_s_paths;
s_paths[i]=new char[256];
sprintf(s_paths[i++],"sound\\%s\\",strupr(finfo.cFileName));
} /* if */
} /* if */
} /* while */
} else {
s_paths=new char *[2];
s_paths[0]=new char[256];
s_paths[1]=new char[256];
strcpy(s_paths[0],"sound\\original\\");
strcpy(s_paths[1],"sound\\alternate\\");
} /* if */
act_s_path=0;
s_path=s_paths[act_s_path];
} /* if */
} /* init_paths */
#else
void init_paths(void)
{
if (g_paths == NULL)
{
g_paths=new char *[2];
g_paths[0]=new char[256];
g_paths[1]=new char[256];
strcpy(g_paths[0],"graphics/original/");
strcpy(g_paths[1],"graphics/alternate/");
n_g_paths=2;
s_paths=new char *[2];
s_paths[0]=new char[256];
s_paths[1]=new char[256];
strcpy(s_paths[0],"sound/original/");
strcpy(s_paths[1],"sound/alternate/");
n_s_paths=2;
act_g_path=0;
g_path=g_paths[act_g_path];
act_s_path=0;
s_path=s_paths[act_s_path];
}
}
#endif
|