| 422 | } |
| 423 | |
| 424 | void CardReader::getLongPath(char * const pathLong, char * const pathShort) { |
| 425 | |
| 426 | int i, pathLen = strlen(pathShort); |
| 427 | char bufShort[FILENAME_LENGTH] = { '\0' }; |
| 428 | strcpy_P(bufShort, pathShort); |
| 429 | |
| 430 | // Zero out slashes to make segments |
| 431 | for (i = 0; i < pathLen; i++) if (bufShort[i] == '/') bufShort[i] = '\0'; |
| 432 | |
| 433 | SdFile diveDir = root; // start from the root for segment 1 |
| 434 | for (i = 0; i < pathLen;) { |
| 435 | |
| 436 | if (bufShort[i] == '\0') i++; // move past a single nul |
| 437 | |
| 438 | char *segment = &bufShort[i]; // The segment after most slashes |
| 439 | |
| 440 | // If a segment is empty (extra-slash) then exit |
| 441 | if (!*segment) break; |
| 442 | |
| 443 | //SERIAL_ECHOLNPGM("Looking for segment: ", segment); |
| 444 | |
| 445 | // Find the item, setting the long filename |
| 446 | diveDir.rewind(); |
| 447 | selectByName(diveDir, segment); |
| 448 | diveDir.close(); |
| 449 | |
| 450 | if (longFilename[0]) { |
| 451 | strlcpy_P(pathLong, longFilename, 64); |
| 452 | break; |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | #endif // LONG_FILENAME_HOST_SUPPORT |
| 458 |
no test coverage detected