| 346 | } |
| 347 | |
| 348 | const char* FileSystem::GetFile(const char* path, size_t& size, size_t& extPos, Type& type, Int32& parentPos) { |
| 349 | const char* cur(path + size); |
| 350 | size = 0; |
| 351 | bool scanDots(true); |
| 352 | UInt16 level(1); |
| 353 | extPos = string::npos; |
| 354 | bool firstChar(true); |
| 355 | type = FOLDER; |
| 356 | |
| 357 | while (cur-- > path) { |
| 358 | if (*cur == '/' || *cur == '\\') { |
| 359 | if (firstChar) { |
| 360 | type = FOLDER; |
| 361 | firstChar = false; |
| 362 | } |
| 363 | if (size) { |
| 364 | if (scanDots) |
| 365 | level += UInt16(size); |
| 366 | else { |
| 367 | if (!level) |
| 368 | break; |
| 369 | scanDots = true; |
| 370 | extPos = string::npos; |
| 371 | } |
| 372 | size = 0; |
| 373 | } |
| 374 | continue; |
| 375 | } |
| 376 | |
| 377 | if (firstChar) { |
| 378 | type = FILE; |
| 379 | firstChar = false; |
| 380 | } |
| 381 | |
| 382 | if (!scanDots && level) |
| 383 | continue; |
| 384 | if (!size++) |
| 385 | --level; |
| 386 | |
| 387 | if (extPos==string::npos && *cur == '.') { |
| 388 | if (scanDots) { |
| 389 | if (size < 3) |
| 390 | continue; |
| 391 | extPos = 1; |
| 392 | } else |
| 393 | extPos = size; |
| 394 | } |
| 395 | scanDots = false; |
| 396 | } |
| 397 | |
| 398 | if (scanDots) // nothing or . or .. or something with backslash (...../) |
| 399 | level += UInt16(size); |
| 400 | |
| 401 | if (level) { |
| 402 | size = 0; // no name! |
| 403 | if (FileSystem::IsAbsolute(path)) { |
| 404 | #if defined(_WIN32) |
| 405 | parentPos = isalpha(*path) ? 3 : 1; // C:/ or / |