|
26 | 26 | #include <TRE/TREMainModel.h> |
27 | 27 | #include "StudLogo.h" |
28 | 28 | #include "LDViewMessages.h" |
| 29 | +#include <TCFoundation/filecase.h> |
29 | 30 |
|
30 | 31 | typedef std::map<std::string, std::string> StringMap; |
31 | 32 |
|
@@ -138,129 +139,6 @@ void *setupContext(OSMesaContext &ctx) |
138 | 139 | } |
139 | 140 | #endif |
140 | 141 |
|
141 | | -bool dirExists(const std::string &path) |
142 | | -{ |
143 | | - struct stat buf; |
144 | | - if (stat(path.c_str(), &buf) != 0) |
145 | | - { |
146 | | - return false; |
147 | | - } |
148 | | - return S_ISDIR(buf.st_mode); |
149 | | -} |
150 | | - |
151 | | -bool fileOrDirExists(const std::string &path) |
152 | | -{ |
153 | | - struct stat buf; |
154 | | - if (stat(path.c_str(), &buf) != 0) |
155 | | - { |
156 | | - return false; |
157 | | - } |
158 | | - return S_ISREG(buf.st_mode) || S_ISDIR(buf.st_mode); |
159 | | -} |
160 | | - |
161 | | -bool findDirEntry(std::string &path) |
162 | | -{ |
163 | | - size_t lastSlash = path.rfind('/'); |
164 | | - if (lastSlash >= path.size()) |
165 | | - { |
166 | | - return false; |
167 | | - } |
168 | | - std::string dirName = path.substr(0, lastSlash); |
169 | | - std::string lowerFilename = lowerCaseString(path.substr(lastSlash + 1)); |
170 | | - DIR *dir = opendir(dirName.c_str()); |
171 | | - if (dir == NULL) |
172 | | - { |
173 | | - return false; |
174 | | - } |
175 | | - bool found = false; |
176 | | - while (!found) |
177 | | - { |
178 | | - struct dirent *entry = readdir(dir); |
179 | | - if (entry == NULL) |
180 | | - { |
181 | | - break; |
182 | | - } |
183 | | - std::string name = lowerCaseString(entry->d_name); |
184 | | - if (name == lowerFilename) |
185 | | - { |
186 | | - path = dirName + '/' + entry->d_name; |
187 | | - found = true; |
188 | | - } |
189 | | - } |
190 | | - closedir(dir); |
191 | | - return found; |
192 | | -} |
193 | | - |
194 | | -bool fileCaseCallback(char *filename) |
195 | | -{ |
196 | | - StringMap s_pathMap; |
197 | | - size_t count; |
198 | | - char **components = componentsSeparatedByString(filename, "/", count); |
199 | | - std::string lowerFilename = lowerCaseString(filename); |
200 | | - |
201 | | - StringMap::iterator it = s_pathMap.find(lowerFilename); |
202 | | - if (it != s_pathMap.end()) |
203 | | - { |
204 | | - strcpy(filename, it->second.c_str()); |
205 | | - return true; |
206 | | - } |
207 | | - if (count > 1) |
208 | | - { |
209 | | - bool ok = true; |
210 | | - std::string builtPath = "/"; |
211 | | - for (size_t i = 1; i + 1 < count && ok; ++i) |
212 | | - { |
213 | | - builtPath += components[i]; |
214 | | - |
215 | | - it = s_pathMap.find(builtPath); |
216 | | - if (it != s_pathMap.end()) |
217 | | - { |
218 | | - // Do nothing |
219 | | - } |
220 | | - else if (dirExists(builtPath)) |
221 | | - { |
222 | | - s_pathMap[lowerCaseString(builtPath)] = builtPath; |
223 | | - } |
224 | | - else if (findDirEntry(builtPath)) |
225 | | - { |
226 | | - s_pathMap[lowerCaseString(builtPath)] = builtPath; |
227 | | - if (!dirExists(builtPath)) |
228 | | - { |
229 | | - ok = false; |
230 | | - } |
231 | | - } |
232 | | - else |
233 | | - { |
234 | | - ok = false; |
235 | | - } |
236 | | - if (ok) |
237 | | - { |
238 | | - builtPath += '/'; |
239 | | - } |
240 | | - } |
241 | | - if (ok) |
242 | | - { |
243 | | - builtPath += components[count - 1]; |
244 | | - if (findDirEntry(builtPath)) |
245 | | - { |
246 | | - s_pathMap[lowerCaseString(builtPath)] = builtPath; |
247 | | - ok = fileOrDirExists(builtPath); |
248 | | - } |
249 | | - else |
250 | | - { |
251 | | - ok = false; |
252 | | - } |
253 | | - } |
254 | | - if (ok) |
255 | | - { |
256 | | - strcpy(filename, builtPath.c_str()); |
257 | | - } |
258 | | - deleteStringArray(components, count); |
259 | | - return ok; |
260 | | - } |
261 | | - return false; |
262 | | -} |
263 | | - |
264 | 142 | #ifdef EGL |
265 | 143 | void assertEGLError(const std::string& msg) { |
266 | 144 | EGLint error = eglGetError(); |
|
0 commit comments