112 |
110 |
113 sprintf(buf, "%s%s", _path.data_dir, filename); |
111 sprintf(buf, "%s%s", _path.data_dir, filename); |
114 |
112 |
115 f = fopen(buf, "rb"); |
113 f = fopen(buf, "rb"); |
116 #if !defined(WIN32) |
114 #if !defined(WIN32) |
117 if (f == NULL) { |
115 if (f == NULL) { // Make lower case and try again |
118 char *s; |
116 strtolower(buf + strlen(_path.data_dir) - 1); |
119 // Make lower case and try again |
|
120 for (s = buf + strlen(_path.data_dir) - 1; *s != 0; s++) |
|
121 *s = tolower(*s); |
|
122 f = fopen(buf, "rb"); |
117 f = fopen(buf, "rb"); |
123 |
118 |
124 #if defined SECOND_DATA_DIR |
119 #if defined SECOND_DATA_DIR |
125 // tries in the 2nd data directory |
120 // tries in the 2nd data directory |
126 if (f == NULL) { |
121 if (f == NULL) { |
127 sprintf(buf, "%s%s", _path.second_data_dir, filename); |
122 sprintf(buf, "%s%s", _path.second_data_dir, filename); |
128 for (s = buf + strlen(_path.second_data_dir) - 1; *s != 0; s++) |
123 strtolower(buf + strlen(_path.second_data_dir) - 1); |
129 *s = tolower(*s); |
124 f = fopen(buf, "rb"); |
130 f = fopen(buf, "rb"); |
|
131 } |
125 } |
132 #endif |
126 #endif |
133 } |
127 } |
134 #endif |
128 #endif |
135 |
129 |
149 sprintf(buf, "%s%s", _path.data_dir, filename); |
143 sprintf(buf, "%s%s", _path.data_dir, filename); |
150 |
144 |
151 f = fopen(buf, "rb"); |
145 f = fopen(buf, "rb"); |
152 #if !defined(WIN32) |
146 #if !defined(WIN32) |
153 if (f == NULL) { |
147 if (f == NULL) { |
154 char *s; |
148 strtolower(buf + strlen(_path.data_dir) - 1); |
155 // Make lower case and try again |
|
156 for (s = buf + strlen(_path.data_dir) - 1; *s != 0; s++) |
|
157 *s = tolower(*s); |
|
158 f = fopen(buf, "rb"); |
149 f = fopen(buf, "rb"); |
159 |
150 |
160 #if defined SECOND_DATA_DIR |
151 #if defined SECOND_DATA_DIR |
161 // tries in the 2nd data directory |
152 // tries in the 2nd data directory |
162 if (f == NULL) { |
153 if (f == NULL) { |
163 sprintf(buf, "%s%s", _path.second_data_dir, filename); |
154 sprintf(buf, "%s%s", _path.second_data_dir, filename); |
164 for (s = buf + strlen(_path.second_data_dir) - 1; *s != 0; s++) |
155 strtolower(buf + strlen(_path.second_data_dir) - 1); |
165 *s = tolower(*s); |
|
166 f = fopen(buf, "rb"); |
156 f = fopen(buf, "rb"); |
167 } |
157 } |
168 #endif |
158 #endif |
169 } |
159 } |
170 #endif |
160 #endif |
180 sprintf(buf, "%s%s", _path.data_dir, filename); |
170 sprintf(buf, "%s%s", _path.data_dir, filename); |
181 |
171 |
182 f = fopen(buf, "rb"); |
172 f = fopen(buf, "rb"); |
183 #if !defined(WIN32) |
173 #if !defined(WIN32) |
184 if (f == NULL) { |
174 if (f == NULL) { |
185 char *s; |
175 strtolower(buf + strlen(_path.data_dir) - 1); |
186 // Make lower case and try again |
|
187 for (s = buf + strlen(_path.data_dir) - 1; *s != 0; s++) |
|
188 *s = tolower(*s); |
|
189 f = fopen(buf, "rb"); |
176 f = fopen(buf, "rb"); |
190 |
177 |
191 #if defined SECOND_DATA_DIR |
178 #if defined SECOND_DATA_DIR |
192 // tries in the 2nd data directory |
179 // tries in the 2nd data directory |
193 if (f == NULL) { |
180 if (f == NULL) { |
194 sprintf(buf, "%s%s", _path.second_data_dir, filename); |
181 sprintf(buf, "%s%s", _path.second_data_dir, filename); |
195 for (s = buf + strlen(_path.second_data_dir) - 1; *s != 0; s++) |
182 strtolower(buf + strlen(_path.second_data_dir) - 1); |
196 *s = tolower(*s); |
183 f = fopen(buf, "rb"); |
197 f = fopen(buf, "rb"); |
|
198 } |
184 } |
199 |
185 |
200 if (f == NULL) |
186 if (f == NULL) |
201 sprintf(buf, "%s%s", _path.data_dir, filename); //makes it print the primary datadir path instead of the secundary one |
187 sprintf(buf, "%s%s", _path.data_dir, filename); //makes it print the primary datadir path instead of the secundary one |
202 |
188 |